:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #eeeae0;
  background: #111d25;
  --ink: #eeeae0;
  --muted: #b9c6c4;
  --gold: #f0ce97;
  --panel: #142129ed;
  --faint: #91a6a441;
  --edge: clamp(12px, 2.6vw, 36px);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; overscroll-behavior: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid #f6d9a4; outline-offset: 4px; }
[hidden] { display: none !important; }
#game { width: 100%; height: 100vh; height: 100dvh; overflow: hidden; position: relative; isolation: isolate; }
#world, .vignette { position: absolute; inset: 0; width: 100%; height: 100%; }
#world { display: block; touch-action: none; cursor: grab; }
#world.dragging { cursor: grabbing; }
.vignette { pointer-events: none; background: linear-gradient(#0a121baf, transparent 29%, transparent 68%, #0b131be5), radial-gradient(ellipse at center, transparent 49%, #0b151a58 100%); }
.top { position: absolute; top: var(--edge); left: var(--edge); right: var(--edge); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.top-left, .top-right { display: flex; flex-direction: column; align-items: flex-start; gap: 13px; }
.top-right { align-items: flex-end; gap: 9px; }
.back { pointer-events: auto; color: #dae3da; text-decoration: none; font-size: .75rem; font-weight: 680; padding: 2px 4px; }
.back:hover { color: var(--gold); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand img { width: clamp(36px, 4vw, 49px); height: auto; filter: drop-shadow(0 3px 15px #0c151af0); }
h1, h2, .phase strong { font-family: Georgia, serif; font-weight: 500; }
h1 { margin: 0; font-size: clamp(1.65rem, 3.4vw, 2.7rem); line-height: 1; letter-spacing: -.04em; text-shadow: 0 2px 14px #101c23; }
.eyebrow { display: block; margin: 0; text-transform: uppercase; letter-spacing: .17em; font-size: .63rem; font-weight: 790; color: #adbfbb; }
.brand .eyebrow { color: #d4b992; margin-bottom: 5px; }
.supplies { display: flex; gap: 12px; border: 1px solid var(--faint); border-radius: 12px; background: var(--panel); min-height: 56px; padding: 8px 11px; align-items: stretch; box-shadow: 0 7px 25px #0b111735; }
.coins { padding-left: 11px; border-left: 1px solid var(--faint); min-width: 73px; }
.coins strong { display: block; margin-top: 2px; font-variant-numeric: tabular-nums; }
.coin-icon, .shop-balance span { color: var(--gold); }
#plant-icons { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
#plant-icons svg { width: 18px; height: 19px; color: #afd984; filter: drop-shadow(0 0 3px #9ac57065); }
#plant-icons svg.lost { color: #748382; opacity: .36; filter: none; }
.help-button { pointer-events: auto; width: 35px; height: 35px; padding: 0; border-radius: 10px; border: 1px solid var(--faint); background: var(--panel); color: var(--gold); font-weight: 720; }
.help-button:hover { background: #293840; }
.map-wrap { min-width: 148px; padding: 9px 9px 7px; border-radius: 12px; background: var(--panel); border: 1px solid var(--faint); box-shadow: 0 7px 25px #0b111740; text-align: center; }
#map { display: block; width: 141px; height: auto; margin: 3px auto 0; }
.map-key { color: var(--muted); font-size: .56rem; display: flex; align-items: center; gap: 4px; justify-content: center; white-space: nowrap; }
.map-key i { margin-left: 3px; width: 5px; height: 5px; border-radius: 50%; }
.map-you { background: #d2ede7; } .map-house { background: #e8bf85; } .map-monster { background: #f9a097; }
.middle { position: absolute; top: calc(var(--edge) + 191px); left: var(--edge); display: grid; gap: 9px; max-width: min(255px, 53vw); pointer-events: none; }
.phase { padding: 13px 14px 12px; display: grid; gap: 4px; background: linear-gradient(120deg, #18252ef1, #15212adb); border: 1px solid var(--faint); border-left: 2px solid #bd9b72; border-radius: 9px; }
.phase[data-active="true"] { border-left-color: #f1a693; }
.phase .eyebrow { color: #d9bc96; }
.phase strong { font-size: clamp(1.05rem, 2.1vw, 1.32rem); }
.phase span:last-child, .toast { color: #c4ceca; font-size: .77rem; }
.toast { padding: 8px 10px; background: var(--panel); border: 1px solid var(--faint); border-radius: 8px; }
.bottom { position: absolute; inset: auto var(--edge) max(var(--edge), env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: end; pointer-events: none; }
.bottom button { pointer-events: auto; }
.game-actions { display: grid; gap: 8px; justify-items: center; }
.main-actions, .weapons, .magic-actions { display: flex; gap: 7px; align-items: center; }
.button { min-height: 42px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--faint); font-weight: 770; font-size: .86rem; letter-spacing: .01em; white-space: nowrap; }
.button span { margin-left: 4px; }
.button.primary { color: #252422; border-color: #f3ce92; background: linear-gradient(135deg, #fae0b2, #d1a775); box-shadow: 0 4px 28px #d3a77232, inset 0 1px #fff2ca; }
.button.primary:hover:not(:disabled) { background: #ffe6b3; }
.button.secondary { color: #e7eded; background: #20313aee; }
.button.secondary:hover:not(:disabled) { background: #32434c; }
.button:disabled { opacity: .52; }
.weapons button, .spell { border: 1px solid var(--faint); border-radius: 8px; padding: 6px 7px; background: #17252de9; color: #c7d2d0; font-weight: 710; font-size: .71rem; white-space: nowrap; }
.weapons button:disabled { opacity: .48; }
.weapons button[aria-pressed="true"], .weapons button:hover:not(:disabled), .spell:hover:not(:disabled) { border-color: #c8b28c99; color: #ffe1a8; }
.weapons button .equipped-dot { display: none; }
.weapons kbd { margin-right: 1px; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 19px; padding: 0 3px; border-radius: 4px; border: 1px solid #96a7a766; color: #ecf1eb; background: #2b3b45; font-family: inherit; font-weight: 730; font-size: .67rem; }
.keyboard-guide { color: #d0dbd6; font-size: .73rem; text-shadow: 0 1px 7px #0b1115; }
.keyboard-guide > div { margin: 5px 0 4px; display: flex; gap: 3px; align-items: center; }
.keyboard-guide > div span { margin-left: 4px; }
.keyboard-guide small { color: #b7c5c0; }
.magic-actions { justify-content: end; align-items: end; }
.spell { display: grid; align-items: center; justify-items: center; gap: 4px; padding: 7px 10px; min-width: 64px; color: #f0dcae; }
.spell kbd { font-size: .83rem; min-width: 29px; height: 25px; border-color: #dfbc806c; color: #ffe9bb; background: #3c3d3d; }
.spell.shield kbd { font-size: .63rem; }
.spell:disabled { opacity: .49; }
.spell.ready { border-color: #f6c87caa; background: #3b3834; box-shadow: 0 0 20px #f0c27c27; }
.touch-pad { display: none; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 9px; text-align: center; background: #12202a; padding: 20px; z-index: 2; }
.loading p { margin: 0; font: 1.25rem Georgia, serif; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
dialog { width: min(590px, calc(100% - 24px)); max-height: calc(100% - 22px); border: 1px solid #a9b9ae62; border-radius: 17px; color: var(--ink); padding: 0; background: linear-gradient(145deg, #25363d, #16232b 62%); box-shadow: 0 16px 100px #000a; overflow: auto; }
dialog::backdrop { background: #0b131bd0; backdrop-filter: blur(4px); }
.dialog-content { padding: clamp(17px, 4vw, 30px); position: relative; }
.dialog-content h2 { color: #ffe4b5; font-size: clamp(1.65rem, 5vw, 2.18rem); letter-spacing: -.035em; margin: 6px 0 9px; }
.dialog-content > p:not(.eyebrow) { color: var(--muted); font-size: .89rem; line-height: 1.45; max-width: 52ch; }
.close { position: absolute; top: 13px; right: 13px; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--faint); background: #17252c; color: #e8d5ae; line-height: 1; font-size: 1.25rem; }
.close:hover { border-color: var(--gold); }
.dialog-content .shop-balance { color: #ffdf9d !important; margin: 14px 0 12px; }
.shop-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.shop-tabs button { border: 1px solid var(--faint); background: #182832; color: #d2ddd8; border-radius: 7px; padding: 6px 10px; font-size: .77rem; }
.shop-tabs button[aria-pressed="true"], .shop-tabs button:hover { border-color: #dbb480; color: #ffe6bb; }
.armor-tabs { margin-top: 8px; padding-left: 8px; border-left: 2px solid #a2998060; }
.armor-tabs button { padding: 4px 7px; }
.dialog-content .category-note { font-size: .78rem !important; margin: 9px 0; }
.shop-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.shop-item { --item: #f0ce97; padding: 9px; border: 1px solid #91a6a452; border-left: 2px solid var(--item); border-radius: 8px; background: #151f27; display: grid; gap: 5px; }
.shop-item strong { color: var(--item); font-size: .83rem; }
.shop-item small { color: #bac5c7; font-size: .71rem; }
.shop-item button { text-align: left; border-radius: 5px; border: 1px solid var(--faint); background: #293a40; color: #f6dcb3; font-size: .72rem; padding: 5px 7px; min-height: 31px; }
.shop-item button:hover:not(:disabled) { border-color: var(--item); }
.shop-item button:disabled { opacity: .6; }
.material-card { grid-template-columns: clamp(34px, 8vw, 52px) minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
.item-preview { display: block; width: 100%; height: auto; grid-column: 1; grid-row: 1 / 3; align-self: center; }
.material-card > :is(strong, small) { grid-column: 2; overflow-wrap: anywhere; }
.material-card > button { grid-column: 1 / -1; }
.material-name { display: block; color: #e1dacc; margin-bottom: 2px; }
.plant-card { grid-column: 1 / -1; grid-template-columns: 38px 1fr; }
.plant-card > span { grid-column: 1; grid-row: 1 / 4; place-self: center; color: var(--item); }
.plant-card svg { display: block; width: 26px; height: 26px; }
.plant-card > :not(span) { grid-column: 2; }
.dialog-content .shop-feedback { color: #c3ddae !important; min-height: 1.2em; margin-bottom: 0; font-size: .8rem !important; }
.key-guide { display: grid; gap: 6px; margin: 14px 0; }
.key-guide div { display: grid; grid-template-columns: 110px 1fr; gap: 6px; border-bottom: 1px solid #8d9d9b47; padding: 5px 0; font-size: .8rem; }
.key-guide dt { color: #f2d7aa; font-weight: 710; }
.key-guide dd { color: #c5cdcd; margin: 0; }
.score { display: flex; gap: 13px; margin: 18px 0; }
.score div { border: 1px solid var(--faint); border-radius: 10px; padding: 9px 13px; display: grid; justify-items: center; flex: 1; }
.score strong { color: #f8d69d; font: 1.6rem Georgia, serif; }
.score span { color: var(--muted); font-size: .78rem; }
@media (max-width: 630px) {
  .bottom { gap: 5px; grid-template-columns: .9fr auto .9fr; }
  .brand .eyebrow { letter-spacing: .1em; font-size: .53rem; }
  .middle { top: calc(var(--edge) + 149px); }
  .map-wrap { min-width: 0; padding: 6px; }
  #map { width: 99px; }
  .map-key { display: none; }
  .phase { padding: 7px 8px; }
  .phase span:last-child, .toast { font-size: .69rem; }
  .bottom .button { padding: 7px 8px; min-height: 36px; font-size: .73rem; }
  .weapons { gap: 3px; }
  .weapons button { padding: 4px 4px; font-size: .64rem; }
  .spell { padding: 5px 6px; min-width: 0; font-size: .65rem; }
  .magic-actions { gap: 4px; flex-wrap: wrap; }
  .keyboard-guide > div span, .keyboard-guide small { display: none; }
  .keyboard-guide kbd { padding: 0 2px; min-width: 13px; }
}
@media (max-height: 500px) {
  .top-left { gap: 5px; }
  .top-right { gap: 4px; }
  .map-key { display: none; }
  #map { width: 103px; }
  .map-wrap { min-width: 0; }
  .middle { top: calc(var(--edge) + 126px); }
}
@media (pointer: coarse) {
  .keyboard-guide { display: none; }
  .touch-pad { display: grid; grid-template-columns: repeat(3, minmax(25px, 32px)); gap: 3px; }
  .touch-pad button { min-height: 29px; border-radius: 6px; border: 1px solid var(--faint); background: #243741db; touch-action: none; color: #edf2e7; }
  .touch-pad button:first-child { grid-column: 2; }
  .touch-pad button:nth-child(2) { grid-column: 1; }
  .touch-pad button:active { background: #61717a; }
}
