* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --gold: #d9ae58;
  --cream: #fff1cc;
  --muted: #b9ccbe;
  --emerald: #0c4c36;
  --dark: #061810;
  font-family: system-ui, sans-serif;
  color: var(--cream);
  background: var(--dark);
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #06181047 5%, transparent 34%, #06181078 76%, #061810 100%),
    url("./assets/temple.jpg") center top / cover fixed;
}
[hidden] { display: none !important; }
button, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #78fff1; outline-offset: 3px; }
h1, h2 { font-family: Georgia, serif; margin: 0; }
p { margin: 0; }
.topbar {
  min-height: 52px;
  padding: 4px clamp(12px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #051810e8;
  border-bottom: 1px solid #a87b3e86;
}
.brand, .quiet {
  border: 1px solid transparent;
  background: transparent;
  min-height: 40px;
  border-radius: 6px;
  padding: 0 10px;
}
.brand {
  padding-left: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 700 20px Georgia, serif;
  color: #f4d290;
}
.quiet:hover:not(:disabled), .brand:hover:not(:disabled) { background-color: #23614780; border-color: #b18c4f; }
.quiet:disabled { opacity: .45; }
main { flex: 1; display: grid; place-items: center; min-width: 0; }
.menu {
  width: min(600px, 100%);
  padding: 32px 12px 38px;
  text-align: center;
  background: radial-gradient(ellipse at center, #04180fea 22%, #04180f99 46%, transparent 72%);
}
.crest {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  margin: auto;
  border: 1px solid #d9ae58;
  border-radius: 50%;
  background: radial-gradient(circle, #105237, #041810 72%);
  box-shadow: 0 0 40px #e4a5415e, inset 0 0 12px #e4a54138;
}
.crest img { filter: drop-shadow(0 5px 10px #000); }
.menu h1 {
  font-size: clamp(64px, 13vw, 122px);
  letter-spacing: -.075em;
  padding-right: .075em;
  margin-top: 5px;
  line-height: 1.04;
  color: #ffd071;
  background: linear-gradient(#fff5cb 18%, #f7d688 42%, #bb7429 80%, #e9af54 91%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #3c250e) drop-shadow(0 8px 10px #000);
}
.menu h1 span { font-size: .72em; letter-spacing: -.04em; }
.rule {
  height: 10px;
  margin: 8px auto 12px;
  width: min(75%, 390px);
  display: flex;
  align-items: center;
  gap: 6px;
}
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.rule::after { transform: scaleX(-1); }
.rule i { width: 8px; height: 8px; transform: rotate(45deg); background: #f3ce76; box-shadow: 0 0 9px #f3ce76; }
.realm {
  font: 700 clamp(13px, 3.5vw, 17px) Georgia, serif;
  letter-spacing: .24em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px #000;
}
.menu-actions { width: min(280px, 90%); display: grid; gap: 12px; margin: 32px auto 16px; }
.gold {
  border: 2px solid #d5a352;
  border-radius: 8px;
  min-height: 46px;
  padding: 8px 14px;
  background: linear-gradient(#134432, #07241b);
  box-shadow: inset 0 0 0 2px #171b10, inset 0 0 0 3px #b989464a, 0 3px 10px #0008;
  font: 700 17px Georgia, serif;
  text-shadow: 0 2px 2px #000a;
}
.gold:hover:not(:disabled) { border-color: #ffe3a1; filter: brightness(1.18); }
.gold:active:not(:disabled) { transform: translateY(1px); }
.gold.primary {
  min-height: 56px;
  background: radial-gradient(ellipse at top, #198a5b, #0b4c36 62%, #082d23);
  border-color: #f6cb75;
  font-size: 24px;
}
.campaign { min-height: 20px; color: #deebd9; font-size: 13px; text-shadow: 0 2px 6px #000; }

.game {
  --width: min(100%, max(360px, min(546px, calc(100dvh - 228px))));
  width: min(100%, 580px);
  display: grid;
  justify-items: center;
  padding: 8px 10px 4px;
  background: radial-gradient(ellipse at center, #04180fcd 38%, #04180f50 76%, transparent);
}
.level-title { text-align: center; padding: 1px 0 8px; text-shadow: 0 2px 6px #000; }
.stage { font-size: 11px; font-weight: 800; color: #ffe09a; letter-spacing: .18em; text-transform: uppercase; }
.level-title h1 { font-size: clamp(21px, 5vw, 30px); line-height: 1.05; color: #fff0c0; }
.level-title h1:focus { outline: none; }
.hud, .board-frame, .game-tools { width: var(--width); }
.hud {
  display: grid;
  grid-template-columns: minmax(55px, .75fr) minmax(0, 2.5fr) minmax(55px, .75fr);
  gap: 5px;
  margin-bottom: 7px;
}
.stat, .objectives {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 68px;
  background: linear-gradient(170deg, #0c3023, #061b13 78%);
  border: 1px solid #ae863e;
  border-radius: 7px;
  box-shadow: inset 0 0 0 2px #debd6624, 0 4px 12px #0009;
}
.stat span, .objectives h2 {
  font: 800 10px system-ui, sans-serif;
  color: #e3cd9c;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.stat strong { font: 700 clamp(21px, 5vw, 31px) Georgia, serif; font-variant-numeric: lining-nums tabular-nums; }
.moves strong { color: #ffda83; }
.targets { display: flex; justify-content: center; width: 100%; }
.goal {
  min-width: 0;
  width: 72px;
  max-width: 34%;
  display: grid;
  place-items: center;
  font-size: clamp(13px, 3.4vw, 16px);
  line-height: 1.05;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #fff1cf;
}
.goal + .goal { border-left: 1px solid #8e74454f; }
.goal img { width: 30px; height: 30px; object-fit: contain; }
.score-symbol { color: #ffd47d; font-size: 26px; line-height: 30px; }
.goal.done { color: #a1f9ba; }
.board-frame {
  padding: 5px;
  border-radius: 10px;
  background: linear-gradient(148deg, #ffdf8d, #82521b 22%, #e4b65d 44%, #5f3613 75%, #d4a350 92%);
  box-shadow: 0 0 0 1px #2a1807, 0 0 0 2px #d6a257, 0 14px 35px #000b;
}
.board {
  --gap: 2px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: var(--gap);
  padding: var(--gap);
  touch-action: none;
  user-select: none;
  background: #031810;
  border-radius: 6px;
  overflow: hidden;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid #2d73545e;
  border-radius: 4px;
  background: radial-gradient(ellipse at 45% 35%, #214d37, #0c2e22 83%);
}
.cell.alternate { background: radial-gradient(ellipse at 45% 35%, #1a412e, #09271d 83%); }
.cell[data-terrain="gap"] { border-color: transparent; background: #02130e; }
.cell[data-terrain="gate"] {
  border-color: #ae8148;
  background: repeating-linear-gradient(135deg, #302b25 0 5px, #1c1a17 5px 10px);
}
.cell[data-terrain="key"] { box-shadow: inset 0 0 0 2px #74fff0; }
.cell[data-overlay="ice"] {
  border-color: #9bd8fa;
  background: linear-gradient(144deg, #d2f9ffae 0 13%, transparent 29% 77%, #7bd7ff9e 92%),
    radial-gradient(ellipse at 45% 35%, #2e5e69, #122c3c 82%);
}
.cell[data-overlay="spread"] { border-color: #ce84d6; }
.cell img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px #000b);
}
.special-piece {
  position: absolute;
  inset: 2%;
  pointer-events: none;
}
.special-piece[data-direction="row"] img { rotate: 90deg; }
.cell[data-blast]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  animation: blast-flash 115ms ease-out both;
}
.cell[data-blast="row"]::after {
  background: linear-gradient(transparent 29%, #218d80 37%, #feffce 49%, #86fff0 53%, transparent 71%);
}
.cell[data-blast="column"]::after {
  background: linear-gradient(90deg, transparent 29%, #218d80 37%, #feffce 49%, #86fff0 53%, transparent 71%);
}
.cell[data-blast="bomb"]::after {
  background: radial-gradient(circle, #fff4b8 12%, #ffa13e 38%, #cf501a88 64%, transparent 76%);
}
.cell[data-blast="cross"]::after {
  background: linear-gradient(transparent 39%, #91fff0 50%, transparent 61%),
    linear-gradient(90deg, transparent 39%, #ffeda6 50%, transparent 61%);
}
.cell[data-blast="prism"]::after {
  background: radial-gradient(circle, #fff 10%, #fa82ff 29%, #72ffe9 51%, #6178ff66 68%, transparent 76%);
}
.cell[data-blast="prism-rocket"]::after {
  background: linear-gradient(36deg, transparent 30%, #ff88ba 40%, #fff8b4 50%, #72ffda 59%, transparent 71%);
}
.cell[data-blast="prism-bomb"]::after {
  background: radial-gradient(circle, #fff6b1 10%, #ff9461 31%, #f63bcc 53%, #894fff88 68%, transparent 76%);
}
.cell[data-blast="vortex"]::after {
  background: radial-gradient(circle, #fef0ad 9%, #74d7ff 31%, #103cff83 48%, #f0bd52aa 63%, transparent 76%);
}
.cell .vortex-flash {
  position: absolute;
  z-index: 3;
  inset: 0;
  animation: blast-flash 115ms ease-out both;
}
@keyframes blast-flash { from { opacity: .92; } to { opacity: .08; } }
.tile-overlay {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 32%;
  padding-inline: 1px;
  border: 1px solid currentColor;
  border-radius: 4px 0 3px 0;
  background: #05130f;
  line-height: 1.05;
  font-size: clamp(10px, 2.8vw, 15px);
  font-weight: 800;
  pointer-events: none;
}
.tile-overlay[data-obstacle="chain"] { color: #e1e4ef; }
.tile-overlay[data-obstacle="door"] { color: #ffce7d; }
.tile-overlay[data-obstacle="circuit"] { color: #71f3e1; }
.tile-overlay[data-obstacle="corruption"] { color: #ff9bf5; }
.tile-overlay[data-obstacle="ice"] { color: #b5f6ff; background: #113955; border-radius: 5px 1px; }
.tile-overlay[data-obstacle="spread"] { color: #ffc0f7; background: #4c124c; }
.tile-overlay[data-obstacle="gate"], .tile-overlay[data-obstacle="exit"] {
  color: #ffe5a4; border-color: #ffe5a4; background: #173a36;
}
.tile-overlay[data-obstacle="gate"] { inset: 25%; min-width: auto; display: grid; place-items: center; border-radius: 4px; }
.cell:focus-visible { outline-offset: -3px; z-index: 1; }
.cell.moving { z-index: 2; }
.cell[aria-pressed="true"] {
  z-index: 1;
  border-color: #ffe6a7;
  box-shadow: inset 0 0 0 2px #f7c95c, inset 0 0 19px #e9ac6166;
}
@media (hover: hover) {
  .board:not([aria-busy="true"]) .cell:hover { border-color: #d7b05b; }
}
.game-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 45px;
  text-shadow: 0 2px 4px #000;
}
.game-tools p { flex: 1; text-align: right; font-size: clamp(11px, 3vw, 13px); }
#pause { background: #071c15dc; border-color: #a07c43; min-height: 38px; }
footer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 10px 5px;
  gap: 4px;
  font-size: 12px;
  color: #c9ddd1;
  text-align: center;
  text-shadow: 0 2px 4px #000;
}

dialog {
  width: min(420px, calc(100% - 26px));
  max-height: calc(100dvh - 26px);
  padding: 25px 21px 21px;
  color: var(--cream);
  text-align: center;
  border: 2px solid #d9ae58;
  border-radius: 12px;
  background: radial-gradient(ellipse at top, #174534, #071f16 68%);
  box-shadow: 0 0 0 4px #342711, 0 16px 90px #000d;
}
dialog::backdrop { background: #02120cd0; }
dialog h2 { font-size: clamp(23px, 6vw, 33px); padding: 6px 28px; }
dialog p { color: #d2e2d7; font-size: 14px; margin: 2px 0 18px; line-height: 1.4; }
.close { position: absolute; top: 5px; right: 5px; font-size: 22px; }
.dialog-actions { display: grid; gap: 10px; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.levels button { padding-inline: 1px; min-height: 52px; }
.levels .done { color: #9cf1b7; }
.levels button:disabled { opacity: .45; }
.relic-guide { margin: 0; padding-left: 1.2em; text-align: left; font-size: 13px; }
.relic-guide li + li { margin-top: 6px; }
.collection-view { text-align: left; }
.collection-view select, .collection-card button { width: 100%; }
.collection-card {
  padding: 9px;
  border: 1px solid #755b39;
  background: #082a23;
  border-radius: 8px;
}
.collection-card p { margin: 5px 0; }
.collection-item { display: grid; grid-template-columns: 46px 1fr; gap: 8px; align-items: center; }
.collection-item img, .skin-sample img { width: 100%; display: block; }
.collection-item h3, .collection-view h3 { margin: 0; font-size: 1rem; }
.mastery-list { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 0; }
.mastery-list dd { color: #ffe5a4; margin: 0; font-variant-numeric: tabular-nums; }
.skin-preview { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; margin: 8px 0; }
.skin-sample { background: #153828; border: 1px solid #375742; border-radius: 4px; }
[data-skin="bronze"] { --finish-rim: #bb7647; --finish-light: #f1ad7290; --finish-corner: 3px; }
[data-skin="silver"] { --finish-rim: #a5c5d5; --finish-light: #deefffa8; --finish-corner: 7px; }
[data-skin="gold"] { --finish-rim: #ddad5d; --finish-light: #ffdb7890; --finish-corner: 9px; }
[data-skin="obsidian"] { --finish-rim: #8164c8; --finish-light: #af8afa79; --finish-corner: 2px; }
[data-skin="diamond"] { --finish-rim: #7ee7f5; --finish-light: #ccfdff99; --finish-corner: 11px; }
[data-skin="kukulkan"] { --finish-rim: #6ee8a2; --finish-light: #d7c87bc7; --finish-corner: 6px; }
[data-skin]:not([data-skin="default"]) .cell[data-terrain="open"],
[data-skin]:not([data-skin="default"]) .skin-sample {
  border-color: var(--finish-rim);
  border-radius: var(--finish-corner);
  box-shadow: inset 0 -2px 0 var(--finish-light), inset 1px 1px 0 var(--finish-light);
}
[data-skin]:not([data-skin="default"]) .cell[data-terrain="open"][aria-pressed="true"] {
  outline: 2px solid #ffed9e;
  outline-offset: -2px;
}
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
select { min-height: 44px; border-radius: 5px; border: 1px solid var(--gold); padding: 4px; background: #0a2419; color: var(--cream); }
[data-motion="full"] dialog[open] { animation: arrive 160ms ease-out; }
@keyframes arrive { from { opacity: 0; transform: scale(.97); } }
@media (max-width: 560px) {
  body { background-size: auto, auto max(650px, 85dvh); background-repeat: no-repeat; }
  .game { --width: 100%; }
  .hud { gap: 4px; }
  .menu { background: radial-gradient(ellipse at center, #04180fe8 20%, #04180f91 60%, transparent 80%); }
}
@media (max-width: 380px) {
  .game { padding-inline: 6px; }
  .board-frame { padding: 4px; }
}
@media (max-height: 760px) {
  .menu { padding-block: 20px; }
  .game { padding-top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  dialog[open] { animation: none !important; }
}
.history-record { padding: .75rem; border: 1px solid #74643a; border-radius: .5rem; }
.history-record h3 { margin: 0 0 .35rem; color: #f2d38a; font-size: 1rem; }
.history-record p { margin: .25rem 0; font-size: .9rem; overflow-wrap: anywhere; }
