:root {
  color-scheme: dark;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #061216;
  color: #eef7ed;
  touch-action: none;
}

* { box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; margin: 0; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #17343b, #050d10 70%);
}

button { font: inherit; color: inherit; }

#game-shell { position: relative; width: 100%; height: 100%; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

#hud-toggle { position:absolute; z-index:8; left:max(16px,env(safe-area-inset-left)); top:72px; padding:7px 11px; border:1px solid rgba(220,240,225,.14); border-radius:999px; background:rgba(5,17,19,.76); box-shadow:0 7px 20px rgba(0,0,0,.2); color:#b9cbc5; font-size:10px; pointer-events:auto; cursor:pointer; backdrop-filter:blur(10px); transition:top .2s,background .2s; }
#game-shell.ui-collapsed #hud-toggle { top:max(16px,env(safe-area-inset-top)); background:rgba(216,180,108,.16); color:#f0d494; }
#game-shell.ui-collapsed #hud .top-row,
#game-shell.ui-collapsed #hud .stats,
#game-shell.ui-collapsed #hud .management,
#game-shell.ui-collapsed #hud #quest-card { display:none; }

#hud { position: absolute; inset: 0; pointer-events: none; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); }
.top-row { position:absolute; right:max(16px,env(safe-area-inset-right)); top:max(14px,env(safe-area-inset-top)); display:flex; justify-content:flex-end; align-items:flex-start; gap:12px; }
.day-card, .inventory, .stats, #message {
  background: rgba(5, 17, 19, .72); border: 1px solid rgba(220, 240, 225, .14);
  box-shadow: 0 10px 30px rgba(0,0,0,.22); backdrop-filter: blur(12px);
}
.day-card { display:none; }
.day-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.day-card span { font-size: 12px; color: #9fb9ae; display: block; }
.day-card strong { font-size: 19px; }
#sound-button { pointer-events:auto; width:28px; height:28px; padding:0; border:1px solid rgba(231,210,155,.22); border-radius:50%; background:rgba(216,180,108,.1); color:#edd394; font-size:12px; cursor:pointer; }
#sound-button[aria-pressed="false"] { border-color:rgba(220,240,225,.11); background:rgba(255,255,255,.035); color:#82958f; }
.clock-track { height: 3px; margin-top: 8px; background: #26383b; border-radius: 2px; overflow: hidden; }
.clock-track i { display:block; width: 0; height:100%; background:#f2c66d; }
.inventory { display:flex; gap:13px; padding:8px 11px; border-radius:15px; font-size:14px; align-items:center; }
.inventory button { pointer-events:auto; border:0; border-left:1px solid rgba(255,255,255,.13); padding:3px 0 3px 11px; background:none; cursor:pointer; }
.inventory #sound-button { padding:0; border:1px solid rgba(231,210,155,.22); }
.inventory .icon-button { width:30px; height:28px; padding:0; border-left:0; border-radius:9px; background:rgba(216,180,108,.12); font-size:17px; }
#map-button b { display:none; }

.stats { position:absolute; left:max(16px,env(safe-area-inset-left)); top:max(14px,env(safe-area-inset-top)); width:min(560px,calc(100vw - 430px)); display:grid; grid-template-columns:repeat(4,minmax(82px,1fr)); gap:11px; border-radius:15px; padding:10px 12px; }
.stats div { display:grid; grid-template-columns:32px 1fr; gap:7px; align-items:center; margin:0; }
.stats span { font-size:11px; color:#bdd0c7; }
.stats i { height:6px; border-radius:5px; overflow:hidden; background:#233539; }
.stats b { display:block; height:100%; width:100%; background:#73c79b; transition: width .25s; }
.stats div:nth-child(2) b { background:#e4b66e; }
.stats div:nth-child(3) b { background:#6db8d0; }
.stats div:nth-child(4) b { background:#f1d66d; }
.stat-help { display:none; }

#minimap-button { display:none !important; }
#minimap { display:block; width:100%; aspect-ratio:39/25; border-radius:7px; background:#071315; }
#minimap-button span { display:block; margin-top:4px; color:#91aaa1; font-size:9px; }
.management { position:absolute; right:max(16px,env(safe-area-inset-right)); top:66px; width:170px; display:grid; grid-template-columns:1fr; gap:7px; pointer-events:auto; }
.management::before { display:none; }
.management button { padding:9px 10px; border:1px solid rgba(227,198,119,.2); border-radius:11px; background:rgba(5,17,19,.8); box-shadow:0 8px 22px rgba(0,0,0,.2); text-align:left; font-size:11px; cursor:pointer; }
.management b { float:right; color:#e1c477; font-size:10px; }
#quest-card { position:absolute; left:max(16px,env(safe-area-inset-left)); top:116px; width:220px; padding:12px 13px; border:1px solid rgba(227,198,119,.22); border-radius:14px; background:rgba(5,17,19,.78); box-shadow:0 8px 24px rgba(0,0,0,.22); }
#quest-card span,#quest-card strong,#quest-card small { display:block; }
#quest-card span { color:#d9bd73; font-size:9px; letter-spacing:.08em; }
#quest-card strong { margin:5px 0 3px; font-size:12px; }
#quest-card small { color:#9bb0a8; font-size:10px; line-height:1.45; }
.guide-focus { animation:guidePulse 1.15s ease-in-out infinite; outline:2px solid rgba(245,204,99,.65); outline-offset:3px; }
@keyframes guidePulse { 50% { transform:scale(1.05); box-shadow:0 0 26px rgba(245,204,99,.36); } }

#message { position:absolute; left:50%; top:72px; transform:translateX(-50%); margin:0; padding:9px 16px; border-radius:999px; font-size:13px; text-align:center; max-width:48vw; transition:opacity .3s; }
#phase-toast { position:absolute; z-index:30; left:50%; top:18%; transform:translate(-50%,-12px); padding:11px 22px; border:1px solid rgba(243,205,113,.42); border-radius:999px; background:rgba(5,17,19,.9); color:#f3d17b; box-shadow:0 14px 40px rgba(0,0,0,.38); font-family:Georgia,"Times New Roman",serif; font-size:18px; letter-spacing:.08em; opacity:0; visibility:hidden; transition:.3s; }
#phase-toast.visible { opacity:1; visibility:visible; transform:translate(-50%,0); }
#home-guide { position:absolute; left:50%; bottom:112px; transform:translateX(-50%); display:grid; grid-template-columns:32px auto; align-items:center; column-gap:8px; padding:8px 14px; border:1px solid rgba(240,204,112,.36); border-radius:14px; background:rgba(7,22,23,.84); box-shadow:0 8px 25px rgba(0,0,0,.3); }
#home-guide b { grid-row:1/3; color:#f1cc72; font-size:28px; line-height:1; text-align:center; }
#home-guide span { color:#f2e4ba; font-size:12px; font-weight:700; }
#home-guide small { color:#93aaa1; font-size:9px; }

#controls { position:absolute; inset:0; pointer-events:none; }
#joystick { position:absolute; left:max(24px, env(safe-area-inset-left)); bottom:max(24px, env(safe-area-inset-bottom)); width:118px; height:118px; border-radius:50%; background:rgba(4,15,17,.45); border:1px solid rgba(255,255,255,.14); pointer-events:auto; touch-action:none; }
#stick { position:absolute; left:34px; top:34px; width:50px; height:50px; border-radius:50%; background:rgba(225,240,229,.38); box-shadow:0 5px 14px rgba(0,0,0,.25); transform:translate(0,0); }
.actions { position:absolute; right:max(20px, env(safe-area-inset-right)); bottom:max(22px, env(safe-area-inset-bottom)); display:flex; align-items:flex-end; gap:10px; pointer-events:auto; }
.actions button { width:62px; height:62px; border-radius:50%; border:1px solid rgba(255,255,255,.18); background:rgba(5,20,22,.66); font-size:22px; box-shadow:0 6px 18px rgba(0,0,0,.25); }
.actions button:active { transform:scale(.94); }
.actions small { display:block; font-size:10px; color:#c9d9d2; line-height:10px; }
.actions .primary { width:80px; height:80px; background:rgba(208,154,68,.84); border-color:#f2ca82; color:white; }

.panel { position:absolute; inset:0; z-index:10; display:none; flex-direction:column; align-items:center; justify-content:center; padding:24px; text-align:center; background:radial-gradient(circle at 50% 42%, rgba(23,55,58,.84), rgba(3,12,14,.98) 68%); }
.panel.visible { display:flex; }
.eyebrow { color:#d8b46c; font-size:11px; letter-spacing:.26em; font-weight:700; margin:0 0 10px; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight:500; font-size:clamp(42px, 7vw, 76px); margin:0; text-shadow:0 6px 28px rgba(0,0,0,.5); }
h2 { font-size:clamp(34px, 6vw, 60px); }
.intro { color:#b9cbc5; font-size:14px; line-height:1.75; margin:16px 0 24px; }
.mode-grid { display:flex; gap:10px; width:min(680px, 94vw); }
.mode { flex:1; padding:17px 8px; border-radius:18px; border:1px solid rgba(255,255,255,.12); background:rgba(255,255,255,.045); cursor:pointer; transition:.2s; }
.mode span { display:block; font-size:26px; margin-bottom:7px; }
.mode strong, .mode small { display:block; }
.mode small { margin-top:4px; color:#88a29a; font-size:11px; }
.mode.selected { border-color:#d8b46c; background:rgba(216,180,108,.12); transform:translateY(-3px); }
.start { margin-top:22px; border:0; border-radius:999px; padding:14px 35px; background:#d6ad63; color:#142126; font-weight:800; cursor:pointer; box-shadow:0 8px 24px rgba(0,0,0,.35); }
.new-game { margin-top:10px; padding:9px 18px; border:1px solid rgba(216,180,108,.34); border-radius:999px; background:rgba(216,180,108,.08); color:#d9c48e; font-size:11px; cursor:pointer; }
.help { color:#718983; font-size:11px; margin-top:18px; }

.story-panel { position:absolute; inset:0; z-index:20; display:none; align-items:center; justify-content:center; padding:20px; background:rgba(2,10,12,.74); backdrop-filter:blur(8px); }
.story-panel.visible { display:flex; }
.story-card { width:min(560px, 92vw); max-height:85vh; overflow:auto; padding:28px; border:1px solid rgba(231,210,155,.25); border-radius:22px; background:linear-gradient(145deg,rgba(19,41,42,.98),rgba(7,21,24,.98)); box-shadow:0 25px 80px rgba(0,0,0,.55); }
.story-card h3 { margin:2px 0 14px; font-family:Georgia,"Times New Roman",serif; font-size:30px; font-weight:500; }
#story-copy { color:#c8d6d0; font-size:14px; line-height:1.8; white-space:pre-line; }
.story-choices { display:grid; gap:9px; margin-top:20px; }
.story-choices button { padding:13px 15px; border-radius:13px; border:1px solid rgba(228,199,126,.3); background:rgba(228,199,126,.08); text-align:left; cursor:pointer; }
.story-choices button:hover { background:rgba(228,199,126,.16); }
.story-card .start { margin-top:20px; }
.map-card { width:min(720px,94vw); }
#map-canvas { display:block; width:100%; height:auto; aspect-ratio:39/25; margin:14px 0; border-radius:12px; background:#071315; border:1px solid rgba(231,210,155,.16); }
#map-status { color:#b9cbc5; font-size:13px; line-height:1.6; }

@media (max-width: 650px) {
  .top-row { top:max(66px,calc(env(safe-area-inset-top) + 54px)); right:max(10px,env(safe-area-inset-right)); }
  #sound-button { min-width:28px; width:28px; padding:0; font-size:11px; }
  .inventory { gap:7px; padding:6px 8px; font-size:11px; }
  .inventory button { padding-left:5px; }
  .inventory .icon-button { padding:0; }
  #message { top:112px; max-width:62vw; font-size:11px; }
  #hud-toggle { top:68px; left:max(10px,env(safe-area-inset-left)); }
  .stats { left:max(10px,env(safe-area-inset-left)); right:max(10px,env(safe-area-inset-right)); top:max(10px,env(safe-area-inset-top)); width:auto; grid-template-columns:repeat(4,minmax(0,1fr)); gap:7px; padding:8px; }
  .stats div { grid-template-columns:27px 1fr; gap:4px; }
  .stats span { font-size:9px; }
  .stats i { height:5px; }
  #joystick { width:104px; height:104px; }
  #stick { left:30px; top:30px; width:44px; height:44px; }
  .actions button { width:54px; height:54px; }
  .actions .primary { width:68px; height:68px; }
  .mode-grid { gap:6px; }
  .mode { padding:12px 4px; }
  .mode strong { font-size:12px; }
  .management { top:108px; width:128px; padding-top:0; gap:6px; }
  .management button { padding:8px; font-size:10px; }
  #quest-card { top:150px; width:150px; padding:9px; }
  #quest-card strong { font-size:11px; }
  #phase-toast { top:20%; font-size:16px; white-space:nowrap; }
}

@media (orientation: portrait) {
  .mode-grid { max-width:420px; }
  h1 { font-size:45px; }
}
