* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; background: #16171a; color: #d8dade; font: 14px/1.6 "Segoe UI", "Yu Gothic UI", "Hiragino Sans", sans-serif; display: flex; flex-direction: column; }
header { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; background: #0f1012; border-bottom: 1px solid #2a2c31; }
h1 { font-size: 18px; margin: 0; letter-spacing: 0.04em; font-weight: 600; }
h1 b, #power h2 b, .brand b { color: #6fe07a; font-weight: 700; }
h1 small { font-size: 12px; color: #8b8f98; font-weight: 400; margin-left: 10px; letter-spacing: 0; }
.opts { display: flex; gap: 16px; align-items: center; font-size: 12px; color: #a9adb6; }
.opts label { cursor: pointer; user-select: none; }
#meter { width: 90px; height: 8px; background: #25272c; border-radius: 4px; overflow: hidden; }
#meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #58d05a 70%, #ffd23a 85%, #ff5a5a); }
main { flex: 1; display: flex; min-height: 0; }
#left { flex: 1 1 62%; min-width: 0; padding: 14px 14px 10px 16px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
#panelWrap { width: 100%; max-width: 1180px; margin: 0 auto; container-type: inline-size; }

/* ---------------------------------------------------------------- 本体 */
#panel { position: relative; width: 100%; aspect-ratio: 614 / 352; background: linear-gradient(#44474d, #3b3e44); border-radius: 1.6cqw; box-shadow: 0 1.2cqw 3cqw #0009, inset 0 0.15cqw 0 #6a6e76, inset 0 -0.3cqw 0.6cqw #0006;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; font-size: 1.08cqw; }
#panel > div { position: absolute; }
.brand { font-size: 2.3cqw; font-weight: 700; color: #e9ebee; letter-spacing: 0.06em; display: flex; align-items: center; white-space: nowrap; }
.brand b { margin-left: 0.4em; }
.brand2 { font-size: 1.05cqw; color: #b9bdc5; display: flex; align-items: center; justify-content: flex-end; letter-spacing: 0.03em; }
.lbl { display: flex; align-items: center; justify-content: center; color: #e4e6ea; font-size: 0.98cqw; font-weight: 700; letter-spacing: 0.05em; white-space: nowrap; pointer-events: none; }
.lbl.line::before, .lbl.line::after { content: ""; flex: 1; height: 0.1cqw; background: #c9ccd2; margin: 0 0.5cqw; opacity: 0.7; }
.lbl.sub span { border: 0.1cqw solid #9da1a9; color: #b9bdc5; font-size: 0.78cqw; padding: 0 0.6cqw; border-radius: 0.2cqw; font-weight: 600; line-height: 1.35; }
.head { background: #d7dade; color: #33363b; font-size: 1.02cqw; font-weight: 800; display: flex; align-items: center; justify-content: center; border-radius: 0.15cqw; letter-spacing: 0.08em; pointer-events: none; }

.btn { --lit: 0.15; --lc: #7dff8a; background: linear-gradient(#2c2e33, #1f2125); border-radius: 0.45cqw; box-shadow: 0 0.25cqw 0.4cqw #0008, inset 0 0.1cqw 0 #50545c; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn .cap { font-weight: 800; font-size: 0.92cqw; letter-spacing: 0.03em; color: color-mix(in srgb, var(--lc) calc(var(--lit) * 100%), #8f949c); text-shadow: 0 0 calc(var(--lit) * 0.9cqw) color-mix(in srgb, var(--lc) calc(var(--lit) * 100%), transparent); }
.btn.white { --lc: #ffffff; } .btn.red { --lc: #ff5a4a; } .btn.green { --lc: #7dff8a; }
.btn.big .cap { font-size: 1.5cqw; }
.btn.down { transform: translateY(0.15cqw); box-shadow: 0 0.05cqw 0.1cqw #000a, inset 0 0.1cqw 0.3cqw #000; }
.btn.latched, .pad.latched { outline: 0.25cqw dashed #fff; outline-offset: 0.15cqw; }
.btn.latched::after, .pad.latched::after { content: "HOLD"; position: absolute; top: -1.3cqw; left: 50%; transform: translateX(-50%); font-size: 0.75cqw; background: #fff; color: #000; padding: 0 0.4cqw; border-radius: 0.2cqw; font-weight: 800; }
.key { display: none; position: absolute; right: 0.2cqw; bottom: -0.1cqw; font-size: 0.78cqw; color: #ffe14d; font-weight: 700; pointer-events: none; text-shadow: 0 0 0.2cqw #000; }
body.keys .key { display: block; }
.knob.value .key { right: 50%; transform: translateX(50%); bottom: -1.2cqw; white-space: nowrap; }

.mled { --lit: 0; border-radius: 50%; background: color-mix(in srgb, #7dff8a calc(var(--lit) * 100%), #1d2a1f); box-shadow: 0 0 calc(var(--lit) * 0.7cqw) #7dff8a; }

.knob { --ang: 0deg; border-radius: 50%; cursor: ns-resize; background: #17181b; box-shadow: 0 0.3cqw 0.6cqw #000a; }
.knob .cap { position: absolute; inset: 10%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5a5e66, #2b2d32 70%); transform: rotate(var(--ang)); box-shadow: inset 0 0.1cqw 0 #7b8089; }
.knob .cap i { position: absolute; left: 50%; top: 4%; width: 0.28cqw; height: 34%; margin-left: -0.14cqw; background: #f3f4f6; border-radius: 0.2cqw; }
.knob.ring { box-shadow: 0 0 0 0.3cqw #49c95a, 0 0.3cqw 0.6cqw #000a; }
.knob.value { box-shadow: 0 0 0 0.35cqw #49c95a, 0 0.3cqw 0.8cqw #000a; cursor: pointer; }
.knob.value .cap i { height: 22%; background: #9aa0aa; }
.knob.down .cap { filter: brightness(1.25); }
.knob.value.down { transform: scale(0.95); }

.lcd { background: #0b0d0b; border-radius: 0.4cqw; box-shadow: inset 0 0 0.8cqw #000, 0 0.1cqw 0 #5d6068; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lcd pre { margin: 0; font: 600 2.52cqw/1.28 Consolas, "Cascadia Mono", "Courier New", monospace; color: #b8f060; text-shadow: 0 0 0.5cqw #8fd13c88; white-space: pre; }

.fader { --pos: 0.2; --lit: 0.5; --tc: #fff; cursor: ns-resize; }
.fader .slot { position: absolute; left: 22%; right: 22%; top: 0; bottom: 0; border-radius: 0.5cqw; background: #141518; box-shadow: 0 0 0 0.28cqw color-mix(in srgb, var(--tc) calc(var(--lit) * 100%), #2a2c30), 0 0 calc(var(--lit) * 0.9cqw) var(--tc); }
.fader .thumb { position: absolute; left: -8%; right: -8%; height: 16%; top: calc(8% + var(--pos) * 84% - 8%); background: linear-gradient(#d9dbde, #8d9199 48%, #2b2d31 50%, #b1b4ba 54%, #c9ccd1); border-radius: 0.3cqw; box-shadow: 0 0.3cqw 0.5cqw #000b; }

.pad { --pc: #888; --pa: 0.04; border-radius: 0.55cqw; cursor: pointer; background: color-mix(in srgb, var(--pc) calc(var(--pa) * 88%), #24262a); box-shadow: 0 0.3cqw 0.5cqw #0009, inset 0 0.12cqw 0 #ffffff30, inset 0 0 calc(var(--pa) * 1.2cqw) #fff6, 0 0 calc(var(--pa) * 1.1cqw) color-mix(in srgb, var(--pc) 60%, transparent); }
.pad.down { transform: translateY(0.15cqw) scale(0.985); filter: brightness(1.2); }
.pad .num { position: absolute; right: 0.4cqw; top: 0.15cqw; font-size: 0.85cqw; font-weight: 800; color: #000a; mix-blend-mode: normal; }
.pad .guide { position: absolute; left: 0; right: 0; bottom: 0.3cqw; text-align: center; font-size: 0.86cqw; font-weight: 800; color: #fff; text-shadow: 0 0 0.25cqw #000, 0 0 0.25cqw #000, 0 0 0.25cqw #000; letter-spacing: 0; white-space: nowrap; }
body.noguide .pad .guide { display: none; }
.pad .key { right: auto; left: 0.3cqw; top: 0.1cqw; bottom: auto; }

.hint { animation: hint 0.9s ease-in-out infinite; z-index: 2; }
@keyframes hint { 0%, 100% { outline: 0.3cqw solid #ffe14d; outline-offset: 0.2cqw; } 50% { outline: 0.3cqw solid #ffe14d33; outline-offset: 0.45cqw; } }

/* ---------------------------------------------------------------- 本体のすぐ下の帯 ([HOLD] と、いまの手順 / お題)。高さを変えない (変わると本体の大きさが動く) */
#bar { max-width: 1180px; width: 100%; margin: 0 auto; flex: none; height: 44px; display: flex; align-items: center; gap: 10px; }
#holdBtn { flex: none; font: inherit; font-size: 12px; font-weight: 800; letter-spacing: 0.05em; padding: 7px 12px; border-radius: 6px; border: 1px solid #5a5e66; background: #25272d; color: #d8dade; cursor: pointer; user-select: none; -webkit-user-select: none; }
#holdBtn.armed { background: #fff; color: #000; border-color: #fff; }
#holdBtn.has { outline: 2px dashed #fff; outline-offset: 1px; }
#now { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; color: #f1f3f5; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#now b { color: #6fe07a; margin-right: 6px; }
#now .ok { color: #6fe07a; font-weight: 700; margin-left: 6px; }
#now .ans { color: #ffe14d; font-weight: 600; margin-left: 6px; }
#nowBtns { flex: none; display: flex; gap: 6px; }
#nowBtns button { font: inherit; font-size: 12px; padding: 7px 12px; border-radius: 6px; border: 0; background: #33363d; color: #d8dade; cursor: pointer; white-space: nowrap; }
#nowBtns button.go { background: #2f7d3a; color: #fff; }
.rotate { display: none; padding: 4px 10px; color: #c8b860; font-size: 12px; }

/* ---------------------------------------------------------------- 本体の下 */
#under { max-width: 1180px; width: 100%; margin: 0 auto; font-size: 13px; color: #b4b8c0; display: flex; flex-direction: column; gap: 4px; }
#modeHelp { color: #e6e8eb; background: #22242a; border-left: 3px solid #6fe07a; padding: 6px 10px; border-radius: 4px; }
#knobHelp { padding: 0 10px; color: #9aa0aa; }
.tip { padding: 0 10px; font-size: 12px; color: #80858f; }
.tip b { color: #c9ccd2; }

/* ---------------------------------------------------------------- 右の欄 */
#side { flex: 0 0 430px; max-width: 38%; display: flex; flex-direction: column; background: #1c1d21; border-left: 1px solid #2a2c31; min-height: 0; }
#tabs { display: flex; border-bottom: 1px solid #2a2c31; }
#tabs button { flex: 1; background: none; border: 0; color: #9aa0aa; padding: 10px 4px; font: inherit; font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent; }
#tabs button.on { color: #fff; border-bottom-color: #6fe07a; }
.tab { display: none; flex: 1; overflow: auto; padding: 14px 16px 30px; }
.tab.on { display: block; }
.tab h3 { font-size: 15px; margin: 14px 0 6px; color: #fff; }
.tab h3:first-child { margin-top: 0; }
.tab p { margin: 6px 0; }
.small { font-size: 12px; color: #8b8f98; }
.tab button.act { background: #2f7d3a; color: #fff; border: 0; border-radius: 5px; padding: 7px 14px; font: inherit; cursor: pointer; margin: 4px 6px 4px 0; }
.tab button.act.sec { background: #33363d; color: #d8dade; }
.tab button.act:hover { filter: brightness(1.15); }
.lessonList { list-style: none; margin: 0; padding: 0; }
.lessonList li { padding: 9px 12px; margin-bottom: 6px; background: #25272d; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.lessonList li:hover { background: #2e3138; }
.lessonList li .done { color: #6fe07a; font-size: 12px; white-space: nowrap; }
ol.steps { margin: 10px 0; padding: 0; list-style: none; counter-reset: st; }
ol.steps li { counter-increment: st; position: relative; padding: 8px 10px 8px 38px; margin-bottom: 5px; border-radius: 6px; background: #222429; color: #7f848e; font-size: 13px; }
ol.steps li::before { content: counter(st); position: absolute; left: 10px; top: 8px; width: 20px; height: 20px; border-radius: 50%; background: #33363d; color: #aaa; font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
ol.steps li.cur { background: #2a3a2d; color: #f1f3f5; outline: 1px solid #4a9a56; }
ol.steps li.cur::before { background: #6fe07a; color: #10210f; }
ol.steps li.ok { color: #8fa593; }
ol.steps li.ok::before { content: "✓"; background: #2f7d3a; color: #fff; }
ol.steps li .note { display: block; margin-top: 4px; font-size: 12px; color: #c8b860; }
ol.steps li:not(.cur) .note { display: none; }
.finish { background: #2f7d3a; color: #fff; padding: 10px 12px; border-radius: 6px; margin: 8px 0; font-weight: 600; }
.card { background: #25272d; border-radius: 8px; padding: 14px; margin: 10px 0; }
.card .q { font-size: 17px; color: #fff; font-weight: 600; }
.card .a { margin-top: 8px; color: #ffe14d; font-weight: 600; min-height: 1.6em; }
.card .res { margin-top: 6px; color: #6fe07a; font-weight: 700; min-height: 1.6em; }
table.cheat { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 8px; }
table.cheat td { padding: 4px 6px; border-bottom: 1px solid #2a2c31; vertical-align: top; }
table.cheat td:first-child { color: #ffe14d; white-space: nowrap; font-weight: 600; width: 46%; white-space: normal; }
table.keys { border-collapse: collapse; font-size: 12.5px; }
table.keys td { padding: 3px 8px; border-bottom: 1px solid #2a2c31; }
table.keys td:nth-child(odd) { color: #ffe14d; font-weight: 600; white-space: nowrap; }
.tab ul { padding-left: 18px; margin: 6px 0; }
.tab li { margin-bottom: 4px; }

/* ---------------------------------------------------------------- 電源 */
#power { position: fixed; inset: 0; background: #0c0d0fee; display: flex; align-items: center; justify-content: center; z-index: 10; }
#power .box { text-align: center; }
#power h2 { font-size: 40px; margin: 0; letter-spacing: 0.06em; }
#powerBtn { margin-top: 18px; font: inherit; font-size: 18px; padding: 12px 34px; border-radius: 8px; border: 0; background: #2f7d3a; color: #fff; cursor: pointer; }
#powerBtn:disabled { background: #33363d; color: #888; cursor: default; }
#error { position: fixed; left: 0; right: 0; bottom: 0; background: #7a1f1f; color: #fff; padding: 8px 14px; font: 12px/1.4 Consolas, monospace; white-space: pre-wrap; z-index: 20; max-height: 30vh; overflow: auto; }

@media (max-width: 1250px) {
  main { flex-direction: column; overflow: auto; }
  #left { overflow: visible; flex: none; }
  #side { flex: none; max-width: none; border-left: 0; border-top: 1px solid #2a2c31; }
  .tab { overflow: visible; }
}
/* 幅のせまい画面 (スマホの縦) */
@media (max-width: 700px) {
  header { flex-wrap: wrap; gap: 4px 12px; padding: 6px 10px; }
  h1 small { display: none; }
  #left { padding: 8px 8px 10px; }
  #now { font-size: 12px; }
}
@media (max-width: 700px) and (orientation: portrait) { .rotate { display: block; } }
/* 高さの低い画面 (スマホの横): 本体と帯だけで 1 画面にし、見出しはいちばん下へ。ページ全体をスクロールする */
@media (max-height: 560px) {
  html, body { height: auto; }
  body { min-height: 100%; }
  header { order: 2; border-bottom: 0; border-top: 1px solid #2a2c31; }
  main { flex: none; flex-direction: column; overflow: visible; }
  #left { flex: none; overflow: visible; padding: 6px 10px 8px; gap: 4px; }
  #side { flex: none; max-width: none; border-left: 0; border-top: 1px solid #2a2c31; }
  .tab { overflow: visible; }
  #bar { height: 40px; }
  #now { font-size: 12px; }
}
