:root {
  color-scheme: dark;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color: #f8f3df;
  background: #100f1c;
  --ink: #161323;
  --cream: #fff0cb;
  --gold: #ffd681;
  --red: #db4a38;
  --panel: #191628;
}
body {
  background: radial-gradient(ellipse at center, #130f1a22, #100c18b0 82%),
    url("assets/arcade-shrine.webp") center center / cover fixed #171527;
}
main, main[data-theme] {
  --accent: var(--stage-color, #c24536);
  max-width: min(1040px, calc(100% - 26px));
  min-height: 0;
  margin: 10px auto 0;
  padding: 10px 18px 14px;
  background: linear-gradient(155deg, #1c1829ed, #131021ec 62%, #211725f6);
  border: 1px solid #a68152;
  box-shadow: inset 0 0 0 3px #e1ab5a16, 0 12px 45px #090810c9;
  position: relative;
}
main::before, main::after {
  content: ""; position: absolute; width: 34px; height: 8px; pointer-events: none;
  background: repeating-linear-gradient(120deg,#edbe68 0 4px,transparent 4px 7px);
}
main::before {left:0;top:0;}
main::after {right:0;bottom:0;}
main header, main[data-theme] header {
  background: linear-gradient(101deg,#891f26 0%, #ce472e 36%, #5b272d 61%,#201b31 78%);
  border: 1px solid #e5b067;
  border-radius: 3px 18px 3px 18px;
  box-shadow: inset 0 -4px #130e238a, 0 3px #080810;
  padding: 8px 18px 9px;
  min-height: 68px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
main header::after {
  content:"";position:absolute;z-index:-1;inset:0;
  background:repeating-linear-gradient(125deg,transparent 0 17px,#ffd47d22 18px 21px,transparent 23px 40px);
}
.header-titles {transform:skewX(-6deg);}
h1 {
  font-weight: 950; font-size: clamp(1.65rem, 5.3vw, 3rem); line-height: 1.09;
  letter-spacing: -.045em; color: #ffe9ac;
  -webkit-text-stroke: .5px #ffe4a1;
  text-shadow: 2px 2px #621e30, 4px 4px #231628;
}
header p {
  margin-top: 4px;font-family: Impact, "Arial Black", system-ui, sans-serif;
  font-size:.86rem;letter-spacing:.22em;color:#fff7dd;
}
.player-badge {
  max-width: min(42%, 250px); overflow-wrap:anywhere; border:1px solid #be914e;
  border-radius:3px 10px; font-size:.78rem;color:#ffefce;background:#231a2eee;
}
.player-badge .player-label {color:#ffd893;opacity:1;}
nav {max-width: min(100%, 530px);margin: 11px auto;gap:7px;}
button, .auth-gate-link {
  color:#fff2d1; border:1px solid #b48b52; border-radius:4px 11px;
  background:linear-gradient(160deg,#443449,#231c31 62%,#291b32);
  box-shadow:inset 0 1px #ffdf9f57,inset 0 -3px #120f20,0 3px #0a0911;
  font-weight:800;
}
button:not(:disabled):hover {border-color:#ffe09a;filter:brightness(1.14);}
button:focus-visible {outline:2px solid #7ef2ff;outline-offset:3px;}
nav button {
  min-height:39px;box-shadow:inset 0 1px #ffd48d57,inset 0 -3px #120f20,0 2px #0a0911;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}
nav button[aria-pressed=true],#clues button[aria-pressed=true] {
  border:1px solid #fff2ad;background:linear-gradient(#ffe097,#c77b36);
  color:#211329;box-shadow:inset 0 0 0 2px #b04a3440,0 0 12px #ffcf6247;
}
.progress {
  justify-content:center;
  gap:6px 10px;
  padding:5px 8px 7px;
  margin-bottom:10px;
  border-block:1px solid #805446;
  background:linear-gradient(90deg,transparent,#492332 27%,#241c31 72%,transparent);
}
.stage-status,.stage-controls {
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  gap:5px;
  max-width:100%;
}
.progress .stage-status > * {
  padding:5px 13px;
  border:1px solid #ffcf79;
  border-radius:2px 10px 2px 2px;
  background:linear-gradient(165deg,#d44b35,#751f2e 70%,#4d182b);
  box-shadow:inset 0 1px #fff4,0 2px #371221;
  color:#fff1bd;
  letter-spacing:.015em;
}
.progress #size {
  background:linear-gradient(165deg,#ffeab0,#ce8b41);
  color:#291726;
}
.stage-controls::before {
  content:"";
  width:14px;
  height:22px;
  margin-inline:0 3px;
  transform:skewX(-19deg);
  background:repeating-linear-gradient(90deg,#d99a5e 0 3px,transparent 3px 6px);
}
.progress button,.audio-settings summary {min-height:34px;}
.progress .stage-controls button {
  margin:0;
  border-radius:2px 10px 2px 2px;
}
.progress #exit {
  padding-block:5px;
  flex:0 1 auto;
  border-color:#e9b66d;
  background:linear-gradient(165deg,#56344c,#261a30 68%);
}
.progress #exit:hover {
  background:linear-gradient(165deg,#77445a,#3a2240 68%);
}
@media(max-width:440px) {
  .stage-controls::before {display:none;}
}
#sound[aria-pressed=false]{opacity:.75;}
.audio-settings summary {
  color:#f8dfac;display:list-item;padding:4px 7px;min-height:0;
}
.audio-settings[open],.audio-panel {
  color:#fff0cd;background:#2a2032;
  border-color:#bc925a;box-shadow:0 5px 16px #0907108f;
}
.audio-panel select {background:#1c1527;color:#fff0cd;}
main[data-theme] #board, main #board {
  background:linear-gradient(145deg,#35233b,var(--ink) 52%,color-mix(in srgb,var(--accent),#171224 73%));
  border:1px solid #dbac6f;border-radius:5px 16px;padding:6px;
  box-shadow:0 0 0 3px #cfa65724,0 4px #090913,0 12px 30px #080711b0;
}
.board-scene img {display:none;}
#board .tile {
  background:linear-gradient(145deg,#fff7df,#e6cba4);
  border:1px solid #bc8857;color:#1a1526;
  border-radius:4px 8px;
  box-shadow:inset 0 1px #fffbf3,inset 0 -3px #b98c55;
  font-weight:850;
}
#board .tile.selected {border-color:#ffae49;box-shadow:inset 0 0 0 1px #e3a14a;}
#board .tile.solved {background:linear-gradient(137deg,#b7f2d9,#6eb4a4);border-color:#8cd9ba;}
#board .tile.current {
  color:#1c1427;background:linear-gradient(#ffed94,#f99739);border-color:#fff1be;
  box-shadow:inset 0 0 0 1px #d97628,0 0 10px #ffbd5d50;
}
main[data-theme] #board .block,main #board .block {
  border-radius:3px;background:repeating-linear-gradient(136deg,#211a2b 0 5px,#2e2234 5px 7px);
}
#board.barred .tile.bar-right::after,#board.barred .tile.bar-bottom::before {background:#130e21;}
#bar-help {color:#f5dab0;}
#clues button {min-height:36px;}
.clue {
  color:#fff1d2;background:linear-gradient(135deg,#332637,#231a30);border:1px solid #b58853;
  border-radius:4px 15px;box-shadow:inset 3px 0 #bc513f,0 3px #0b0914;
  font-size:clamp(.9rem,2.4vw,1.07rem);
}
.clue img {mix-blend-mode:normal;border-radius:4px;}
#direction {min-height:37px;background:linear-gradient(#583044,#311e34);}
#keys button {
  background:linear-gradient(145deg,#fef1c8 0%,#e9b872 54%,#d78d49 100%);
  color:#2a1523;border:1px solid #ffe0a3;box-shadow:inset 0 2px #fff5c7,inset 0 -4px #a75c40,0 3px #0d0a15;
}
#keys .erase,.primary,#start,.auth-gate-link {
  background:linear-gradient(145deg,#e95e44,#a52835 68%,#842339);color:#fff9e2;
  border-color:#eda96b;box-shadow:inset 0 1px #ffc493,inset 0 -3px #69172c,0 3px #090912;
}
#focus-word .current,#focus-word .solved {color:#1a1526;}
#celebration,.panel,.auth-gate-card {
  background:linear-gradient(145deg,#372440,#1e182d 65%);color:#fff0ce;
  border:1px solid #cf9e63;border-radius:5px 18px;box-shadow:0 5px 18px #090813ad;
}
#celebration h2,.panel h2,.auth-gate-card h2 {color:#ffd888;}
.auth-gate-backdrop {background:#110b1fb5;backdrop-filter:blur(3px);}
#status {color:#ffc2aa;}
#status:empty {display:none;}
@media (min-width:760px) {
  #play {column-gap:24px;}
  #board {width:min(85%,360px,max(195px,calc(100svh - 253px)));}
  #board.barred.dense {width:min(93%,410px,max(190px,calc(100svh - 277px)));}
  .clue {min-height:68px;}
}
@media (max-width:550px) {
  body {background-attachment:scroll;background-position:center top;}
  main,main[data-theme] {max-width:none;margin:0;padding:9px 9px 14px;border-inline:0;}
  main header,main[data-theme] header {padding-inline:10px;gap:5px;}
  nav {gap:4px;}
  .player-badge {padding:3px 6px;font-size:.7rem;}
  .player-badge .player-label {display:none;}
  .progress #exit {min-height:35px;}
}

body {min-height:100svh;display:flow-root;}
main header::before {
  content:"";position:absolute;z-index:-1;inset:0 0 0 46%;
  background:linear-gradient(90deg,#24192b 0%,transparent 54%),
    url("assets/arcade-shrine.webp") center 38% / cover;
  opacity:.38;
}
.score-hud {
  display:flex;align-items:stretch;justify-content:center;gap:5px;
  margin:0 0 8px;padding:4px;background:#161324;border:1px solid #a57b50;border-radius:4px 10px;
}
.score-hud div {display:flex;flex:1;gap:8px;align-items:center;justify-content:space-between;padding:3px 7px;}
.score-hud div+div {border-left:1px solid #805c48;}
.score-hud span {font-size:.75rem;color:#f2d5aa;}
.score-hud strong,#score-change {font-family:Impact,"Arial Black",system-ui,sans-serif;font-variant-numeric:tabular-nums;}
.score-hud strong {font-size:1.2rem;letter-spacing:.05em;color:#ffe8a9;}
#score-change {align-self:center;min-width:3ch;color:#8ee9d3;text-align:center;padding-inline:3px;}
#score-change[data-negative=true] {color:#ffa59e;}
#score-change:empty {display:none;}
.score-rules {color:#efd4a5;font-size:.85rem;}
#celebration #clear-score {color:#ffdc90;}
@media (min-width:760px) {
  .score-hud {grid-column:2;grid-row:2;align-self:start;margin-bottom:5px;}
  .audio-settings {grid-column:2;grid-row:3;}
  #clues {grid-row:4;}
  .clue {grid-row:5;}
  #focus-word {grid-row:6;}
  #keys {grid-row:7;}
  #play > .actions {grid-row:8;}
  #play:not(.celebrating) .board-scene {grid-row:2/9;}
  #celebration {grid-row:4;}
}
@media (min-width:760px) {
  #celebration {
    width:min(100%,760px);display:grid;grid-template-columns:1fr 1fr;
    align-items:center;column-gap:16px;padding:14px 16px;
  }
  #celebration-title,#celebration-progress,#course-progress,#celebration > p:has(#clear-score) {grid-column:1;}
  #celebration [data-text=learned] {grid-column:2;grid-row:1;}
  #learned-words {grid-column:2;grid-row:2/5;}
  #celebration > .actions {grid-column:1/-1;grid-row:5;}
  #course-progress {justify-self:center;}
}
@media (min-width:760px) {
  #celebration-title {grid-row:1;}
  #celebration-progress {grid-row:2;}
  #course-progress {grid-row:3;}
  #celebration > p:has(#clear-score) {grid-row:4;}
  #play.celebrating {row-gap:0;}
}
@media (min-width:760px) and (max-height:720px) {
  main,main[data-theme] {margin-top:5px;padding-bottom:9px;}
  #celebration {margin-bottom:0;padding-block:11px;}
}
#celebration h2 {font-size:clamp(1.5rem,4.2vw,2rem);line-height:1.15;text-wrap:balance;}

#home-ranking,#clear-ranking {
  position:relative;isolation:isolate;text-align:left;
  background:linear-gradient(120deg,#402738,#211a30 55%,#161527);
  border:1px solid #ba8d55;border-radius:4px 13px;
  padding:7px 10px 9px;box-shadow:inset 3px 0 #d25e41,0 3px #110b19;
}
#home-ranking {max-width:480px;margin:18px auto 0;}
#clear-ranking {margin-top:9px;}
#home-ranking h3,#clear-ranking h3 {
  margin:0;color:#ffe298;font-weight:950;font-size:1rem;
  font-family:Impact,"Arial Black","Hiragino Kaku Gothic ProN",sans-serif;letter-spacing:.06em;
}
#home-ranking .ranking-scope,#clear-ranking .ranking-scope {
  margin:1px 0 5px;color:#ebc399;font-size:.68rem;
}
#home-ranking ol,#clear-ranking ol {list-style:none;margin:0;padding:0;display:grid;gap:3px;}
#home-ranking li,#clear-ranking li {
  display:grid;grid-template-columns:24px minmax(0,1fr) auto;gap:7px;align-items:center;
  padding:2px 6px 2px 3px;background:#110e20b0;border:1px solid #845e49;border-radius:3px;
}
.rank-medal {text-align:center;font-weight:900;color:#271619;background:#ffe092;border-radius:2px;}
li:nth-child(2) .rank-medal {background:#dae6f1;}
li:nth-child(3) .rank-medal {background:#db9766;}
.rank-name {text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:.83rem;font-weight:700;}
#home-ranking li strong,#clear-ranking li strong {color:#ffdf8a;font:1.05rem Impact,"Arial Black",sans-serif;letter-spacing:.035em;}
#home-ranking .rank-empty,#clear-ranking .rank-empty {margin:0;color:#f4deba;font-size:.8rem;line-height:1.4;}
@media (min-width:760px) {
  #celebration [data-text=learned] {grid-column:1;grid-row:5;padding-top:6px;}
  #learned-words {grid-column:1;grid-row:6;max-height:65px;margin-top:3px;}
  #clear-ranking {grid-column:2;grid-row:1/7;margin-top:0;}
  #celebration > .actions {grid-row:7;margin-top:6px;}
}

#retry-dialog {
  width:min(620px,calc(100vw - 22px));max-height:calc(100svh - 20px);margin:auto;
  border:1px solid #f2a465;border-radius:4px 19px;padding:0;
  color:#fff0ce;background:radial-gradient(ellipse,#492238,#1b1328 72%);
  box-shadow:0 0 36px #f66b554c,0 12px 24px #0a0816;
}
#retry-dialog::backdrop {background:#100818ca;}
#retry-show {position:relative;height:clamp(130px,42svh,275px);overflow:hidden;}
#retry-show .dragon-film {transform:scale(1.2);}
#retry-show .dragon-still {width:78%;}
.retry-copy {
  padding:5px 15px 15px;text-align:center;
  background:linear-gradient(145deg,#542c35,#24172c);border-top:1px solid #b57256;
}
.retry-copy h2 {color:#ffb681;font-size:clamp(1.65rem,8vw,3.2rem);line-height:1.13;text-shadow:2px 2px #801f2c;}
.retry-copy p {margin:7px auto 11px;}

.score-hud {
  gap:6px;isolation:isolate;padding:4px;
  background:linear-gradient(155deg,#e3aa59,#4b263c 21%,#130e20 44%,#101421 78%,#c98b51);
  border:1px solid #f3be75;border-radius:3px 12px;
  box-shadow:0 3px 0 #070711,0 0 16px #ec874b40,inset 0 0 0 2px #0e0c16;
}
.score-hud .score-stage,.score-hud .score-total {
  position:relative;isolation:isolate;overflow:hidden;
  display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;
  gap:6px;min-width:0;min-height:40px;padding:3px 9px 4px;
  border:1px solid #e9a861;border-radius:2px 9px;box-shadow:inset 0 -3px #0c0b16ab;
}
.score-hud .score-stage {
  background:linear-gradient(105deg,#872936,#4b2134 59%,#1d1528);
}
.score-hud .score-total {
  background:linear-gradient(105deg,#263759,#263055 58%,#16182e);
}
.score-hud .score-stage::before,.score-hud .score-total::before {
  content:"";position:absolute;inset:0;z-index:-1;
  background:repeating-linear-gradient(126deg,transparent 0 12px,#ffd68618 13px 16px,transparent 17px 25px);
}
.score-hud .score-stage::after,.score-hud .score-total::after {
  content:"";position:absolute;inset:auto 0 1px;height:2px;
  background:linear-gradient(90deg,#ffa85d,transparent 72%);
}
.score-hud .score-total::after {background:linear-gradient(90deg,#6bc9ff,transparent 72%);}
.score-hud span {
  color:#fff1cd;font-size:clamp(.61rem,1.3vw,.83rem);font-weight:850;
  line-height:1.15;text-shadow:1px 1px #1b1220;
}
.score-hud strong {
  color:#fff0a4;font-size:clamp(1.42rem,3vw,2rem);line-height:1.05;
  letter-spacing:.03em;text-shadow:0 2px #772d31,0 0 11px #ffca6475;
}
.score-hud .score-total strong {color:#ffe6a2;text-shadow:0 2px #32395d,0 0 11px #ffdf746b;}
#score-change {
  align-self:center;min-width:0;padding:3px 5px;border-radius:3px;
  background:#13172b;border:1px solid #63c9b2;font-size:.88rem;
}
#score-change[data-negative=true] {border-color:#d97873;}
@media (max-width:440px) {
  .score-hud .score-stage,.score-hud .score-total {padding-inline:5px;gap:4px;}
  .score-hud strong {font-size:clamp(1.1rem,4.8vw,1.5rem);}
  #score-change {padding-inline:3px;font-size:.74rem;}
}
