:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #a9bbca;
  --panel: rgba(8, 25, 42, 0.96);
  --line: rgba(210, 239, 255, 0.16);
  --cyan: #70e9e0;
  --gold: #ffd36a;
  --night: #06121f;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 50% 0%, #193d55 0, #081a2b 46%, #050d17 100%); overscroll-behavior: none; }
body { color: var(--ink); font-family: "Segoe UI", system-ui, sans-serif; display: grid; place-items: center; padding: 22px; }
button { font: inherit; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.game-shell { width: min(1180px, 100%); }
.topbar, .control-strip { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #06202c; background: linear-gradient(135deg, var(--cyan), #d9ff8e); box-shadow: 0 8px 28px rgba(112,233,224,.24); }
.brand div { display: grid; gap: 1px; }
.brand strong { font-size: 1rem; letter-spacing: .02em; }
.brand span:last-child { color: var(--muted); font-size: .78rem; }
.top-actions { display: flex; gap: 8px; }
.site-home, .quiet-button, .icon-button, .shop-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: rgba(10,28,44,.84); cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.22); }
.site-home { display: inline-flex; align-items: center; text-decoration: none; font-weight: 800; }
.site-home:hover, .quiet-button:hover, .icon-button:hover, .shop-button:hover { border-color: rgba(112,233,224,.65); background: rgba(18,46,65,.94); }
.shop-button { color: #fff0a6; border-color: rgba(255,211,106,.32); font-weight: 800; }
.fullscreen-button { display: none; min-height: 40px; padding: 0 12px; border: 1px solid rgba(112,233,224,.32); border-radius: 8px; color: var(--cyan); background: rgba(10,28,44,.84); font-weight: 800; cursor: pointer; }

.stage-wrap { position: relative; overflow: hidden; border: 1px solid rgba(182,232,255,.22); border-radius: 24px; background: #102e43; box-shadow: 0 30px 80px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.04); }
canvas { display: block; width: 100%; aspect-ratio: 16/9; touch-action: none; image-rendering: pixelated; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: linear-gradient(90deg, rgba(3,13,24,.86), rgba(6,20,34,.54)); backdrop-filter: blur(5px); z-index: 5; }
.hidden { display: none !important; }
.start-screen { place-items: center start; }
.start-card, .modal-card { width: min(520px, 100%); padding: clamp(24px, 5vw, 46px); border: 3px solid rgba(193,239,255,.25); border-radius: 10px; background: rgba(7,23,38,.95); box-shadow: 8px 8px 0 rgba(2,9,16,.58), inset 0 0 0 2px rgba(255,255,255,.04); }
.start-card { margin-left: clamp(0px, 5vw, 70px); }
.eyebrow { margin-bottom: 10px; color: var(--cyan); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
h1, h2 { margin: 0; font-family: "Trebuchet MS", system-ui, sans-serif; font-weight: 900; line-height: 1.02; letter-spacing: -.04em; }
h1 { max-width: 460px; font-size: clamp(2.3rem, 6vw, 4.7rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3rem); }
.start-card p, .modal-content { color: #c4d3df; font-size: 1rem; line-height: 1.6; }
.primary-button { border: 2px solid #eaffcb; border-radius: 7px; min-height: 48px; padding: 0 22px; color: #08212b; background: linear-gradient(#baffd1, #65d8c8); font-weight: 900; cursor: pointer; box-shadow: 0 5px 0 #237e7d, 0 10px 28px rgba(112,233,224,.2); }
.primary-button:hover { filter: brightness(1.07); transform: translateY(-1px); }
.small-note { display: block; margin-top: 14px; color: #7f98aa; font-size: .78rem; }
.modal-card { width: min(610px, 100%); }
.modal-content { display: grid; gap: 14px; margin: 20px 0 24px; }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.guide-item { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.guide-item b { display: block; color: white; margin-bottom: 4px; }
.guide-item span { font-size: .84rem; line-height: 1.35; color: var(--muted); }
.shop-head { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:4px; }
.wallet { color:#fff0a6; font-weight:900; white-space:nowrap; }
.shop-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.shop-item { display:grid; grid-template-columns:48px 1fr; gap:10px; align-items:center; padding:12px; border:2px solid rgba(180,229,244,.14); border-radius:8px; background:#0d2b3b; }
.shop-swatch { width:46px; height:46px; display:grid; place-items:center; border:2px solid rgba(255,255,255,.22); border-radius:5px; background:#173f50; font-size:1.45rem; }
.shop-copy b { display:block; color:#f7fbff; font-size:.9rem; }
.shop-copy small { display:block; min-height:30px; margin:3px 0 8px; color:#9fb6c4; line-height:1.25; }
.buy-button { width:100%; min-height:32px; border:1px solid rgba(255,255,255,.16); border-radius:5px; color:#0a2430; background:#ffd978; font-weight:900; cursor:pointer; }
.buy-button[disabled] { color:#72909d; background:#173746; cursor:default; }
.buy-button.equip { color:#dffeff; background:#1c5363; }
.pixel-note { padding:10px 12px; border-left:4px solid #70e9e0; color:#bcd0da; background:rgba(112,233,224,.06); font-size:.85rem; line-height:1.45; }

.announcement { position: absolute; top: 84px; left: 50%; z-index: 4; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; padding: 10px 17px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: white; background: rgba(5,21,34,.88); font-weight: 700; transition: .25s ease; white-space: nowrap; }
.announcement.show { transform: translate(-50%, 0); opacity: 1; }
.rotate-hint { display: none; position: absolute; z-index: 7; top: 10px; left: 50%; width: max-content; max-width: calc(100% - 20px); transform: translateX(-50%); padding: 8px 12px; border: 1px solid rgba(255,211,106,.5); border-radius: 999px; color: #fff0a6; background: rgba(5,21,34,.94); font-size: .78rem; font-weight: 800; text-align: center; pointer-events: none; }
.rotate-hint span { display: inline-block; margin-right: 5px; font-size: 1rem; }

.control-strip { justify-content: center; flex-wrap: wrap; padding: 14px 6px 0; color: var(--muted); font-size: .8rem; }
.control-strip span { display: flex; align-items: center; gap: 5px; }
kbd { min-width: 25px; padding: 4px 6px; border: 1px solid rgba(255,255,255,.15); border-bottom-width: 2px; border-radius: 6px; color: #eafaff; background: rgba(255,255,255,.06); font: 700 .7rem/1 system-ui; text-align: center; }

.touch-controls { display: none; position: absolute; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); z-index: 3; align-items: end; justify-content: space-between; gap: 10px; pointer-events: none; }
.touch-controls button { min-width: 58px; height: 56px; border: 1px solid rgba(255,255,255,.3); border-radius: 15px; color: white; background: rgba(5,23,38,.78); backdrop-filter: blur(6px); box-shadow: 0 4px 12px rgba(0,0,0,.24); font-size: .74rem; font-weight: 850; pointer-events: auto; touch-action: none; }
.touch-controls button:active { transform: translateY(2px); background: rgba(31,91,105,.9); }
.touch-group { display: flex; gap: 7px; margin-right: auto; }
.touch-actions { display: flex; align-items: end; gap: 7px; }
.touch-jump, .touch-ability { border-radius: 50% !important; width: 58px; }

.stage-wrap:fullscreen { width: 100vw; height: 100dvh; border: 0; border-radius: 0; background: #06121f; }
.stage-wrap:fullscreen canvas { width: 100%; height: 100%; aspect-ratio: auto; object-fit: contain; }
.stage-wrap:fullscreen .modal-card { max-height: calc(100dvh - 24px); overflow: auto; }

@media (pointer: coarse), (max-width: 760px) {
  body { padding: 10px; align-content: start; }
  .touch-controls { display: flex; }
  .control-strip { display: none; }
  .topbar { flex-wrap: wrap; margin-bottom: 8px; }
  .brand { width: 100%; }
  .brand span:last-child { display: none; }
  .top-actions { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .quiet-button { display: none; }
  .fullscreen-button.mobile-ready { display: inline-flex; align-items: center; justify-content: center; }
  .site-home, .shop-button, .icon-button, .fullscreen-button { min-width: 0; min-height: 42px; justify-content: center; padding: 0 6px; font-size: .72rem; white-space: nowrap; }
  .stage-wrap { border-radius: 17px; }
  .start-card { margin: 0; padding: 22px; }
  .start-card p { font-size: .9rem; }
  .guide-grid, .shop-grid { grid-template-columns: 1fr; }
  .modal-content { max-height: 48vh; overflow: auto; }
}

@media (pointer: coarse) and (orientation: portrait) {
  .stage-wrap { min-height: min(70dvh, 560px); }
  .stage-wrap canvas { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; }
  .rotate-hint:not(.dismissed) { display: block; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 600px) {
  body.game-running { display: block; padding: 0; overflow: hidden; }
  body.game-running .game-shell { width: 100vw; }
  body.game-running .topbar, body.game-running .control-strip { display: none; }
  body.game-running .stage-wrap { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  body.game-running canvas { width: 100%; height: 100%; aspect-ratio: auto; object-fit: contain; }
  .modal-card { max-height: calc(100dvh - 20px); overflow: auto; }
}

@media (max-width: 420px) {
  .touch-controls { left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right)); gap: 6px; }
  .touch-group, .touch-actions { gap: 5px; }
  .touch-controls button { min-width: 52px; width: 52px; height: 52px; font-size: .68rem; }
  .start-card { padding: 18px; }
  .start-card p { line-height: 1.45; }
}
