:root {
  --ink: #dff8ff;
  --muted: #86a6b8;
  --night: #030913;
  --panel: rgba(7, 21, 35, 0.92);
  --line: rgba(123, 199, 224, 0.17);
  --cyan: #45ddff;
  --cyan-bright: #a8f4ff;
  --blue: #168de2;
  --gold: #ffc857;
  --danger: #ff5f67;
  --green: #4ee3a4;
  --font-display: "Barlow Condensed", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; background: #02070d; color: var(--ink); }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 50% -20%, rgba(24, 108, 151, 0.23), transparent 38%),
    linear-gradient(150deg, #07111c 0%, #02060b 75%);
}

button { font: inherit; }

.game-shell { width: 100vw; height: 100dvh; min-height: 640px; display: grid; grid-template-rows: 72px 1fr; }

.topbar {
  z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  border-bottom: 1px solid var(--line); background: rgba(3, 10, 17, 0.9); backdrop-filter: blur(18px);
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: var(--cyan); font-size: 30px; text-shadow: 0 0 18px var(--cyan); }
.brand p, .brand h1 { margin: 0; }
.eyebrow { color: #83e9ff; font-family: var(--font-display); font-weight: 700; letter-spacing: .19em; font-size: .72rem; }
.brand h1 { font-family: var(--font-display); font-size: 1.65rem; letter-spacing: .06em; line-height: .9; }

.world-meta { display: flex; align-items: center; height: 100%; }
.meta-item { min-width: 170px; padding: 0 22px; border-left: 1px solid var(--line); }
.meta-item span, .day-panel span, .rank { display: block; color: var(--muted); font: 700 .66rem/1 var(--font-body); letter-spacing: .13em; }
.meta-item strong { display: block; margin-top: 6px; font-size: .86rem; }
.meta-item.seed { min-width: 108px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--cyan); background: rgba(32, 116, 151, .1); cursor: pointer; font-size: 1.25rem; transition: .2s; }
.icon-button:hover { transform: rotate(45deg); border-color: var(--cyan); box-shadow: 0 0 16px rgba(69,221,255,.18); }

.play-layout { min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr) 230px; gap: 1px; background: var(--line); }
.left-rail, .right-rail { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #24546a transparent; background: rgba(2, 9, 15, .96); padding: 14px; display: flex; flex-direction: column; gap: 11px; }
.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(12, 34, 50, .94), rgba(5, 17, 28, .94)); box-shadow: inset 0 1px rgba(255,255,255,.025), 0 14px 30px rgba(0,0,0,.12); }

.hero-card { padding: 12px; display: flex; align-items: center; gap: 12px; }
.hero-portrait { width: 64px; height: 64px; flex: 0 0 auto; overflow: hidden; border-radius: 9px 22px 9px 22px; background: radial-gradient(circle, #2475a3, #071521 67%); border: 1px solid #2b7a98; position: relative; }
.portrait-sprite { position: absolute; inset: 3px; background: url("./assets/slime-creatures.png") left center / 500% auto no-repeat; filter: drop-shadow(0 0 8px #3bd9ff); }
.hero-card h2 { margin: 3px 0; font: 800 1.42rem/1 var(--font-display); letter-spacing: .03em; }
.hero-card p { margin: 0; color: var(--muted); font-size: .78rem; }
.rank { color: var(--cyan); }

.vitals { padding: 14px; }
.meter-label { display: flex; justify-content: space-between; margin: 0 0 6px; color: #a9bdc8; font-size: .7rem; }
.meter-label b { color: var(--ink); }
.meter { height: 7px; margin-bottom: 13px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.065); }
.meter i { display: block; height: 100%; width: 100%; border-radius: inherit; transition: width .25s ease; }
.meter.hp i { background: linear-gradient(90deg, #e43750, #ff6877); box-shadow: 0 0 10px #ff4e63; }
.meter.mana i { background: linear-gradient(90deg, #1b78e6, #59d9ff); box-shadow: 0 0 10px #279eef; }
.meter.xp { margin-bottom: 0; height: 5px; }
.meter.xp i { width: 0; background: linear-gradient(90deg, #d6972d, #ffe08a); }
.xp-label { margin-top: 4px; }

.quest, .controls, .threat, .stats, .discoveries { padding: 14px; }
.panel h3 { margin: 0; font: 800 .86rem/1 var(--font-display); letter-spacing: .09em; }
.panel-heading { display: flex; align-items: center; gap: 8px; }
.quest-rune, .danger-rune { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #14202b; background: var(--gold); font-weight: 900; }
.danger-rune { color: white; background: #a72939; }
.quest p { margin: 12px 0 10px; color: #c3d4dd; font-size: .78rem; line-height: 1.5; }
.quest-progress { height: 4px; background: #243240; overflow: hidden; }
.quest-progress i { display: block; width: 0; height: 100%; background: var(--gold); transition: width .3s; }
.quest > strong { display: block; margin-top: 7px; text-align: right; color: var(--gold); font-size: .67rem; }
.controls { margin-top: auto; }
.controls h3 { color: var(--muted); margin-bottom: 10px; }
.controls p { margin: 7px 0; color: #7592a3; font-size: .63rem; white-space: nowrap; }
kbd { display: inline-block; min-width: 20px; padding: 3px 5px; border: 1px solid #34637a; border-bottom-color: #183847; border-radius: 3px; color: #bcecf7; background: #0c2735; font: 700 .58rem var(--font-body); text-align: center; box-shadow: 0 2px 0 #03121a; }

.game-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0b312b; isolation: isolate; }
#gameCanvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.stage-vignette { pointer-events: none; position: absolute; inset: 0; box-shadow: inset 0 0 120px 28px rgba(1,6,12,.62); z-index: 2; }
.objective-chip { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 13px; border: 1px solid rgba(255,210,109,.28); border-radius: 4px; background: rgba(7,17,24,.84); backdrop-filter: blur(8px); box-shadow: 0 7px 22px rgba(0,0,0,.3); }
.objective-chip span { color: var(--gold); font-size: .58rem; letter-spacing: .13em; }
.objective-chip b { font-size: .69rem; }
.combo { position: absolute; top: 64px; left: 50%; translate: -50% 0; z-index: 5; color: var(--gold); font: 800 1.5rem var(--font-display); text-shadow: 0 2px 8px #000; }
.interaction { position: absolute; left: 50%; bottom: 116px; translate: -50% 10px; z-index: 6; padding: 8px 12px; border: 1px solid rgba(123,199,224,.25); border-radius: 4px; background: rgba(3,12,19,.9); font-size: .7rem; opacity: 0; transition: .2s; pointer-events: none; }
.interaction.show { opacity: 1; translate: -50% 0; }

.minimap-wrap { position: absolute; top: 15px; right: 15px; z-index: 5; width: 190px; padding: 7px; background: rgba(3,15,23,.85); backdrop-filter: blur(8px); }
.minimap-title { display: flex; justify-content: space-between; margin: 1px 2px 6px; font: 700 .53rem var(--font-body); letter-spacing: .08em; color: #83a8b8; }
.minimap-title b { color: var(--cyan-bright); }
#minimap { display: block; width: 100%; height: 128px; background: #0d2831; }

.skill-dock { position: absolute; z-index: 6; left: 50%; bottom: 18px; translate: -50% 0; display: flex; gap: 8px; padding: 8px; border: 1px solid var(--line); background: rgba(3,13,21,.87); backdrop-filter: blur(10px); box-shadow: 0 12px 35px rgba(0,0,0,.35); }
.skill { position: relative; width: 60px; height: 64px; padding: 0; overflow: hidden; border: 1px solid #24465b; border-radius: 4px; color: #d7f7ff; background: linear-gradient(145deg, #153d53, #081b29); cursor: pointer; transition: .16s; }
.skill:hover, .skill.active { border-color: var(--cyan); translate: 0 -3px; box-shadow: 0 0 14px rgba(65,215,255,.24); }
.skill i { display: block; font: normal 1.42rem/1 var(--font-body); text-shadow: 0 0 8px currentColor; }
.skill small { display: block; margin-top: 5px; color: #93b2c0; font-size: .52rem; }
.skill .key { position: absolute; top: 3px; left: 4px; color: #a8c2ce; font-size: .46rem; font-weight: 800; }
.skill em { position: absolute; inset: auto 0 0; height: 0; background: rgba(1,6,10,.72); transition: height .08s linear; }

.right-rail { padding-left: 13px; padding-right: 13px; }
.day-panel { padding: 13px; display: flex; align-items: center; gap: 10px; }
.day-panel strong { display: block; margin: 5px 0 3px; font: 800 1.18rem var(--font-display); }
.day-panel small { display: block; color: #9cb2bd; font-size: .62rem; }
.sun-orbit { position: relative; width: 52px; height: 52px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(255,200,87,.25); border-radius: 50%; color: var(--gold); }
.sun-orbit::before { content: ""; position: absolute; inset: 6px; border: 1px dashed rgba(255,200,87,.3); border-radius: 50%; animation: spin 12s linear infinite; }
.sun-orbit span { text-shadow: 0 0 12px var(--gold); }
.sun-orbit i { position: absolute; top: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 7px var(--cyan); }
@keyframes spin { to { rotate: 360deg; } }

.threat-list { margin-top: 12px; display: grid; gap: 8px; }
.threat-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 8px; padding: 7px; background: rgba(255,255,255,.025); border-left: 2px solid var(--danger); }
.enemy-thumb { width: 38px; height: 32px; background-image: url("./assets/slime-creatures.png"); background-size: 500% auto; background-repeat: no-repeat; filter: drop-shadow(0 3px 4px rgba(0,0,0,.6)); }
.threat-item:nth-child(1) .enemy-thumb { background-position: 25% center; }
.threat-item:nth-child(2) .enemy-thumb { background-position: 50% center; }
.threat-item:nth-child(3) .enemy-thumb { background-position: 75% center; }
.threat-item strong { display: block; font-size: .7rem; }
.threat-item small { color: var(--muted); font-size: .58rem; }
.threat-count { color: var(--danger); font: 800 .95rem var(--font-display); }
.stats div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.055); color: #91aab7; font-size: .7rem; }
.stats h3, .discoveries h3 { margin-bottom: 6px; color: var(--muted); }
.stats b { color: var(--cyan-bright); }
.stats b.danger-high { color: var(--danger); text-shadow: 0 0 9px rgba(255,95,103,.3); }
.ranged-tag { display: inline-block; margin-left: 5px; padding: 1px 4px; border: 1px solid rgba(255,185,82,.35); color: #ffd27d; font-size: .48rem; letter-spacing: .04em; }
.discovery-row { display: flex; gap: 6px; margin-top: 13px; }
.biome-dot { width: 28px; height: 28px; border: 1px solid #244353; border-radius: 50%; display: grid; place-items: center; color: transparent; background: #081722; font-size: .62rem; }
.biome-dot.found { color: white; border-color: #5696ac; box-shadow: inset 0 0 12px rgba(255,255,255,.1); }
.discoveries p { margin: 9px 0 0; color: #839da9; font-size: .65rem; }
.sound-toggle { margin-top: auto; padding: 11px 12px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); color: #8caab8; background: rgba(14,39,52,.6); cursor: pointer; font-size: .65rem; }
.sound-toggle span { color: var(--cyan); }
.sound-toggle b { margin-left: auto; color: var(--green); }

.overlay { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(12,60,75,.45), rgba(2,8,14,.9)); backdrop-filter: blur(3px); transition: opacity .3s; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.start-content { width: min(560px, calc(100% - 40px)); padding: 40px; text-align: center; border: 1px solid rgba(99,214,239,.28); background: linear-gradient(145deg, rgba(7,26,39,.96), rgba(3,12,20,.97)); box-shadow: 0 30px 90px rgba(0,0,0,.5), inset 0 1px rgba(255,255,255,.04); clip-path: polygon(22px 0, calc(100% - 22px) 0, 100% 22px, 100% calc(100% - 22px), calc(100% - 22px) 100%, 22px 100%, 0 calc(100% - 22px), 0 22px); }
.start-content.compact { max-width: 430px; }
.chapter { margin: 0 0 12px; color: var(--gold); font: 800 .7rem var(--font-body); letter-spacing: .18em; }
.chapter.danger { color: var(--danger); }
.start-content h2, .upgrade-content h2 { margin: 0; color: white; font: 800 clamp(2.7rem, 6vw, 4.8rem)/.86 var(--font-display); letter-spacing: -.03em; text-transform: uppercase; }
.start-content h2 span { color: var(--cyan); text-shadow: 0 0 22px rgba(69,221,255,.28); }
.start-content > p:not(.chapter) { max-width: 450px; margin: 24px auto; color: #a9c1cd; font-size: .86rem; line-height: 1.65; }
.feature-row { display: flex; justify-content: center; gap: 25px; margin-bottom: 24px; }
.feature-row span { color: #87a5b4; font-size: .67rem; text-transform: uppercase; letter-spacing: .08em; }
.feature-row b { margin-right: 4px; color: var(--cyan-bright); font: 800 1.15rem var(--font-display); }
.primary-button { min-width: 210px; padding: 14px 22px; border: 1px solid #8beaff; color: #001019; background: linear-gradient(90deg, #3ccff0, #99f5ff); font: 800 .75rem var(--font-body); letter-spacing: .14em; cursor: pointer; box-shadow: 0 0 28px rgba(64,220,255,.2); transition: .18s; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(64,220,255,.3); }
.primary-button span { margin-left: 12px; font-size: 1rem; }
.start-content > small { display: block; margin-top: 13px; color: #668594; font-size: .6rem; }

.upgrade-content { width: min(850px, calc(100% - 40px)); text-align: center; }
.upgrade-content h2 { font-size: clamp(2.4rem, 5vw, 4rem); }
.upgrade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 26px; }
.upgrade-card { min-height: 210px; padding: 22px 18px; text-align: left; border: 1px solid #23485c; color: var(--ink); background: linear-gradient(150deg, #123347, #071723); cursor: pointer; transition: .18s; }
.upgrade-card:hover { transform: translateY(-6px); border-color: var(--cyan); box-shadow: 0 14px 35px rgba(0,0,0,.35), 0 0 20px rgba(69,221,255,.14); }
.upgrade-card i { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 28px; border: 1px solid #39809c; border-radius: 50%; color: var(--cyan-bright); font-style: normal; font-size: 1.3rem; }
.upgrade-card b { display: block; font: 800 1.25rem var(--font-display); text-transform: uppercase; }
.upgrade-card p { margin: 8px 0 0; color: #91aebc; font-size: .7rem; line-height: 1.5; }

.toast-stack { position: absolute; z-index: 20; top: 78px; left: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 10px 13px; border-left: 3px solid var(--cyan); color: #c7edf5; background: rgba(3,17,25,.93); font-size: .68rem; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toast-in .25s ease both; }
.toast.gold { border-color: var(--gold); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-10px); } }

.touch-controls { display: none; }

@media (max-width: 1050px) {
  .play-layout { grid-template-columns: 220px 1fr; }
  .right-rail { display: none; }
}

@media (max-width: 760px) {
  html, body { overflow: hidden; }
  .game-shell { min-height: 0; grid-template-rows: 58px 1fr; }
  .topbar { padding: 0 12px; }
  .brand-mark { width: 30px; font-size: 22px; }
  .brand h1 { font-size: 1.3rem; }
  .eyebrow { font-size: .55rem; }
  .meta-item { min-width: 0; padding: 0 9px; }
  .meta-item.seed { display: none; }
  .meta-item span { font-size: .5rem; }
  .meta-item strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .66rem; }
  .icon-button { width: 34px; height: 34px; }
  .play-layout { display: block; }
  .left-rail { position: absolute; z-index: 8; top: 68px; left: 8px; padding: 0; width: auto; height: auto; background: transparent; pointer-events: none; }
  .left-rail .hero-card, .left-rail .quest, .left-rail .controls { display: none; }
  .left-rail .vitals { width: 160px; padding: 9px; background: rgba(3,13,20,.84); backdrop-filter: blur(6px); }
  .meter-label { font-size: .56rem; }
  .meter { margin-bottom: 7px; height: 5px; }
  .minimap-wrap { width: 132px; top: 9px; right: 9px; }
  #minimap { height: 90px; }
  .minimap-title { font-size: .43rem; }
  .objective-chip { top: 110px; font-size: .6rem; }
  .skill-dock { bottom: 10px; gap: 4px; padding: 5px; }
  .skill { width: 48px; height: 52px; }
  .skill i { font-size: 1.1rem; }
  .skill small { display: none; }
  .touch-controls { display: block; position: absolute; inset: 0; z-index: 7; pointer-events: none; }
  .joystick { position: absolute; left: 18px; bottom: 80px; width: 88px; height: 88px; border: 1px solid rgba(164,235,250,.2); border-radius: 50%; background: rgba(3,18,27,.35); pointer-events: auto; touch-action: none; }
  .joystick i { position: absolute; left: 28px; top: 28px; width: 32px; height: 32px; border-radius: 50%; background: rgba(108,226,248,.35); border: 1px solid rgba(180,245,255,.5); }
  .touch-action { position: absolute; right: 22px; bottom: 92px; width: 64px; height: 64px; border: 1px solid #6ee8ff; border-radius: 50%; color: #dffaff; background: rgba(13,116,151,.5); pointer-events: auto; font-size: .62rem; font-weight: 800; }
  .touch-action.alt { right: 90px; bottom: 68px; width: 50px; height: 50px; border-color: #ffd374; background: rgba(133,86,12,.5); }
  .start-content { padding: 30px 22px; }
  .feature-row { gap: 12px; }
  .upgrade-grid { grid-template-columns: 1fr; max-height: 62vh; overflow-y: auto; }
  .upgrade-card { min-height: 0; padding: 15px; }
  .upgrade-card i { float: left; margin: 0 15px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
