/* コーディング道場 共通の見た目。色は先頭の変数だけで決める。 */
@font-face { font-family: "Zen Maru Gothic"; font-weight: 500; font-display: swap; src: url("フォント/ZenMaruGothic-Medium.woff2") format("woff2"); }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 900; font-display: swap; src: url("フォント/ZenMaruGothic-Black.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 300 700; font-display: swap; src: url("フォント/Fredoka.woff2") format("woff2"); }

:root {
  --bg: #1A1340; --bg-2: #2A1B5C; --panel: #FFF4DC; --ink: #2A1848; --ink-dim: #5A4A78; --line: #2A1848;
  --player: #FF5B7A; --cpu: #2EE0D0; --accent-y: #FFE14A; --accent-m: #FF4FB8; --accent-l: #7CFF6B; --accent-o: #FF8A3D;
  --ok: #1F9D55; --ng: #C62828;
  --block-1: #FF6B8A; --block-2: #FFD166; --block-3: #4CD964; --block-4: #4FC3F7; --block-5: #B388FF; --block-6: #FFA05C;
  --white: #FFFDF7;
  --story-wood: #8B5A2B; --story-paper: #FFF4DC; --story-ink: #2A1848; --story-hp: #FF5B7A; --story-foe: #2EE0D0;
  --wood: #C77B3B;
  --jp: "Zen Maru Gothic", system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --num: "Fredoka", "Zen Maru Gothic", system-ui, sans-serif;
  --barh: 0px; --cheek: #FFB3C1; --well: #130D31; --cell-line: #41307C; --slot-line: #7A69B8; --veil: rgba(19, 13, 49, .62);
  /* 舞台 1280×720 の 1px。画面に合わせて全体が同じ比率で伸び縮みする */
  --u: min(100vw / 1280, (100vh - var(--barh)) / 720, 1px);
  --u: min(100vw / 1280, (100dvh - var(--barh)) / 720, 1px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  isolation: isolate; display: flow-root;
  background-color: var(--bg); color: var(--ink);
  background-image: radial-gradient(circle at 24px 24px, var(--bg-2) 0 5px, transparent 6px);
  background-size: 48px 48px;
  font-family: var(--jp); font-weight: 500; line-height: 1.6; overflow: hidden;
  /* 日本語は文節で折り、行頭に句読点を出さない。英数字のかたまりは単語の途中で折らない */
  line-break: strict; text-wrap: pretty; word-break: auto-phrase; overflow-wrap: break-word;
}
button { font: inherit; color: inherit; cursor: pointer; }

#stage { position: relative; width: calc(var(--u) * 1280); height: calc(var(--u) * 720); margin: 0 auto; overflow: hidden; display: flex; flex-direction: column; }
@media (min-height: 800px) and (min-width: 800px) { #stage { margin-top: calc((100dvh - var(--barh) - var(--u) * 720) / 2); } }
#app { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

:focus-visible { outline: 4px solid var(--accent-y); outline-offset: 3px; }

/* ---- 共通の部品 ---- */
.ui-btn {
  --c: var(--block-4); --lip: 0px; --shade: color-mix(in srgb, var(--c) 60%, var(--ink));
  display: block; min-height: 64px; padding: 6px 18px; border: 4px solid var(--line); border-radius: 24px;
  background: radial-gradient(120% 60% at 50% 0, rgba(255, 255, 255, .75), rgba(255, 255, 255, 0) 60%), linear-gradient(var(--c) 45%, color-mix(in srgb, var(--c) 78%, var(--ink)));
  box-shadow: inset 0 -3px 8px var(--shade);
  color: var(--ink); font-weight: 900; font-size: max(18px, calc(var(--u) * 20)); line-height: 1.35; text-align: center;
  text-wrap: pretty; line-break: strict; word-break: auto-phrase;
  transition: transform 120ms, filter 120ms;
}
.ui-btn:active:not(:disabled) { transform: translateY(2px) scale(.96); filter: brightness(.92); transition-duration: 80ms; }
.ui-btn:disabled { cursor: default; transform: none; }
.ui-panel { background: var(--panel); border: 4px solid var(--line); border-radius: 22px; }
.hud { flex: none; height: max(40px, calc(var(--u) * 44)); display: flex; align-items: center; gap: 14px; padding: 0 14px; color: var(--white); font-size: 15px; }
.hud b { font-weight: 900; }
.hud .mode { margin-right: auto; padding: 1px 12px; border-radius: 99px; background: var(--bg-2); font-weight: 900; }
.hud button { width: 44px; height: 40px; padding: 0; border: 0; border-radius: 12px; background: var(--bg-2); color: var(--white); display: grid; place-items: center; }
.hud svg { width: 22px; height: 22px; }

/* ブロック:角丸の正方形、上端のハイライト、ごく小さい内側の影 */
.block { border-radius: 24%; background-color: var(--b); box-shadow: inset 0 -3px 0 rgba(42,24,72,.28), inset 0 0 0 2px rgba(42,24,72,.25); position: relative; }
.block::before { content: ""; position: absolute; left: 14%; right: 14%; top: 11%; height: 20%; border-radius: 99px; background: rgba(255,255,255,.72); }
.b1 { --b: var(--block-1); } .b2 { --b: var(--block-2); } .b3 { --b: var(--block-3); } .b4 { --b: var(--block-4); } .b5 { --b: var(--block-5); } .b6 { --b: var(--block-6); }
.pattern .bit.b1, .pattern .next .block.b1, .pattern .put .pair .block.b1, .pattern .fore .in.b1, .pattern .fly.b1, .pattern .swatch.b1 { background-image: radial-gradient(var(--ink) 18%, transparent 20%); background-size: 9px 9px; }
.pattern .bit.b2, .pattern .next .block.b2, .pattern .put .pair .block.b2, .pattern .fore .in.b2, .pattern .fly.b2, .pattern .swatch.b2 { background-image: repeating-linear-gradient(45deg, transparent 0 5px, var(--ink) 5px 7px); }
.pattern .bit.b3, .pattern .next .block.b3, .pattern .put .pair .block.b3, .pattern .fore .in.b3, .pattern .fly.b3, .pattern .swatch.b3 { background-image: linear-gradient(var(--ink), var(--ink)), linear-gradient(var(--ink), var(--ink)); background-size: 60% 4px, 4px 60%; background-position: center; background-repeat: no-repeat; }
.pattern .bit.b4, .pattern .next .block.b4, .pattern .put .pair .block.b4, .pattern .fore .in.b4, .pattern .fly.b4, .pattern .swatch.b4 { background-image: repeating-linear-gradient(0deg, transparent 0 5px, var(--ink) 5px 7px); }
.pattern .bit.b5, .pattern .next .block.b5, .pattern .put .pair .block.b5, .pattern .fore .in.b5, .pattern .fly.b5, .pattern .swatch.b5 { background-image: radial-gradient(circle, transparent 24%, var(--ink) 26% 36%, transparent 38%); }
.pattern .bit.b6, .pattern .next .block.b6, .pattern .put .pair .block.b6, .pattern .fore .in.b6, .pattern .fly.b6, .pattern .swatch.b6 { background-image: repeating-linear-gradient(90deg, transparent 0 5px, var(--ink) 5px 7px); }
.pattern-sample { display: flex; gap: 8px; margin: -2px 0 6px; }
.pattern-sample .swatch { width: 28px; height: 28px; display: block; }

/* ---- ホーム ---- */
.home { --g: calc(var(--u) * 16); padding: 0 calc(var(--u) * 36) calc(var(--u) * 20); }
#swim { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
#swim i { position: absolute; width: calc(var(--s) * 1px); height: calc(var(--s) * 1px); opacity: .2; animation: swim var(--t) linear infinite; }
@keyframes swim { from { transform: translate(-10vw, 0) rotate(0); } 50% { transform: translate(50vw, -24px) rotate(14deg); } to { transform: translate(110vw, 0) rotate(0); } }
.logo { flex: none; display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 22); height: calc(var(--u) * 128); }
.logo-row { display: flex; gap: calc(var(--u) * 5); }
.logo-row .block { width: calc(var(--u) * 78); height: calc(var(--u) * 78); display: grid; place-items: center; font-weight: 900; font-size: calc(var(--u) * 46); line-height: 1; color: var(--ink); animation: logo-drop .5s cubic-bezier(.5,0,.9,.6) backwards; animation-delay: calc(var(--i) * 70ms); }
.logo-row .block span { position: relative; top: .06em; }
@keyframes logo-drop { 0% { transform: translateY(-260%); } 78% { transform: translateY(0); } 88% { transform: translateY(6%) scale(1.05, .9); } 100% { transform: none; } }
.logo-big { font-weight: 900; font-size: calc(var(--u) * 92); line-height: 1; color: var(--accent-y); -webkit-text-stroke: calc(var(--u) * 14) var(--line); paint-order: stroke fill; letter-spacing: .02em; }
.rank { padding: 2px 14px; border: 3px solid var(--line); border-radius: 10px; background: var(--white); font-weight: 900; font-size: max(14px, calc(var(--u) * 17)); }
.modes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); gap: var(--g); }
.mode-btn { display: flex; align-items: center; justify-content: space-between; text-align: left; border-radius: calc(var(--u) * 28); padding: calc(var(--u) * 10) calc(var(--u) * 34) calc(var(--u) * 10); overflow: hidden; }
.mode-btn strong { display: block; white-space: nowrap; font-size: calc(var(--u) * 46); line-height: 1.15; }
.mode-btn small { font-size: max(16px, calc(var(--u) * 22)); font-weight: 900; }
.mode-btn svg { height: 92%; max-width: 44%; flex: 0 1 auto; }
.foot { flex: none; display: flex; align-items: center; gap: calc(var(--u) * 22); padding-top: calc(var(--u) * 16); min-height: calc(var(--u) * 88); }
.badge { display: flex; align-items: center; gap: 12px; padding: 6px 18px; border: 4px solid var(--line); border-radius: 14px; background: var(--panel); font-weight: 900; font-size: max(16px, calc(var(--u) * 19)); }
.badge.due { background: var(--accent-o); }
.badge .num { font-family: var(--num); font-weight: 700; font-size: 1.4em; line-height: 1; }
.seals { display: flex; gap: 4px; }
.seals i { width: 19px; height: 19px; border-radius: 50%; border: 2px dashed var(--ink-dim); }
.seals i.got { border: 0; background: var(--ng); box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 5px var(--ng); }
.foot .ui-btn { margin-left: auto; --c: var(--white); }
#flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 30; }

/* ---- 対戦 ---- */
.battle { --cell: calc(var(--u) * 29.6); --gap: calc(var(--u) * 3); --cell-w: var(--cell); }
.top { flex: none; height: calc(var(--u) * 60); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: calc(var(--u) * 26); color: var(--white); padding: 0 calc(var(--u) * 24); }
.top .who { flex: 1; font-weight: 900; font-size: max(17px, calc(var(--u) * 26)); display: flex; align-items: center; gap: 10px; }
.top .who.r { justify-content: flex-end; }
.top .who .face { display: none; }
.center { display: grid; grid-template-columns: calc(var(--u) * 170) auto calc(var(--u) * 170); gap: calc(var(--u) * 22); align-items: center; }
.center .qno { text-align: right; }
.vs { text-align: center; line-height: 1; }
.vs b { font-family: var(--num); font-weight: 700; font-size: calc(var(--u) * 46); color: var(--accent-y); -webkit-text-stroke: calc(var(--u) * 8) var(--line); paint-order: stroke fill; }
.qno { font-weight: 900; font-size: max(15px, calc(var(--u) * 20)); white-space: nowrap; }
.qno .num, .combo .num { font-family: var(--num); font-weight: 700; font-size: 1.35em; }
.combo { font-weight: 900; font-size: max(14px, calc(var(--u) * 19)); color: var(--accent-y); white-space: nowrap; visibility: hidden; }
.center.hot .combo { visibility: visible; }
.mid { flex: none; height: calc(var(--u) * 396); display: flex; justify-content: center; gap: calc(var(--u) * 24); }
.corner { width: calc(var(--u) * 216); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: calc(var(--u) * 12); padding-bottom: calc(var(--u) * 8); }
.corner .face { width: calc(var(--u) * 206); height: calc(var(--u) * 206); }
.face { position: relative; z-index: 26; border-radius: 50%; background: var(--panel); border: calc(var(--u) * 6) solid var(--player); padding: calc(var(--u) * 17); }
.face.f-foe { border-color: var(--cpu); }
.face svg { width: 100%; height: 100%; display: block; overflow: visible; }
.say { min-height: 1.7em; color: var(--white); font-weight: 900; font-size: max(16px, calc(var(--u) * 20)); }
.gauge.m { display: none; } .gauge.blank { visibility: hidden; }
.gauge { width: 100%; color: var(--white); font-weight: 900; font-size: max(14px, calc(var(--u) * 17)); }
.gauge div { height: calc(var(--u) * 20); border: 3px solid var(--white); border-radius: 99px; overflow: hidden; background: var(--bg-2); }
.gauge i { display: block; height: 100%; width: 100%; background: var(--accent-o); transform: scaleX(0); transform-origin: left; }
.field { display: flex; flex-direction: column; align-items: center; }
.fore { flex: none; height: calc(var(--u) * 36); display: flex; align-items: center; justify-content: center; gap: 3px; max-width: 100%; }
.fore i { width: calc(var(--u) * 18); height: calc(var(--u) * 18); flex: none; }
.fore b { padding: 0 8px; border-radius: 8px; background: var(--accent-o); color: var(--ink); font-weight: 900; font-size: max(14px, calc(var(--u) * 17)); line-height: 1.5; white-space: nowrap; }
.fore.warn { animation: warn .6s ease-in-out infinite; }
@keyframes warn { 50% { opacity: .55; } }
.board { position: relative; padding: calc(var(--u) * 5); border: calc(var(--u) * 6) solid var(--player); border-radius: calc(var(--u) * 16); background: var(--well); }
.field.cpu .board { border-color: var(--cpu); }
.grid { display: grid; grid-template-columns: repeat(6, var(--cell-w)); grid-auto-rows: var(--cell); gap: var(--gap); overflow: hidden; border-radius: calc(var(--u) * 8); }
.cell { background: var(--bg-2); border-radius: 24%; box-shadow: inset 0 0 0 1px var(--cell-line); }
.grid { position: relative; }
.blocks { position: absolute; inset: 0; }
.blocks .bit { position: absolute; left: 0; top: 0; width: var(--cell-w); height: var(--cell); transform: translate(calc(var(--x) * (var(--cell-w) + var(--gap))), calc(var(--y) * (var(--cell) + var(--gap)))); transition: transform .24s cubic-bezier(.5, 0, .9, .6); }
.calm #stage .blocks .bit { transition: none !important; }
/* 飛んできたブロックの封。色はそのまま見せ、まん中に留め具を付ける */
.bit.locked { box-shadow: inset 0 0 0 2px var(--ink); }
.bit.locked::before { left: 34%; right: 34%; top: 34%; height: 32%; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--white); opacity: 1 !important; }
.bit.ghost { opacity: .8; outline: 2px dashed var(--white); outline-offset: -2px; }
.bit.will { outline: 3px solid var(--white); outline-offset: -1px; z-index: 2; }
.bit.popping { z-index: 3; outline: 3px solid var(--white); }
.board.picking { cursor: pointer; }
.board::after { content: ""; position: absolute; inset: 0 0 auto; height: 34%; border-radius: calc(var(--u) * 9) calc(var(--u) * 9) 0 0; background: linear-gradient(var(--accent-o), transparent); opacity: 0; pointer-events: none; }
.danger .board::after { animation: danger 1.2s ease-in-out infinite; }
@keyframes danger { 0%, 100% { opacity: .1; } 50% { opacity: .6; } }
.white { position: absolute; inset: 0; background: var(--white); opacity: 0; pointer-events: none; border-radius: calc(var(--u) * 9); }
.meter { flex: none; width: 100%; height: calc(var(--u) * 11); margin-top: calc(var(--u) * 5); display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.meter i { border-radius: 3px; background: var(--bg-2); }
.meter i.on { background: var(--player); } .cpu .meter i.on { background: var(--cpu); }
.lane { width: calc(var(--u) * 104); margin: calc(var(--u) * 36) 0 calc(var(--u) * 22); border-radius: calc(var(--u) * 18); background: repeating-linear-gradient(0deg, var(--bg-2) 0 14px, transparent 14px 26px); opacity: .9; }
.ask { flex: 1; min-height: 0; margin: calc(var(--u) * 6) calc(var(--u) * 110) calc(var(--u) * 12); padding: calc(var(--u) * 8) calc(var(--u) * 24) calc(var(--u) * 14); display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.ask .cat { align-self: flex-start; padding: 0 12px; border-radius: 8px; background: var(--ink); color: var(--white); font-weight: 900; font-size: max(14px, calc(var(--u) * 15)); }
.ask .head { display: flex; align-items: baseline; gap: 14px; }
.ask .q { font-size: max(18px, calc(var(--u) * 22)); line-height: 1.45; }
.ask .head .cat { flex: none; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 8) calc(var(--u) * 14); }
.choices .ui-btn { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 65px; padding: 8px 16px; }
.choices .ui-btn span { flex: 1; min-width: 0; text-align: left; }
.choices .ui-btn i { flex: none; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; font: 700 .9em/1 var(--num); }
.choices .ui-btn.right { --c: var(--accent-l); outline: 4px solid var(--ok); }
.choices .ui-btn.right i { background: var(--ok); font-size: .9em; }
.choices .ui-btn.miss { --c: var(--white); outline: 4px solid var(--ng); color: var(--ng); }
.choices .ui-btn.miss i { background: var(--ng); }

/* 演出 */
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
#fx canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stamp {
  --k: 1; position: absolute; left: 50%; padding: 2px 30px; border: 5px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ok); font-weight: 900; font-size: calc(max(30px, var(--u) * 56) * var(--k)); line-height: 1.35; white-space: nowrap; translate: -50% -50%; }
.stamp.ng { color: var(--ng); font-size: max(26px, calc(var(--u) * 44)); }
.stamp.combo-s { background: var(--accent-m); color: var(--white); -webkit-text-stroke: 6px var(--line); paint-order: stroke fill; }
.stamp.fast { background: var(--accent-y); color: var(--ink); }
.count { position: absolute; left: 50%; top: 44%; translate: -50% -50%; font: 700 calc(var(--u) * 260)/1 var(--num); color: var(--accent-y); -webkit-text-stroke: calc(var(--u) * 26) var(--line); paint-order: stroke fill; white-space: nowrap; }
.count.go { font-family: var(--jp); font-weight: 900; font-size: calc(var(--u) * 170); color: var(--accent-l); }
.fly { position: absolute; left: 0; top: 0; width: calc(var(--u) * 46); height: calc(var(--u) * 46); }

.over { position: absolute; inset: calc(var(--u) * -44) 0 0; z-index: 25; display: none; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 18); background: var(--veil); padding: 16px; }
.banner { font: 700 calc(var(--u) * 170)/1 var(--num); color: var(--accent-y); -webkit-text-stroke: calc(var(--u) * 22) var(--line); paint-order: stroke fill; }
.banner.lose { font-family: var(--jp); font-weight: 900; font-size: calc(var(--u) * 92); color: var(--white); }
.score { display: flex; gap: 8px 34px; flex-wrap: wrap; justify-content: center; padding: 10px 34px; font-weight: 900; font-size: max(17px, calc(var(--u) * 22)); }
.score b { font: 700 1.7em/1 var(--num); margin-left: 8px; }
.acts { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.acts .main { --c: var(--accent-y); font-size: max(20px, calc(var(--u) * 28)); padding: 10px 34px calc(10px); }
.acts .sub { --c: var(--white); }

/* ---- 土台(本体で足したもの) ---- */
#date-banner { height: 34px; line-height: 34px; background: var(--accent-o); color: var(--ink); text-align: center; font-weight: 900; font-size: 15px; }
#swim .block::before { opacity: .5; }
body[data-screen="training"] { background-color: var(--well); }
.hud { overflow: hidden; }
.hud b { margin-right: 0; } .hud .load-line { flex: 1 1 auto; min-width: 0; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 1.2; color: var(--white); }
.hud button.load-line { width: auto; height: auto; min-height: 40px; padding: 2px 10px; background: var(--ng); text-align: left; }
.hidden-title { position: absolute; clip-path: inset(50%); margin: 0; }
h1, h2, h3, p, ul { margin: 0; }
h1, h2, h3 { font-weight: 900; line-height: 1.4; }
.home { --g: calc(var(--u) * 16); padding: 0 calc(var(--u) * 36) calc(var(--u) * 20); }
button.badge { min-height: 48px; color: var(--ink); } button.badge:disabled { background: var(--panel); cursor: default; }
button.badge.due:not(:disabled):active { transform: translateY(2px); }
#overlay { position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; padding: 14px; background: var(--veil); }
#notice { position: absolute; left: 50%; bottom: 14px; translate: -50% 0; z-index: 50; max-width: 92%; padding: 8px 18px; border: 4px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ng); font-weight: 900; }
.pause-panel, .popup { width: min(100%, 560px); max-height: 100%; overflow: auto; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 10px; font-size: 18px; }
.pause-panel h2, .popup h2 { font-size: 28px; } .pause-panel h3 { font-size: 18px; margin-top: 8px; }
.pause-panel > *, .popup > * { flex: none; }
.ui-btn.main { --c: var(--accent-y); } .ui-btn.sub { --c: var(--white); } .ui-btn.lime { --c: var(--accent-l); } .ui-btn.pink { --c: var(--accent-m); }
.ui-btn.small { min-height: 58px; font-size: 17px; } .ui-btn.danger { --c: var(--white); color: var(--ng); }
.switch, .set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; width: 100%; padding: 4px 0; border: 0; background: none; font-size: 18px; font-weight: 500; text-align: left; }
.switch i { flex: none; position: relative; width: 92px; height: 44px; border: 4px solid var(--line); border-radius: 99px; background: var(--white); font-style: normal; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink-dim); transition: transform 120ms; }
.switch em { position: absolute; inset: 0 10px 0 0; text-align: right; font: 900 15px/36px var(--jp); }
.switch[aria-checked="true"] i { background: var(--accent-l); } .switch[aria-checked="true"] i::after { transform: translateX(46px); background: var(--ink); } .switch[aria-checked="true"] em { inset: 0 0 0 12px; text-align: left; }
.set-row input[type="number"] { width: 96px; } .set-row input[type="range"] { width: 200px; height: 44px; accent-color: var(--player); }
.ui-input, .set-row input[type="number"] { min-height: 56px; padding: 8px 14px; border: 4px solid var(--line); border-radius: 14px; background: var(--white); color: var(--ink); font: 500 18px/1.5 var(--jp); }
.ui-input { width: 100%; } input.ui-input:not([type=search]) { font-family: var(--code); } textarea.ui-input { resize: vertical; }
:root { --code: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.notice { padding: 8px 14px; border-radius: 12px; background: var(--white); color: var(--ng); font-weight: 900; }
.skip-list { padding: 0; list-style: none; font-size: 15px; } .skip-list li { padding: 6px 0; border-top: 2px solid var(--ink-dim); }
.meta { font-size: 15px; color: var(--ink-dim); }
.acts .ui-btn { flex: 0 1 auto; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.ask .head .q { flex: 1 1 100%; }
.battle .ask .head { flex-wrap: nowrap; align-items: baseline; } .battle .ask .head .q { flex: 1; }
.q { white-space: pre-wrap; }
.code { margin: 0; padding: 10px 14px; overflow: auto; border-radius: 12px; background: var(--white); border: 3px solid var(--line); font: 16px/1.5 var(--code); white-space: pre; }
.code, .code code, .code-text, .ui-btn.line, .ui-btn.line span { word-break: normal; line-break: auto; overflow-wrap: anywhere; }
.code code { font: inherit; }
.choice:disabled { color: var(--ink); } .choice.rest { --c: var(--white); opacity: .75; } .choice.picked { --c: var(--accent-y); }
.ui-btn.right { --c: var(--accent-l); outline: 4px solid var(--ok); } .ui-btn.right > i { background: var(--ok) !important; }
.ui-btn.miss { --c: var(--white); color: var(--ng); outline: 4px solid var(--ng); opacity: 1; } .ui-btn.miss > i { background: var(--ng) !important; }
.lines, .slots { display: flex; flex-direction: column; gap: 6px; }
.ui-btn.line { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 2px 12px; border-radius: 12px; text-align: left; font: 500 16px/1.35 var(--code); }
.ui-btn.line > i { flex: none; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; font: 700 14px/1 var(--num); }
.code-text { white-space: pre-wrap; text-wrap: wrap; }
.slots { padding: 10px; border: 4px dashed var(--ink-dim); border-radius: 16px; } .empty { color: var(--ink-dim); }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .columns .ui-btn { width: 100%; margin-bottom: 8px; font-size: 18px; text-align: left; }
.reply { padding: 6px 12px; border-left: 6px solid var(--ink-dim); background: var(--white); border-radius: 8px; white-space: pre-wrap; } .reply.right { border-color: var(--ok); } .reply.miss { border-color: var(--ng); } .reply-head { font-weight: 900; }

/* 解説 */
.explain-panel { padding: 12px 24px 20px; font-size: 18px; display: flex; flex-direction: column; gap: 6px; scroll-margin-top: 8px; }
.mark { font-weight: 900; font-size: 20px; line-height: 1.45; color: var(--ink); }
.mark b { font-weight: 900; } .mark b.ok { color: var(--ok); } .mark b.ng { color: var(--ng); }
.correct-line { margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--white); border-left: 6px solid var(--ok); white-space: pre-wrap; }
.correct-line b { font-weight: 900; }
.explain { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.more { align-self: flex-start; min-height: 44px; border: 0; background: none; font-weight: 900; text-decoration: underline; }
.term-inline { display: inline-block; min-height: 44px; margin: -10px 4px -10px 0; padding: 6px 2px; border: 0; background: none; font-weight: 900; text-decoration: underline; text-decoration-color: var(--accent-m); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.hint-line { margin: 0; font-weight: 700; font-size: 16px; line-height: 1.45; }
#hint-button { align-self: flex-start; }
.story-scroll h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.35; }
.scroll-kicker { font-weight: 900; }
.scroll-h { margin: 14px 0 4px; font-size: 16px; }
.scroll-miss { margin: 4px 0; }
.lesson-terms { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.mode-btn.glow { outline: 4px solid var(--white); outline-offset: 2px; }
.explain-panel .acts { margin-top: 8px; justify-content: flex-start; } .explain-panel .acts .main { min-width: 240px; }

/* トレーニング */
.room { align-items: center; padding: 0 16px 10px; gap: 8px; }
.room-scroll { flex: 1; min-height: 0; width: min(100%, 840px); overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.room-info { display: flex; justify-content: space-between; color: var(--white); font-weight: 900; font-size: 16px; }
.room .ask, .simple .ask, .terms .ask { flex: none; margin: 0; padding: 16px 24px 22px; justify-content: flex-start; gap: 14px; }
.room .q, .simple .q, .terms .q { font-size: 21px; line-height: 1.6; }
.room .choices { grid-template-columns: 1fr; } .simple .choices, .terms .choices { grid-template-columns: 1fr; }
.sheet { width: min(100%, 840px); margin: auto 0; max-height: 100%; overflow: auto; padding: 16px 24px 24px; display: flex; flex-direction: column; gap: 14px; } .sheet > * { flex: none; } .sheet .acts { justify-content: flex-start; }
.filter h3 { font-size: 17px; margin-bottom: 6px; } .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 48px; padding: 4px 16px; border: 4px solid var(--line); border-radius: 99px; background: var(--white); font-weight: 900; font-size: 16px; }
.chip::before { content: "＋ "; } .chip[aria-pressed="true"] { background: var(--accent-l); } .chip[aria-pressed="true"]::before { content: "✓ "; }
.dots { flex: none; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; } .dots i { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--slot-line); display: grid; place-items: center; font: 900 14px/1 var(--jp); color: var(--ink); }
.dots i.ok { background: var(--accent-l); border-color: var(--accent-l); } .dots i.ng { background: var(--player); border-color: var(--player); } .dots i.now { outline: 3px solid var(--accent-y); outline-offset: 2px; }

/* 結果 */
.result-box { margin: auto; display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 16); max-width: 100%; max-height: 100%; overflow: auto; padding: 10px; }
.result-box > * { flex: none; }
.banner { text-align: center; } .banner.quiet { font-family: var(--jp); font-weight: 900; font-size: calc(var(--u) * 84); color: var(--white); } .banner.small-banner { font-family: var(--jp); font-weight: 900; font-size: calc(var(--u) * 78); -webkit-text-stroke-width: calc(var(--u) * 16); }
.notes { padding: 8px 22px 10px; max-width: 760px; font-size: 17px; line-height: 1.45; } .notes ul { padding: 0; list-style: none; } .notes li { padding: 4px 0; border-bottom: 2px dashed var(--ink-dim); } .notes li b { display: block; font-weight: 900; }
.stamp.rankup { background: var(--accent-l); color: var(--ink); } .stamp.note { font-size: max(20px, calc(var(--u) * 26)); color: var(--ink); }

/* 相手選び・サイト選び */
.select { align-items: center; justify-content: center; gap: calc(var(--u) * 22); padding: 8px 20px 16px; overflow: auto; } .select > * { flex: none; }
.select h1 { color: var(--white); font-size: max(26px, calc(var(--u) * 44)); text-align: center; }
.foes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; width: min(100%, 1080px); }
.foe-btn { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 16px calc(14px); border-radius: 26px; text-align: center; overflow: hidden; }
.foe-btn[data-foe="minarai"] { --c: var(--block-2); } .foe-btn[data-foe="shihandai"] { --c: var(--cpu); } .foe-btn[data-foe="shihan"] { --c: var(--block-5); } .site-btn { --c: var(--accent-y); }
.foe-btn.chosen { outline: 5px solid var(--white); outline-offset: 3px; } .foe-btn .face { width: calc(var(--u) * 168); height: calc(var(--u) * 168); border-color: var(--line); } .foe-btn > svg { width: 160px; }
.foe-text { display: flex; flex-direction: column; gap: 2px; font-size: 18px; } .foe-text strong { font-size: 32px; line-height: 1.2; } .wins { font-weight: 900; }
.more-filters { width: min(100%, 1080px); padding: 4px 20px; } .more-filters summary { min-height: 48px; display: flex; align-items: center; font-weight: 900; font-size: 18px; cursor: pointer; } .more-filters summary::before { content: "▼ "; white-space: pre; } .more-filters[open] { padding-bottom: 16px; } .more-filters[open] summary::before { content: "▲ "; } .more-filters .filter { margin-top: 8px; }

.how { width: min(100%, 1080px); padding: 10px 20px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; font-size: 17px; } .how p { flex: 1 1 360px; }
/* シンプル */
.simple { flex-direction: row; gap: 18px; padding: 4px 20px 16px; } .site-side { flex: 0 0 52%; min-width: 0; display: flex; flex-direction: column; gap: 8px; } .quiz-side { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; } .quiz-side > * { flex: none; } .quiz-side .result-box { margin: auto 0; }
.browser { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 5px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--white); outline: 4px solid var(--accent-y); }
.browser-bar { flex: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 2px 12px; background: var(--panel); border-bottom: 4px solid var(--line); }
.lights { display: flex; gap: 6px; } .lights i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--block-1); } .lights i:nth-child(2) { background: var(--block-2); } .lights i:nth-child(3) { background: var(--block-3); }
.address { flex: 1; min-width: 0; padding: 3px 14px; border: 3px solid var(--line); border-radius: 99px; background: var(--white); font: 15px/1.5 var(--code); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: none; font-weight: 900; } .tab[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.browser iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--white); }
.code-view { flex: 1; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; } .code-view .code { margin-top: 5px; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; } .fresh-line { border-color: var(--accent-m); }
.steps { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--white); font: 700 20px/1 var(--num); } .steps i { width: 18px; height: 18px; border-radius: 30%; background: var(--bg-2); border: 2px solid var(--slot-line); } .steps i.on { background: var(--accent-y); border-color: var(--accent-y); }
.acts.low { justify-content: flex-start; gap: 10px; }

/* 用語 */
.terms { flex-direction: row; gap: 16px; padding: 4px 20px 16px; } .term-side { flex: 0 0 36%; min-width: 0; display: flex; flex-direction: column; } .term-index { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; } .drawer-button { display: none; }
.term-main { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; } .term-main > * { flex: none; } .term-main .result-box { margin: auto; }
.learned { font-weight: 900; font-size: 18px; } .tabs .chip { min-height: 44px; padding: 2px 10px; font-size: 14px; border-width: 3px; } .tabs .chip::before { content: none; } .tabs .chip[aria-pressed="true"] { background: var(--accent-m); } .tabs { gap: 5px; }
#term-list { flex: 1; min-height: 0; overflow: auto; } #term-list h3 { font-size: 15px; margin-top: 8px; }
.term-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px; padding: 2px 12px; border: 0; border-bottom: 2px solid var(--ink-dim); background: none; text-align: left; font-weight: 900; font-size: 17px; } .term-row em { flex: none; font: 500 14px/1 var(--jp); } .term-row[aria-pressed="true"] { background: var(--accent-y); border-radius: 10px; }
.entry { padding: 16px 24px 22px; font-size: 18px; display: flex; flex-direction: column; gap: 8px; } .entry h2 { font-size: 34px; } .term-short { font-weight: 900; font-size: 20px; } .entry .ui-btn { align-self: flex-start; }

/* 置く場所を選ぶ枠 */
.next { display: flex; align-items: center; gap: 8px; color: var(--white); font-weight: 900; font-size: max(14px, calc(var(--u) * 17)); min-height: 30px; } .next .block { width: 24px; height: 24px; }
.put { display: grid; grid-template-columns: auto 1fr auto; gap: 10px 18px; align-items: center; flex: 1; }
.put .pair { display: flex; gap: 4px; } .put .pair.up { flex-direction: column; } .put .pair .block { width: 42px; height: 42px; }
.put .hint { font-weight: 900; font-size: 22px; line-height: 1.4; } .put .hint small { display: block; font-size: 16px; font-weight: 500; }
.put .pads { display: grid; grid-template-columns: repeat(3, 84px) 160px; gap: 8px; } .put .pads .ui-btn { padding-left: 4px; padding-right: 4px; font-size: 20px; text-align: center; }
.put .time { grid-column: 1 / -1; height: 14px; border: 3px solid var(--line); border-radius: 99px; overflow: hidden; } .put .time i { display: block; height: 100%; background: var(--accent-o); transform-origin: left; }
.cat.tint { color: var(--ink); border: 3px solid var(--line); }
/* 対戦の下段 */
.battle .ask { overflow: auto; } .battle .ask.has-code { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; justify-content: stretch; } .battle .ask.has-code:has(.lines) { grid-template-columns: 2fr 3fr; } .over .notes { max-width: max(300px, calc(var(--u) * 620)); } .ask-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; } .battle .has-code .choices { grid-template-columns: 1fr; align-self: stretch; align-content: start; gap: 5px; } .battle .has-code .choices .ui-btn { min-height: 56px; font-size: 18px; }
.battle .has-code .head { flex-wrap: wrap; } .battle .has-code .head .q { flex: 1 1 100%; } .battle .lines { gap: 4px; } .battle .ui-btn.line { min-height: 44px; font-size: 16px; }
.battle.tight { --cell: calc(var(--u) * 21); } .battle.tight .mid { height: calc(var(--u) * 300); } .battle.tight .ask .q { font-size: max(18px, calc(var(--u) * 19)); }
.battle.tight .corner .face { width: calc(var(--u) * 150); height: calc(var(--u) * 150); }
@media (min-width: 800px) and (pointer: fine) { .battle.tighter .ui-btn.line { min-height: 31px; font-size: 15px; padding-top: 0; } }
.battle.tighter .has-code .choices .ui-btn { min-height: 48px; font-size: 17px; }
.battle.tighter .ui-btn.line { border-width: 3px; line-height: 1.2; }
.ready { margin: auto; font-weight: 900; font-size: 26px; } .battle .ask #next-button { flex: none; }
.battle .top { padding-top: 0; }

/* ---- 縦長・スマホ ---- */
@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  :root { --u: 1px;  }
  #stage { width: 100%; height: calc(100dvh - var(--barh)); max-width: 620px; margin-top: 0; }
  .home { --g: 12px; padding: 0 14px 12px; }
  .logo { height: auto; padding: 6px 0 14px; flex-wrap: wrap; gap: 8px 14px; }
  .logo-row .block { width: min(13.5vw, 70px); height: min(13.5vw, 70px); font-size: min(8vw, 40px); }
  .logo-big { font-size: 58px; -webkit-text-stroke-width: 10px; }
  .mode-btn { flex-direction: column-reverse; justify-content: center; align-items: center; text-align: center; padding: 8px 8px calc(8px); border-radius: 22px; gap: 2px; }
  .mode-btn strong { font-size: min(6.6vw, 27px); } .mode-btn small { display: block; line-height: 1.3; font-size: 15px; }
  .mode-btn svg { height: auto; width: min(64%, 84px); max-width: none; max-height: 64px; min-height: 0; flex: 0 1 auto; }
  .foot { flex-wrap: nowrap; align-items: stretch; gap: 10px; padding-top: 12px; }
  .badge { flex: 1 1 0; justify-content: center; padding: 3px 10px; font-size: 16px; min-width: 0; text-align: center; }
  .seals i { width: 16px; height: 16px; }
  .foot .ui-btn { flex: 1 1 0; width: auto; min-width: 0; margin: 0; }
  .battle { --h: calc(100dvh - var(--barh)); --fit: calc((100vw - 122px) / 13.5); --cell: min(calc((var(--h) * .45 - 136px) / 10), var(--fit)); --gap: 2px; }
  .top { height: 52px; padding: 0 8px; gap: 8px; }
  .top .who { gap: 4px; font-size: 16px; }
  .top .who .face { display: block; width: 52px; height: 52px; z-index: 5; flex: none; }
  .vs b { font-size: 26px; -webkit-text-stroke-width: 6px; }
  .center { display: flex; flex-direction: column; gap: 0; } .center .qno { font-size: 14px; line-height: 1.2; }
  .combo { display: none; font-size: 16px; } .center.hot .combo { display: block; }
  .face { border-width: 3px; padding: 4px; }
  .center.hot .vs { display: none; }
  .corner { display: none; }
  .mid { height: auto; gap: 6px; padding: 0 6px; align-items: flex-start; }
  .field { flex: 0 0 auto; }
  .fore { height: 28px; gap: 2px; } .fore i { width: 11px; height: 11px; } .fore b { font-size: 13px; padding: 0 5px; }
  .board { border-width: 4px; padding: 3px; border-radius: 12px; }
  .grid { --cell-w: calc(var(--cell) * 1.12); grid-template-columns: repeat(6, var(--cell-w)); border-radius: 6px; }
  .meter { height: 8px; margin-top: 4px; }
  .lane { width: auto; flex: 1; max-width: 64px; margin: 28px 0 12px; border-radius: 10px; align-self: stretch; }
  .gauge.m { display: flex; align-items: center; gap: 8px; padding: 6px 12px 0; } .gauge.m div { flex: 1; height: 14px; border-width: 2px; }
  .ask { margin: 8px 8px 10px; padding: 8px 12px 14px; border-radius: 18px; }
  .ask .head { display: block; } .ask .head .cat { display: block; width: fit-content; } .ask .q { margin-top: 4px; font-size: 18px; }
  .choices { gap: 8px; } .choices .ui-btn { padding: 4px 8px calc(4px); gap: 7px; font-size: 16px; min-height: 76px; }
  .choices .ui-btn i { width: 1.5em; height: 1.5em; }
  .count { font-size: 170px; -webkit-text-stroke-width: 20px; } .count.go { font-size: 84px; }
  .banner { font-size: 104px; -webkit-text-stroke-width: 16px; } .banner.lose { font-size: 60px; }
  .fly { width: 30px; height: 30px; }
  .acts { flex-direction: column; align-items: stretch; width: min(100%, 320px); }
}

/* 背の低い画面 */
@media (min-width: 800px) and (max-height: 740px), (min-width: 800px) and (max-width: 1180px) and (min-aspect-ratio: 1/1) {
  .battle { --cell: calc(var(--u) * 25.5); } .mid { height: calc(var(--u) * 350); }
  .ask { padding-bottom: 10px; margin-left: calc(var(--u) * 70); margin-right: calc(var(--u) * 70); } .choices { gap: 7px 12px; }
}
@media (max-width: 799px) and (max-height: 740px) {
  .battle { --cell: min(calc((var(--h) * .40 - 130px) / 10), var(--fit)); }
  .ask { padding: 5px 10px 10px; margin: 4px 8px 8px; } .ask .q { font-size: 18px; line-height: 1.3; } .ask .cat { font-size: 13px; line-height: 1.4; }
  .choices .ui-btn { min-height: 66px; font-size: 15px; line-height: 1.2; }
}


@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  .hud { gap: 8px; padding: 0 10px; font-size: 14px; } .hud b { font-size: 13px; }
  .home { padding: 0 14px 12px; } .over { inset: -40px 0 0; overflow: auto; }
  .banner.quiet { font-size: 50px; -webkit-text-stroke-width: 12px; } .banner.small-banner { font-size: 44px; -webkit-text-stroke-width: 12px; }
  .result-box { gap: 12px; width: 100%; } .notes { padding: 6px 14px; font-size: 15px; } .score { padding: 6px 14px; }
  .stamp { font-size: calc(31px * var(--k)); padding: 2px 18px; } .stamp.ng { font-size: 28px; } .stamp.note { font-size: 20px; }
  .battle .ask .head { display: block; } .battle .ask.has-code { display: flex; } .battle .has-code .choices { grid-template-columns: 1fr 1fr; }
  .battle .lines { gap: 3px; } .battle .ui-btn.line { font-size: 14px; padding-left: 8px; padding-right: 8px; } .battle .code { font-size: 14px; padding: 6px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .over .banner { font-size: 76px; -webkit-text-stroke-width: 13px; } .over .banner.quiet { font-size: 44px; } .over .acts { gap: 8px; } .over .acts .ui-btn { min-height: 56px; font-size: 18px; padding-top: 4px; padding-bottom: calc(4px); } .over .score { font-size: 16px; gap: 2px 22px; } .over .notes { font-size: 14px; line-height: 1.4; }
  .battle .ask.has-code { justify-content: flex-start; } .battle .has-code .choices .ui-btn { min-height: 52px; }
  .battle.tight { --cell: min(calc((var(--h) * .36 - 120px) / 10), var(--fit)); } .battle.tight .mid { height: auto; } .battle.tight .ask { margin-top: 4px; padding: 5px 10px 8px; } .battle.tight .choices { gap: 6px; } .battle.tight .choices .ui-btn { min-height: 60px; font-size: 15px; line-height: 1.25; } .battle.tight .ask .q { line-height: 1.35; }
  .select { justify-content: flex-start; } .foes { grid-template-columns: 1fr; gap: 12px; } .foe-btn { flex-direction: row; text-align: left; padding: 10px 14px calc(8px); } .foe-btn .face { width: 92px; height: 92px; flex: none; padding: 8px; } .foe-btn > svg { width: 96px; flex: none; } .foe-text { font-size: 16px; } .foe-text strong { font-size: 24px; }
  .put { grid-template-columns: auto 1fr; align-content: start; } .put .pads { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); } .put .pads .go { grid-column: 1 / -1; } .put .hint { font-size: 18px; }
  .room { padding: 0 10px 8px; } .room .ask, .simple .ask, .terms .ask { padding: 12px 14px 18px; } .room .q, .simple .q, .terms .q { font-size: 19px; } .explain-panel { padding: 10px 16px 16px; } .explain-panel .acts, .sheet .acts { width: 100%; } .explain-panel .acts .ui-btn { width: 100%; }
  .sheet { padding: 12px 14px 18px; } .dots i { width: 20px; height: 20px; font-size: 11px; border-width: 2px; }
  .simple { flex-direction: column; padding: 0 10px 8px; gap: 8px; } .site-side { flex: 0 0 42%; } .browser-bar { padding: 0 8px; gap: 6px; min-height: 48px; } .address { font-size: 13px; padding: 3px 10px; } .tab { padding: 0 9px; } .steps { gap: 6px; font-size: 16px; } .steps i { width: 14px; height: 14px; }
  .terms { flex-direction: column; padding: 0 10px 8px; gap: 8px; } .term-side { flex: none; } .term-index { display: none; } .drawer-button { display: block; width: 100%; } .term-side.open { flex: 1; min-height: 0; } .term-side.open .term-index { display: flex; } .term-side.open + .term-main { display: none; } .entry { padding: 12px 16px 18px; } .entry h2 { font-size: 28px; } .entry .ui-btn, .acts.low .ui-btn { width: 100%; }
  .acts.low { flex-direction: row; width: 100%; } .columns { gap: 8px; } .columns .ui-btn { font-size: 16px; padding-left: 10px; padding-right: 10px; } .pause-panel, .popup { padding: 14px 16px 20px; } .set-row input[type="range"] { width: 150px; }
}
@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  .battle.tighter { --cell: min(calc((var(--h) * .28 - 100px) / 10), var(--fit)); } .battle.tighter .gauge.m { padding-top: 2px; } .battle.tighter .ask .cat { display: none; } .battle.tighter .ask .q { font-size: 17px; line-height: 1.3; } .battle.tighter .ask { gap: 3px; }
}
@media (max-width: 799px) and (max-height: 740px) { .battle.tight { --cell: calc((var(--h) * .34 - 120px) / 10); } }

/* 動きを減らす */
.calm #stage *, .calm #swim *, .calm *::before, .calm *::after { animation: none !important; transition-duration: .1s !important; }
.calm .danger .board::after { opacity: .45; }

/* ---- 第4弾: スマホの表示。幅800px以上の横長には当てない ---- */
.how-short { display: none; }
html, body { overscroll-behavior: none; }
button, .chip, .switch, .badge, .mode-btn, .term-row, .tab { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.q, .code, .code-text, .explain, .reason, .reply, .term-short, .notes li, .entry p { -webkit-user-select: text; user-select: text; }
.board.picking { touch-action: none; }
.symbols { display: none; gap: 4px; }
br.phone-only { display: none; }
.symbol { flex: 0 0 40px; min-width: 40px; min-height: 44px; padding: 0; border: 3px solid var(--line); border-radius: 12px; background: var(--white); color: var(--ink); font: 700 18px/1 var(--code); }
.dots-more { display: none; align-self: center; padding: 0 6px; color: var(--white); font-weight: 900; font-size: 14px; }
.dots-more:not([hidden]) { display: inline-flex; align-items: center; min-height: 26px; }

@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  #stage {
    height: calc(100vh - var(--barh));
    height: calc(100dvh - var(--barh));
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  #overlay {
    padding: calc(14px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
  }
  .symbols { display: flex; flex-wrap: wrap; }
  .symbol { flex: 1 1 calc((100% - 20px) / 6); width: auto; min-width: 44px; }
  br.phone-only { display: inline; }
  #solve-all { font-size: 17px; line-height: 1.25; }
  .switch { font-size: 16px; }
  .switch span { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
  .hud { height: 48px; min-height: 48px; }
  .hud b { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .hud .mode { flex: none; padding: 1px 8px; white-space: nowrap; font-size: 13px; }
  .hud .load-line { white-space: normal; }
  .hud button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .hud button.load-line { width: auto; height: auto; min-height: 44px; }

  .battle { --cell-floor: 12px; --cell: max(var(--cell-floor), min(calc((var(--h) * .45 - 136px) / 10), var(--fit))); }
  .battle.tight { --cell: max(var(--cell-floor), min(calc((var(--h) * .36 - 120px) / 10), var(--fit))); }
  .battle.tighter { --cell: max(var(--cell-floor), min(calc((var(--h) * .28 - 100px) / 10), var(--fit))); }
  .battle .ask, .battle .ask.has-code {
    display: flex; flex-direction: column; justify-content: flex-start; overflow: auto; min-height: 0;
  }
  .battle .ask > .head, .battle .ask > .ask-left, .battle .ask > .lines, .battle .ask > .code {
    flex: 0 0 auto; min-height: 0; overflow: visible;
  }
  .battle .ask:has(.lines) > .head { flex: 0 0 auto; }
  .battle .ask > .choices, .battle .ask > .ui-btn, .battle .ask > .ui-input, .battle .ask > .put, .battle .ask > .symbols { flex: none; }
  .battle .choices .ui-btn { font-size: 15px; min-height: 44px; }
  .battle .choices .ui-btn span { min-width: 0; white-space: normal; }
  .battle .ui-btn.line span { min-width: 0; overflow-wrap: anywhere; white-space: normal; word-break: normal; }
  .battle .choices.stack { grid-template-columns: 1fr; gap: 4px; }
  .battle .choices.stack .ui-btn { min-height: 44px; padding: 1px 8px; line-height: 1.15; border-width: 3px; }
  .battle .ui-btn.line { min-height: 44px; }
  .battle .ask:has(.put) { flex: none; overflow: visible; }
  .put .pads .ui-btn { min-height: 44px; }
  .fore b { font-size: 14px; }
  .fore i { width: 12px; height: 12px; }

  .how-long { display: none; }
  .how-short { display: block; flex: 1 1 auto; margin: 0; }
  .select { gap: 6px; padding: 2px 12px 4px; justify-content: flex-start; }
  .select h1 { font-size: 26px; }
  .foes { gap: 8px; }
  .foe-btn { min-height: 0; padding: 6px 10px; gap: 8px; }
  .foe-btn .face { width: 56px; height: 56px; }
  .foe-text span:nth-child(3) { display: none; }
  .foe-text { font-size: 15px; } .foe-text strong { font-size: 22px; }
  .how { padding: 8px 12px; gap: 8px; }
  .how .chip { min-height: 44px; }

  .simple { overflow: hidden; min-height: 0; }
  .site-side { flex: 1 1 42%; min-height: 40%; }
  .quiz-side { flex: 1 1 auto; min-height: 0; overflow: auto; }

  .terms { padding-bottom: 76px; }
  .drawer-button {
    position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 40; width: auto; max-width: 596px; margin: 0 auto; min-height: 48px;
  }
  .term-side.open .term-index { padding-bottom: 72px; }

  #resume-button { position: sticky; top: 0; z-index: 2; }

  .over { inset: 0; overflow: hidden; justify-content: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .result-box { width: 100%; max-height: 100%; overflow: hidden; justify-content: center; gap: 8px; }
  .over .banner, .over .banner.quiet { font-size: 48px; -webkit-text-stroke-width: 8px; }
  .over .notes { width: 100%; max-height: 22vh; overflow: auto; }
  .over .acts { flex: none; width: min(100%, 320px); }
  .over .acts .ui-btn { min-height: 44px; }
}

@media (max-width: 799px) and (max-height: 740px), (max-aspect-ratio: 1/1) and (max-height: 740px) {
  .battle { --cell: max(var(--cell-floor), min(calc((var(--h) * .40 - 130px) / 10), var(--fit))); }
  .battle.tight, .battle.tighter { --cell: max(var(--cell-floor), min(calc((var(--h) * .34 - 120px) / 10), var(--fit))); }
}
@media (max-width: 380px) and (max-height: 580px) {
  .battle { --cell-floor: 10px; --cell: max(var(--cell-floor), min(calc((var(--h) * .40 - 130px) / 10), var(--fit))); }
  .battle.tight, .battle.tighter { --cell: max(var(--cell-floor), min(calc((var(--h) * .34 - 120px) / 10), var(--fit))); }
  .battle .top { height: 40px; }
  .battle .fore { height: 20px; }
  .battle .gauge.m { padding-top: 2px; }
  .battle .ask { margin: 4px; }
}

@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  :root { --u: 1px; }
  #stage {
    width: 100%; max-width: none; margin: 0;
    height: 100vh; height: 100dvh;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .hud { height: 44px; min-height: 44px; }
  .hud button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .hud button.load-line { width: auto; height: auto; min-height: 44px; }
  .home { padding: 0 8px 6px; min-height: 0; }
  .logo { height: auto; padding: 0; flex-wrap: nowrap; gap: 8px; }
  .logo-row .block { width: 28px; height: 28px; font-size: 16px; }
  .logo-big { font-size: 26px; -webkit-text-stroke-width: 4px; }
  .rank { font-size: 13px; padding: 0 8px; }
  .modes { flex: 1 1 auto; min-height: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .mode-btn { min-height: 44px; padding: 4px; border-radius: 16px; gap: 0; }
  .mode-btn strong { font-size: 15px; white-space: normal; }
  .mode-btn small { font-size: 11px; line-height: 1.2; }
  .mode-btn svg { width: 32px; height: 32px; }
  .foot { flex-wrap: nowrap; gap: 8px; padding-top: 6px; min-height: 0; }
  .badge { flex: 1 1 auto; min-height: 44px; font-size: 13px; padding: 2px 8px; }
  .foot .ui-btn { width: auto; min-height: 44px; margin: 0; white-space: nowrap; }

  .battle {
    --cell-floor: 12px; --gap: 2px; --h: 100dvh;
    --fit: calc((46vw - 48px) / 13.5);
    --cell: max(12px, min(20px, var(--fit)));
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }
  .battle .top { grid-column: 1 / -1; grid-row: 1; height: 44px; }
  .battle .mid { grid-column: 1; grid-row: 2; height: auto; min-height: 0; align-self: center; padding: 0 4px; }
  .battle .gauge.m, .battle .corner, .battle .lane { display: none; }
  .battle .ask, .battle .ask.has-code {
    grid-column: 2; grid-row: 2; margin: 4px; min-height: 0; overflow: hidden;
    display: flex; flex-direction: column; justify-content: flex-end;
  }
  .battle .ask > .head, .battle .ask > .ask-left, .battle .ask > .lines {
    flex: 1 1 auto; min-height: 0; overflow: auto;
  }
  .battle .ask > .choices, .battle .ask > .put, .battle .ask > .ui-btn, .battle .ask > .symbols { flex: none; }
  .symbols { display: flex; flex-wrap: wrap; }
  .symbol { flex: 1 1 calc((100% - 20px) / 6); width: auto; min-width: 44px; }
  .battle .choices .ui-btn, .battle .ui-btn.line, .put .pads .ui-btn { min-height: 44px; font-size: 15px; }
  .battle .choices.stack { grid-template-columns: 1fr; }
  .battle .over { grid-column: 1 / -1; grid-row: 1 / -1; }
  .battle .ask:has(.put) { overflow: visible; }
  .fore b { font-size: 14px; }

  .select, .room, .sheet { overflow: auto; }
  .foes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .simple { flex-direction: row; overflow: hidden; }
  .site-side { flex: 0 0 46%; min-height: 40%; }
  .terms { flex-direction: row; padding-bottom: 8px; }
  .term-side { flex: 0 0 42%; }
  .term-index { display: flex; }
  .drawer-button { display: none; }
  .term-side.open + .term-main { display: flex; }
}

/* ---- タイトル画面 ---- */
.view.title { overflow: hidden; background: transparent; }
.title-rain { position: absolute; inset: 0; pointer-events: none; }
.title-rain i {
  position: absolute; top: -12%; font-style: normal; font: 700 calc(var(--u) * 26) / 1 var(--num); color: var(--ink);
  background: var(--c); border: calc(var(--u) * 3) solid var(--line); border-radius: calc(var(--u) * 10);
  padding: calc(var(--u) * 6) calc(var(--u) * 10); opacity: .55; animation: title-fall var(--t) linear infinite; animation-delay: var(--d);
}
@keyframes title-fall { to { transform: translateY(calc(var(--u) * 900)) rotate(20deg); } }
.title-logo { position: absolute; left: 50%; top: calc(var(--u) * 28); translate: -50% 0; text-align: center; z-index: 2; }
.title-blocks { display: flex; gap: calc(var(--u) * 8); justify-content: center; }
.title-block {
  display: grid; place-items: center; width: calc(var(--u) * 58); height: calc(var(--u) * 58);
  border: calc(var(--u) * 4) solid var(--line); border-radius: calc(var(--u) * 14); color: var(--ink);
  font: 900 calc(var(--u) * 32) / 1 var(--jp); box-shadow: inset 0 calc(var(--u) * 6) 0 rgba(255,255,255,.45);
  animation: title-hop 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * .12s);
}
@keyframes title-hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(calc(var(--u) * -10)); } }
.title-big {
  font: 900 calc(var(--u) * 92) / 1.05 var(--jp); color: var(--accent-y); -webkit-text-stroke: calc(var(--u) * 10) var(--line);
  paint-order: stroke fill; letter-spacing: .08em; margin-top: calc(var(--u) * 4);
}
.title-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.title-moon {
  position: absolute; left: 50%; top: calc(var(--u) * 168); width: calc(var(--u) * 380); height: calc(var(--u) * 380);
  translate: -50% 0; border-radius: 50%; background: var(--cpu); border: calc(var(--u) * 6) solid var(--line);
  box-shadow: 0 0 0 calc(var(--u) * 14) rgba(46, 224, 208, .18); z-index: 1;
}
.title-dojo { position: absolute; left: 50%; top: calc(var(--u) * 194); width: calc(var(--u) * 340); translate: -50% 0; transform-origin: 50% 62%; z-index: 2; }
.title-dojo svg { width: 100%; height: auto; display: block; overflow: visible; }
.title-glow { animation: title-glow 1.6s ease-in-out infinite; }
@keyframes title-glow { 50% { opacity: .45; } }
.title-noren { transition: transform .55s cubic-bezier(.5, 0, .2, 1); }
.title-start {
  position: absolute; left: 50%; top: calc(var(--u) * 560); translate: -50% 0; z-index: 3;
  min-width: calc(var(--u) * 340); min-height: 56px; padding: calc(var(--u) * 12) calc(var(--u) * 36) calc(var(--u) * 10);
  border: calc(var(--u) * 5) solid var(--line); border-radius: calc(var(--u) * 22); background: var(--accent-y); color: var(--ink);
  box-shadow: 0 calc(var(--u) * 9) 0 var(--line); font-family: var(--jp); text-align: center;
}
.title-start b { display: block; font: 900 calc(var(--u) * 40) / 1.1 var(--jp); }
.title-start small { display: block; font: 600 calc(var(--u) * 16) / 1.2 var(--num); letter-spacing: .2em; opacity: .8; }
.title-start.title-ready { animation: title-breathe 1.4s ease-in-out infinite; }
.title-start:active { translate: -50% calc(var(--u) * 4); box-shadow: 0 calc(var(--u) * 5) 0 var(--line); }
.title-start:disabled { background: var(--white); cursor: default; animation: none; }
@keyframes title-breathe { 50% { transform: scale(1.04); } }
.title-bar { height: calc(var(--u) * 8); margin-top: calc(var(--u) * 6); border-radius: 99px; background: #E9E1CF; overflow: hidden; }
.title-bar i { display: block; height: 100%; width: 0; background: var(--cpu); transition: width .2s; }
.title-next { position: absolute; left: 50%; top: calc(var(--u) * 668); translate: -50% 0; min-height: calc(var(--u) * 8); z-index: 3; }
.title-corner { position: absolute; bottom: calc(var(--u) * 18); z-index: 3; font: 900 calc(var(--u) * 20) / 1.3 var(--jp); }
.title-left { left: calc(var(--u) * 26); display: flex; gap: calc(var(--u) * 10); }
.title-right { right: calc(var(--u) * 26); }
.title-chip { padding: calc(var(--u) * 6) calc(var(--u) * 16); border: calc(var(--u) * 4) solid var(--line); border-radius: 99px; background: var(--panel); color: var(--ink); }
.title-chip.title-due { background: var(--accent-l); }
.title-sound {
  width: calc(var(--u) * 58); height: calc(var(--u) * 58); min-width: 44px; min-height: 44px;
  border: calc(var(--u) * 4) solid var(--line); border-radius: calc(var(--u) * 16); background: var(--panel); color: var(--ink);
  font: 900 calc(var(--u) * 22) / 1 var(--num);
}
.title-count { position: absolute; bottom: calc(var(--u) * 4); left: 50%; translate: -50% 0; z-index: 3; font: 500 calc(var(--u) * 14) / 1 var(--num); opacity: .7; color: var(--white); }
.title-veil { position: absolute; inset: 0; background: var(--white); opacity: 0; pointer-events: none; z-index: 4; }
.view.title.title-going .title-dojo { animation: title-enter .7s cubic-bezier(.55, 0, .3, 1) forwards; }
.view.title.title-going .title-moon { animation: title-away .5s ease-in forwards; }
.view.title.title-going .title-logo,
.view.title.title-going .title-start,
.view.title.title-going .title-corner,
.view.title.title-going .title-count,
.view.title.title-going .title-rain,
.view.title.title-going .title-next { animation: title-away .35s ease-in forwards; }
.view.title.title-going .title-veil { animation: title-veil .7s ease-in forwards; }
.view.title.title-going .title-n1 { transform: translateX(-24px); }
.view.title.title-going .title-n3 { transform: translateX(24px); }
@keyframes title-enter { 30% { transform: scale(1.1); } 100% { transform: scale(4.2) translateY(12%); opacity: 0; } }
@keyframes title-away { to { opacity: 0; transform: translateY(calc(var(--u) * 20)); } }
@keyframes title-veil { 70% { opacity: 0; } 100% { opacity: .9; } }
@keyframes title-fade { to { opacity: 0; } }
.calm #stage .view.title.title-going { animation: title-fade .15s linear forwards !important; }
.calm #stage .view.title .title-rain,
.calm #stage .view.title .title-block,
.calm #stage .view.title .title-glow,
.calm #stage .view.title .title-start.title-ready { animation: none !important; }

@media (max-width: 799px), (max-aspect-ratio: 1/1), (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .view.title { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 12px 12px 78px; overflow: hidden; }
  .title-logo, .title-dojo, .title-start, .title-moon { position: relative; left: auto; top: auto; translate: none; }
  .title-block { width: min(13vw, 64px); height: min(13vw, 64px); font-size: min(7.5vw, 36px); border-width: 4px; }
  .title-big { font-size: min(19vw, 96px); -webkit-text-stroke-width: 8px; }
  .title-moon { position: absolute; top: 46%; left: 50%; width: min(78vw, 360px); height: min(78vw, 360px); translate: -50% -50%; }
  .title-dojo { width: min(68vw, 300px); }
  .title-start { width: min(84vw, 380px); min-width: 0; min-height: 56px; top: auto; }
  .title-start:active { translate: 0 4px; }
  .title-corner { bottom: 28px; }
  .title-count { bottom: 4px; }
  .title-next { position: relative; top: auto; min-height: 8px; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .view.title { gap: 6px; padding-bottom: 52px; }
  .title-block { width: 32px; height: 32px; font-size: 16px; }
  .title-big { font-size: 40px; -webkit-text-stroke-width: 5px; }
  .title-moon { width: 150px; height: 150px; }
  .title-dojo { width: 132px; }
  .title-corner { bottom: 18px; }
  .title-start { min-height: 56px; padding: 6px 18px; }
  .title-start b { font-size: 28px; }
  .title-chip { font-size: 14px; padding: 4px 10px; }
}

/* ---- 辞書 ---- */
#dictionary {
  position: fixed; inset: 0; z-index: 70; align-items: center; justify-content: center;
  padding: 28px; background: var(--veil);
}
.dict-panel {
  width: min(860px, 100%); max-height: min(640px, 100%); display: flex; flex-direction: column; gap: 12px;
  padding: 18px 18px 16px; border: 4px solid var(--line); border-radius: 28px;
  background: var(--panel); color: var(--ink); box-shadow: 0 16px 0 rgba(19, 13, 49, .28);
}
.dict-head { display: flex; align-items: center; gap: 12px; }
.dict-head b { font-size: 28px; font-weight: 900; margin-right: auto; }
.dict-head button, .dict-back {
  min-width: 44px; min-height: 44px; border: 3px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--ink); font-weight: 900;
}
#dict-query {
  width: 100%; min-height: 56px; padding: 8px 14px; border: 4px solid var(--line); border-radius: 16px;
  background: var(--white); color: var(--ink); font: inherit; font-size: 20px;
}
#dict-results { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
#dict-results h2 { margin: 8px 0 0; font-size: 16px; color: var(--ink-dim); }
.dict-row, .dict-question { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.dict-row {
  min-height: 52px; padding: 8px 12px; border: 3px solid var(--line); border-radius: 16px;
  background: var(--white); color: var(--ink); font: inherit;
}
.dict-row.static { cursor: default; }
.dict-row b { flex: none; }
.dict-row small { margin-left: auto; color: var(--ink-dim); font-size: 14px; }
.dict-question { align-items: stretch; }
.dict-question .dict-row { flex: 1; width: auto; min-width: 0; }
.dict-solve {
  flex: none; min-width: 72px; min-height: 52px; padding: 0 12px; border: 3px solid var(--line); border-radius: 16px;
  background: var(--accent-y); color: var(--ink); font: inherit; font-weight: 900;
}
.dict-explain, .dict-reading, .dict-empty { margin: 0; }
.story-band {
  flex: none; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; margin: 0 0 8px;
  padding: 8px 16px; border: 4px solid var(--line); border-radius: 22px; background: var(--story-paper);
  color: var(--story-ink); text-align: left; font: inherit;
}
.story-band b { display: block; font-size: max(18px, calc(var(--u) * 28)); line-height: 1.1; }
.story-band small { display: block; margin-top: 2px; font-weight: 700; font-size: max(13px, calc(var(--u) * 16)); }
.home .logo { height: calc(var(--u) * 96); }
.home .logo-big { font-size: calc(var(--u) * 72); -webkit-text-stroke-width: calc(var(--u) * 10); }
.home .logo-row .block { width: calc(var(--u) * 58); height: calc(var(--u) * 58); font-size: calc(var(--u) * 34); }
.dot { width: calc(var(--u) * 96); height: auto; image-rendering: pixelated; image-rendering: crisp-edges; background: transparent; }
.dot.big { width: calc(var(--u) * 128); }
.story-band .dot { width: 64px; height: 64px; }
.set-row input[type="text"] { width: 8em; min-height: 52px; padding: 8px 12px; border: 4px solid var(--line); border-radius: 14px; background: var(--white); color: var(--ink); font: 900 18px/1.4 var(--jp); }
.view.story { min-height: 0; padding: 8px; }
.story-window {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px;
  border: 4px solid var(--story-ink); border-radius: 18px; background: var(--story-paper); color: var(--story-ink); overflow: hidden;
}
.story-title { flex: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; background: var(--story-wood); color: var(--white); font-weight: 900; }
.dojo-name { min-width: 0; line-height: 1.35; }
.dojo-name b { font-weight: 900; }
.dojo-badge { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; background: var(--accent-y); color: var(--ink); font-style: normal; font-size: 13px; line-height: 1.7; white-space: nowrap; vertical-align: 1px; }
.dojo-label { margin: 10px 0 2px; font-size: 16px; }
.dojo-theme { font-weight: 700; }
.dojo-feel p { margin: 0; }
.dojo-warn { font-weight: 700; }
.dojo-kokoro p { margin: 0; }
.dojo-tip { margin: 8px 0; padding: 10px 12px; border: 3px solid var(--line); border-radius: 16px; background: var(--accent-y); color: var(--ink); }
.dojo-tip p { font-weight: 700; }
.dojo-actions { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
.dojo-action { display: flex; align-items: center; gap: 12px; }
.dojo-action .ui-btn { flex: 0 0 auto; min-width: 11em; text-align: center; }
.dojo-action small { flex: 1; min-width: 0; font-weight: 700; line-height: 1.4; color: var(--ink); }
@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  .dojo-action { flex-direction: column; align-items: stretch; gap: 2px; }
  .dojo-action .ui-btn { width: 100%; }
  .dojo-action small, .story-stop small, .dojo-badge { font-size: 14px; }
}
.story-title .dot { width: 48px; height: 48px; }
.story-window, .story-body, .story-scroll { min-width: 0; max-width: 100%; }
.story-body, .story-scroll { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 12px; }
.story-scroll.more { box-shadow: inset 0 -16px 12px -12px rgba(42, 24, 72, .45); }
.scroll-actions { display: flex; flex-direction: column; gap: 6px; width: min(100%, 520px); margin: 0 auto; padding: 0 8px 8px; }
.scroll-actions > .ui-btn { width: 100%; min-height: 44px; }
.scroll-nav { display: flex; gap: 8px; }
.scroll-nav .ui-btn { flex: 1; min-height: 36px; padding: 2px 8px; font-size: 15px; }
.story-kicker { margin: 0 0 4px; font-weight: 900; }
.story-line { margin: 0; font-weight: 700; line-height: 1.5; }
.story-road { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.story-stop {
  min-height: 64px; padding: 8px 10px; border: 4px solid var(--line); border-radius: 16px;
  background: var(--white); color: var(--ink); text-align: left; font: inherit;
}
.story-stop b, .story-stop small { display: block; }
.story-stop small { font-weight: 700; white-space: normal; }
@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  .home .logo { height: auto; overflow: visible; padding: 4px 0 8px; }
  .home .logo-big { font-size: 36px; -webkit-text-stroke-width: 6px; }
  .home .logo-row .block { width: min(11vw, 48px); height: min(11vw, 48px); font-size: min(6.4vw, 28px); }
  .story-band { min-height: 64px; margin-bottom: 6px; }
}
.story-stop.spot { background: var(--accent-y); }
.story-stop.locked { opacity: .55; }
.story-stop:disabled { cursor: default; }
.story-name { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 900; }
.story-name input { width: 8em; min-height: 52px; padding: 8px 12px; border: 4px solid var(--line); border-radius: 14px; font: 900 20px/1.4 var(--jp); }
.story-hp { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.story-hp b { width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-bar { flex: 1; display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; height: 16px; }
.story-bar i { display: block; background: #ddd; border-radius: 2px; }
.story-hp.hero .story-bar i.on { background: var(--story-hp); }
.story-hp.foe .story-bar i.on { background: var(--story-foe); }
.story-stage { display: flex; justify-content: space-between; align-items: end; min-height: 96px; padding: 4px 12px; }
.story-stage .who { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 900; }
.story-ask { margin: 0 8px; padding: 8px 10px 10px; max-height: 46%; min-height: 160px; overflow: auto; }
.story-window > p, .story-window > .story-hp { padding: 0 12px; }
.story-window > .story-hp:first-child { padding-top: 8px; }
.story-battle .story-window { overflow: auto; }
.story-battle .story-window > * { flex-shrink: 0; }
.story-battle .story-window > .story-ask { flex-shrink: 1; }
.story-commands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 8px; }
.story-commands .ui-btn { min-height: 56px; }
.story-commands .ui-btn.picked { outline: 4px solid var(--accent-y); }
.story-hints { margin: 0 8px; padding-left: 1.2em; }
.story-map h2 { margin: 12px 0 8px; font-size: 18px; }
.view.story .acts { flex: none; align-self: center; padding: 0 8px 8px; }
@media (max-width: 420px), (max-height: 700px) {
  .story-commands { grid-template-columns: 1fr; }
  .story-commands .ui-btn { min-height: 52px; }
  .story-road { grid-template-columns: 1fr; }
  .story-ask { max-height: none; }
}
@media (max-height: 420px) and (orientation: landscape) {
  .story-battle .story-window { display: grid; grid-template-columns: minmax(180px, 34%) 1fr; grid-auto-rows: auto; overflow: auto; }
  .story-battle .story-stage { grid-column: 1; grid-row: 1 / span 3; }
  .story-title, .story-hp, .story-ask, .story-commands, .story-line, .story-hints { min-width: 0; }
}
.dict-explain { padding: 8px 12px; border-radius: 12px; background: var(--white); }
.dict-panel mark { background: var(--accent-y); color: inherit; border-radius: 4px; }
@media (max-width: 799px), (max-aspect-ratio: 1/1), (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .battle .choices .ui-btn, .battle.tight .choices .ui-btn, .battle.tighter .choices .ui-btn { font-size: 16px; }
  .battle:has(.choices.stack) { --cell-floor: 8px; --cell: 8px; }
  .battle:has(.choices.stack) .top { height: 40px; }
  .battle:has(.choices.stack) .top .who .face { width: 36px; height: 36px; }
  .battle:has(.choices.stack) .ask .q { font-size: 16px; line-height: 1.3; }
  .battle:has(.choices.stack) .ask { margin: 2px; padding: 4px 4px 6px; }
  .battle .choices.stack, .story-ask .choices.stack { grid-template-columns: 1fr; gap: 4px; }
  .battle .has-code .choices.stack { grid-template-columns: 1fr; }
  .battle .choices.stack .ui-btn, .battle.tight .choices.stack .ui-btn, .battle.tighter .choices.stack .ui-btn,
  .story-ask .choices.stack .ui-btn {
    font-size: 16px; min-height: 40px; padding: 2px 8px; line-height: 1.25;
  }
  .battle .choices.stack.dense .ui-btn, .story-ask .choices.stack.dense .ui-btn {
    padding: 0 2px; line-height: 1.15; gap: 2px; letter-spacing: -0.16em;
  }
  .battle .choices.stack.dense .ui-btn i, .story-ask .choices.stack.dense .ui-btn i { width: 1.15em; height: 1.15em; }
  .battle .choices.stack.dense .ui-btn span, .story-ask .choices.stack.dense .ui-btn span {
    overflow-wrap: anywhere; word-break: break-all; line-break: auto; text-wrap: wrap;
  }
  .story-ask .choices .ui-btn { font-size: 16px; min-height: 44px; }
  .story-battle:has(.choices.stack) .story-stage { min-height: 0; height: 72px; padding-top: 0; padding-bottom: 0; overflow: hidden; }
  .story-battle:has(.choices.stack) .story-stage .dot { transform: scale(.62); transform-origin: center bottom; }
  .story-battle:has(.choices.stack) .story-ask { margin: 0 2px; padding: 4px; }
  .story-battle:has(.choices.stack) .story-hp { min-height: 20px; }
  .story-battle:has(.choices.stack) .story-bar { height: 10px; }
  .story-battle:has(.choices.stack) .story-ask { overflow: visible; max-height: none; }
}

.hud .load-line { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.hud button.skip-tag {
  width: auto; height: auto; min-width: 0; min-height: 28px; margin: 0; padding: 2px 8px;
  border-radius: 999px; background: var(--ng); color: var(--white); border-color: var(--ng);
  font-size: 13px; line-height: 1.2; white-space: nowrap;
}

@media (max-width: 799px) and (max-aspect-ratio: 1/1) {
  .view.terms { min-height: 0; overflow: hidden; }
  .terms .term-main { order: 1; flex: 0 0 auto; min-height: 0; max-height: 42%; overflow: auto; }
  .terms .term-side { order: 2; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .terms .term-index { display: flex; flex: 1 1 auto; min-height: 0; overflow: auto; }
  .terms .drawer-button { display: none; }
  .terms .term-side.open + .term-main { display: block; }
}

@media (max-width: 799px), (max-aspect-ratio: 1/1) {
  #dictionary { padding: 0; }
  .dict-panel { width: 100%; height: 100%; max-height: none; border-radius: 0; border-width: 0; box-shadow: none; }
  .dict-row, .dict-solve { min-height: 48px; }
}
