/* Starlight Supper — Dave-the-Diver-inspired chunky cozy arcade look */
:root {
  --ink: #14102a;
  --deep: #1d1740;
  --panel: #2a2158;
  --panel2: #35296e;
  --gold: #ffc857;
  --coral: #ff6b6b;
  --teal: #4ecdc4;
  --mint: #95e06c;
  --lav: #b39ddb;
  --cream: #fff3e2;
  --danger: #ff5470;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  background: var(--ink);
  color: var(--cream);
  overflow: hidden;
  user-select: none;
}
#game-shell { position: relative; width: 100vw; height: 100vh; max-width: 1100px; margin: 0 auto; }
#bg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }

.screen {
  position: absolute; inset: 0; z-index: 2;
  display: none; flex-direction: column; align-items: center;
  padding: 64px 16px 16px; overflow-y: auto;
}
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ---------- Title ---------- */
.title-card {
  margin: auto; text-align: center;
  background: rgba(29,23,64,.88); border: 3px solid var(--gold);
  border-radius: 24px; padding: 36px 40px; box-shadow: 0 12px 60px rgba(0,0,0,.6);
  max-width: 620px;
}
.game-title {
  font-size: clamp(44px, 9vw, 76px); line-height: .95; letter-spacing: 2px;
  color: var(--gold); text-shadow: 4px 4px 0 var(--coral), 8px 8px 0 rgba(0,0,0,.35);
}
.subtitle { color: var(--teal); margin: 10px 0 14px; font-size: 18px; letter-spacing: 4px; text-transform: uppercase; }
.lore-blurb { color: #cfc7f2; font-size: 14px; line-height: 1.55; margin-bottom: 22px; }
.credits { margin-top: 18px; color: #8d84c0; font-size: 11px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-weight: bold; font-size: 15px;
  background: var(--panel2); color: var(--cream);
  border: 2px solid var(--lav); border-radius: 12px;
  padding: 12px 20px; margin: 5px; cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-teal { background: var(--teal); color: var(--ink); border-color: var(--teal); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(20,16,42,.92); border-bottom: 2px solid var(--panel2);
  font-size: 14px; font-weight: bold; gap: 8px; flex-wrap: wrap;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.phase-chip { background: var(--gold); color: var(--ink); border-radius: 999px; padding: 3px 12px; }
.phase-chip.night { background: var(--lav); color: var(--ink); }

/* ---------- Panels / hub ---------- */
.screen-title { font-size: 26px; color: var(--gold); margin-bottom: 14px; text-shadow: 2px 2px 0 rgba(0,0,0,.4); }
.log-box {
  margin-top: 16px; background: rgba(20,16,42,.75); border: 2px solid var(--panel2);
  border-radius: 12px; padding: 12px 16px; font-size: 13px; line-height: 1.5;
  max-width: 720px; width: 94%; max-height: 180px; overflow-y: auto; color: #d8d2f5;
}
.panel-body { width: 100%; max-width: 780px; }
.card {
  background: rgba(42,33,88,.92); border: 2px solid var(--panel2); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px;
}
.card h4 { color: var(--teal); margin-bottom: 6px; font-size: 15px; }
.card p { font-size: 13px; color: #cfc7f2; line-height: 1.45; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.tag { background: var(--deep); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--gold); }
.bar-track { background: var(--deep); border-radius: 999px; height: 10px; overflow: hidden; flex: 1; min-width: 80px; }
.bar-fill { height: 100%; background: var(--mint); border-radius: 999px; transition: width .4s; }

/* ---------- Map ---------- */
.map-desc { color: #cfc7f2; font-size: 14px; margin-bottom: 14px; text-align: center; max-width: 600px; }
.node-btn { min-width: 210px; text-align: left; }
.node-icon { font-size: 22px; margin-right: 6px; }
.node-sub { display: block; font-size: 11px; font-weight: normal; color: #b3aade; }

/* ---------- Battle ---------- */
.battle-stage {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 800px; margin-top: 4px;
}
.battle-enemy, .battle-player { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.battle-vs { font-size: 34px; opacity: .8; }
.unit-bar { width: 240px; }
.unit-name { font-weight: bold; color: var(--gold); font-size: 15px; text-align: center; }
.enemy-bar { text-align: center; }
.hp-track { position: relative; background: #0d0a1f; border: 2px solid var(--panel2); border-radius: 999px; height: 20px; overflow: hidden; margin-top: 4px; }
.hp-fill { height: 100%; background: linear-gradient(90deg, var(--danger), #ff8fa3); transition: width .45s; }
.hp-fill.player { background: linear-gradient(90deg, var(--mint), #d2f5b0); }
.hp-track span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; color: #fff; text-shadow: 1px 1px 2px #000; }
.intent { text-align: center; font-size: 13px; color: var(--teal); margin-top: 5px; min-height: 18px; }
.buffs { text-align: center; font-size: 12px; color: var(--mint); min-height: 16px; }
#player-battle-canvas, #enemy-canvas { image-rendering: auto; filter: drop-shadow(0 8px 14px rgba(0,0,0,.5)); }
.battle-allies { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; justify-content: center; min-height: 44px; }
.ally-chip { background: var(--panel2); border: 2px solid var(--teal); border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; }
.ally-chip.ready:hover { filter: brightness(1.3); }
.ally-chip.used { opacity: .4; cursor: default; }
.battle-log { max-height: 120px; }
.battle-actions { display: flex; flex-wrap: wrap; justify-content: center; max-width: 760px; margin-top: 8px; }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 50%{transform:translateX(8px)} 75%{transform:translateX(-4px)} }
.flash-dmg { animation: flashd .35s; }
@keyframes flashd { 0%,100%{filter:none} 50%{filter:brightness(2.5) saturate(0);} }

/* ---------- Story overlay ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(10,8,24,.82); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.story-card, .menu-card {
  background: var(--panel); border: 3px solid var(--gold); border-radius: 20px;
  padding: 24px; max-width: 640px; width: 100%;
  display: flex; gap: 16px; align-items: flex-start; box-shadow: 0 16px 70px rgba(0,0,0,.7);
  position: relative;
}
.menu-card { flex-direction: column; text-align: center; }
.story-speaker { color: var(--gold); font-weight: bold; font-size: 17px; margin-bottom: 8px; }
.story-text { font-size: 15px; line-height: 1.6; color: var(--cream); }
#story-next { position: absolute; bottom: 14px; right: 14px; min-width: 52px; }
.howto { text-align: left; font-size: 13px; color: #cfc7f2; line-height: 1.55; margin-top: 12px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--deep); border: 2px solid var(--teal); color: var(--cream);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: bold;
  animation: toastin .25s ease-out; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.gold { border-color: var(--gold); }
@keyframes toastin { from { opacity: 0; transform: translateY(-14px) scale(.9);} to { opacity: 1; } }

/* cooking minigame */
.cook-zone { position: relative; height: 46px; background: var(--deep); border-radius: 12px; border: 2px solid var(--panel2); overflow: hidden; margin: 12px 0; }
.cook-target { position: absolute; top: 0; bottom: 0; background: rgba(149,224,108,.35); border-left: 2px solid var(--mint); border-right: 2px solid var(--mint); }
.cook-marker { position: absolute; top: 0; bottom: 0; width: 6px; background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.cook-ticks { font-size: 15px; margin: 6px 0; color: var(--gold); letter-spacing: 4px; }

@media (max-width: 640px) {
  .battle-stage { flex-direction: column; gap: 4px; }
  .battle-vs { display: none; }
  #enemy-canvas { width: 130px; height: 130px; }
  #player-battle-canvas { width: 110px; height: 110px; }
  .unit-bar { width: 200px; }
  #hud { font-size: 12px; }
}

/* ---------- v2: painted assets ---------- */
#planet-bg {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity .8s;
}
#planet-bg.visible { opacity: .55; }
#planet-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,16,42,.25), rgba(20,16,42,.88)); }

.art-img { width: 100%; max-width: 230px; height: auto; border-radius: 18px; box-shadow: 0 10px 26px rgba(0,0,0,.55); object-fit: cover; aspect-ratio: 1; }
.asset-card { display: flex; gap: 14px; align-items: center; }
.dish-art { width: 92px; height: 92px; border-radius: 12px; object-fit: cover; border: 2px solid var(--panel2); flex-shrink: 0; }
.dish-art.wide { width: 150px; height: 96px; }
.asset-body { flex: 1; min-width: 0; }
.worm-icon { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.ally-face { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 4px; }
.cook-card { text-align: center; position: relative; overflow: hidden; }
.cook-scene { position: absolute; right: -30px; bottom: -30px; width: 180px; opacity: .18; border-radius: 20px; transform: rotate(-8deg); }
.big-strike { font-size: 18px; padding: 14px 40px; }

/* title splash */
.title-splash { width: 100%; max-width: 560px; border-radius: 18px; border: 3px solid var(--gold); box-shadow: 0 14px 50px rgba(0,0,0,.6); margin-bottom: 18px; display: block; }

/* ---------- route-graph map ---------- */
#map-nodes { position: relative; width: 94%; max-width: 760px; height: 380px; background: rgba(13,10,31,.65); border: 2px solid var(--panel2); border-radius: 16px; overflow: hidden; }
#map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-node {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--panel2); color: var(--cream);
  border: 2px solid var(--lav); border-radius: 14px;
  padding: 8px 10px; font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 84px; transition: transform .1s, filter .15s;
}
.map-node .node-emoji { font-size: 22px; }
.map-node .node-label { font-size: 10px; font-weight: bold; opacity: .85; white-space: nowrap; }
.map-node.reachable { border-color: var(--gold); box-shadow: 0 0 14px rgba(255,200,87,.35); animation: pulse 1.6s infinite; }
.map-node.reachable:hover { transform: translate(-50%,-50%) scale(1.1); filter: brightness(1.25); }
.map-node.here { border-color: var(--teal); background: var(--deep); }
.map-node.done { opacity: .35; }
.map-node:disabled:not(.here) { cursor: default; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 8px rgba(255,200,87,.25);} 50% { box-shadow: 0 0 20px rgba(255,200,87,.55);} }
.map-foot { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; }

.story-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; width: 100%; }
.story-card { flex-wrap: wrap; }

/* ---------- world screen ---------- */
#screen-world { padding: 58px 8px 8px; justify-content: flex-start; }
.world-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; max-width: 980px; font-size: 13px; font-weight: bold; color: var(--gold); margin-bottom: 6px; flex-wrap: wrap; }
#world-sub { color: #b3aade; font-weight: normal; }
#world-canvas { border-radius: 16px; border: 3px solid var(--panel2); box-shadow: 0 12px 44px rgba(0,0,0,.6); background: #14102f; touch-action: none; }
#touch-stick { display: none; }
@media (pointer: coarse) {
  #touch-stick { display: block; position: absolute; bottom: 26px; left: 26px; width: 110px; height: 110px; border-radius: 50%; background: rgba(42,33,88,.55); border: 2px solid var(--lav); z-index: 6; }
  #stick-knob { position: absolute; left: 33px; top: 33px; width: 44px; height: 44px; border-radius: 50%; background: var(--gold); opacity: .85; }
}
