:root {
  color-scheme: dark;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: #e9fbff;
  background: #031c2d;
  --deep: #031c2d;
  --navy: #073b58;
  --sea: #087a9d;
  --cyan: #8cf2ed;
  --foam: #e9ffff;
  --sun: #ffd277;
  --coral: #ff8f8a;
  --line: rgba(190, 244, 248, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--deep); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgba(105, 227, 228, .17), transparent 28rem),
    linear-gradient(160deg, #062d45 0%, #031927 62%, #020f1c 100%);
}

button, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, canvas:focus-visible, a:focus-visible { outline: 3px solid var(--sun); outline-offset: 4px; }

.page-shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; }

.topbar {
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #a9d9df;
  font: 750 .68rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .12em;
}

.workspace-link { color: inherit; text-decoration: none; }
.workspace-link:hover { color: var(--foam); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cef4f7;
  background: rgba(2, 23, 37, .48);
  cursor: pointer;
}
.icon-button:hover { border-color: rgba(140, 242, 237, .7); background: rgba(9, 79, 103, .7); }

main { padding: clamp(28px, 5vw, 62px) 0 48px; }

.hero {
  margin-bottom: clamp(24px, 4vw, 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 420px);
  align-items: end;
  gap: 34px;
}

.eyebrow, .overlay-kicker {
  margin: 0 0 12px;
  color: var(--cyan);
  font: 800 .68rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .16em;
}

h1 {
  margin: 0;
  color: var(--foam);
  font-size: clamp(3.3rem, 9vw, 7.4rem);
  line-height: .87;
  letter-spacing: -.09em;
  text-shadow: 0 12px 45px rgba(38, 213, 219, .2);
}

.hero-copy { margin: 0; color: #b9dfe4; font-weight: 650; line-height: 2; }

.game-panel {
  overflow: hidden;
  border: 1px solid rgba(167, 239, 242, .34);
  border-radius: 24px;
  background: rgba(3, 28, 45, .78);
  box-shadow: 0 30px 80px rgba(0, 10, 20, .42);
}

.run-stats {
  min-height: 76px;
  padding: 13px clamp(16px, 3vw, 30px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.run-stats > div { min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.run-stats > div:nth-child(2) { justify-content: center; }
.run-stats > div:last-child { justify-content: flex-end; }
.run-stats span { color: #8fc1c9; font: 800 .62rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .11em; }
.run-stats strong { color: var(--foam); font-size: clamp(1.2rem, 3vw, 2rem); line-height: 1; }
.run-stats small { color: #9bcbd1; font-weight: 700; }

.sea-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 270px;
  background: #086a8c;
  isolation: isolate;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
#game-canvas.is-gathering { cursor: grabbing; }

.stage-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  padding: clamp(18px, 4vw, 42px);
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, rgba(2, 25, 42, .9), rgba(3, 35, 54, .48) 64%, rgba(3, 41, 59, .16));
  backdrop-filter: blur(3px);
}

.overlay-card { width: min(550px, 100%); }
.overlay-card h2 { margin: 0 0 18px; font-size: clamp(2rem, 5.5vw, 4.8rem); line-height: .98; letter-spacing: -.06em; }
.overlay-card > p:not(.overlay-kicker, .result-score) { max-width: 540px; margin: 0 0 24px; color: #c8e9ec; line-height: 1.9; }
.overlay-card > small { display: block; margin-top: 13px; color: #9bcbd1; font-weight: 700; }

.primary-button {
  min-height: 58px;
  padding: 0 25px;
  border: 0;
  border-radius: 999px;
  color: #03273a;
  background: var(--sun);
  box-shadow: 0 12px 28px rgba(2, 21, 31, .3);
  font-weight: 900;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(2, 21, 31, .38); }

.result-panel { text-align: center; background: rgba(2, 28, 44, .82); }
.result-card { display: grid; justify-items: center; }
.result-score { margin: 0 0 3px; display: flex; align-items: baseline; gap: 9px; }
.result-score strong { color: var(--sun); font-size: clamp(4rem, 12vw, 8.5rem); line-height: .82; letter-spacing: -.1em; }
.result-score span { color: #b6e2e7; font-size: clamp(1.1rem, 3vw, 1.8rem); font-weight: 850; }
.result-time { color: #9bcbd1 !important; font: 800 .72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .1em; }
.result-time strong { color: var(--foam); }
.result-card h2 { margin-bottom: 8px; font-size: clamp(1.6rem, 4vw, 3rem); }
.result-card > p:not(.overlay-kicker, .result-score) { margin-bottom: 18px; }

.stage-callout {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 19px;
  padding: 8px 14px;
  border: 1px solid rgba(230, 255, 255, .4);
  border-radius: 999px;
  color: #eaffff;
  background: rgba(2, 31, 49, .54);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .08em;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.stage-callout.is-visible { opacity: 1; transform: translate(-50%, 0); }

.control-deck {
  min-height: 92px;
  padding: 16px clamp(16px, 3vw, 30px);
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  border-top: 1px solid var(--line);
}

.hold-readout {
  position: relative;
  width: 112px;
  height: 48px;
  overflow: hidden;
  border: 1px solid rgba(168, 237, 241, .24);
  border-radius: 999px;
  background: rgba(1, 18, 30, .48);
}
.hold-readout i { position: absolute; inset: auto 5px 5px; width: 0; height: 4px; border-radius: 99px; background: var(--cyan); box-shadow: 0 0 12px rgba(140, 242, 237, .62); transition: width .08s linear; }
.hold-readout i.is-hot { background: var(--sun); box-shadow: 0 0 16px rgba(255, 210, 119, .88); }
.hold-readout b { position: absolute; z-index: 2; right: 10px; top: 5px; color: #c9f8f6; font: 850 .55rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; }
.hold-bubble { position: absolute; border: 1px solid rgba(225, 255, 255, .78); border-radius: 50%; background: rgba(111, 226, 236, .16); }
.hold-bubble-one { left: 18px; top: 17px; width: 12px; height: 12px; }
.hold-bubble-two { left: 39px; top: 9px; width: 20px; height: 20px; }
.hold-bubble-three { left: 65px; top: 16px; width: 14px; height: 14px; }
.hold-bubble-four { left: 86px; top: 8px; width: 23px; height: 23px; }

.control-instruction { margin: 0 0 6px; color: var(--foam); font-weight: 850; }
.status-line { margin: 0; color: #99cbd2; font-size: .8rem; line-height: 1.45; }
.keyboard-note { margin: 0; color: #87b5bd; font: 700 .68rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
kbd { padding: 4px 7px; border: 1px solid rgba(208, 249, 250, .32); border-bottom-width: 3px; border-radius: 6px; color: #dffbfc; background: rgba(2, 23, 36, .58); font: inherit; }

footer {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #6e9da7;
  font: 700 .6rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .1em;
}

.help-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  padding: clamp(24px, 5vw, 44px);
  overflow: auto;
  border: 1px solid rgba(161, 236, 239, .42);
  border-radius: 24px;
  color: #e8fbfc;
  background: #062d43;
  box-shadow: 0 32px 90px rgba(0, 8, 15, .65);
}
.help-dialog::backdrop { background: rgba(0, 12, 22, .76); backdrop-filter: blur(6px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-close { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; color: white; background: transparent; font-size: 1.5rem; cursor: pointer; }
.help-dialog h2 { margin: 12px 0 28px; font-size: clamp(2rem, 6vw, 4rem); line-height: 1; letter-spacing: -.06em; }
.help-dialog ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 17px; }
.help-dialog li { display: grid; grid-template-columns: 38px 1fr; gap: 13px; }
.help-dialog li > span { color: var(--cyan); font: 850 .72rem/1.8 ui-monospace, SFMono-Regular, Consolas, monospace; }
.help-dialog li p { margin: 0; color: #b9dfe3; line-height: 1.8; }
.keyboard-help { margin: 26px 0 0; color: #8fbfc7; font-size: .82rem; line-height: 1.8; }

@media (max-width: 720px) {
  .page-shell { width: min(100% - 18px, 1180px); }
  .topbar { min-height: 60px; }
  .topbar-actions > span { display: none; }
  .icon-button { min-height: 36px; padding: 0 10px; font-size: .72rem; }
  main { padding-top: 26px; }
  .hero { grid-template-columns: 1fr; gap: 16px; }
  h1 { font-size: clamp(3.6rem, 19vw, 6.2rem); }
  .hero-copy { font-size: .86rem; }
  .run-stats { min-height: 66px; padding-inline: 13px; gap: 8px; }
  .run-stats > div { gap: 4px; }
  .run-stats span { font-size: .51rem; }
  .run-stats strong { font-size: 1.12rem; }
  .run-stats small { font-size: .66rem; }
  .sea-stage { min-height: 360px; aspect-ratio: auto; }
  .stage-overlay { padding: 20px; }
  .overlay-card h2 { font-size: clamp(2rem, 10vw, 3.3rem); }
  .overlay-card > p:not(.overlay-kicker, .result-score) { font-size: .78rem; line-height: 1.65; }
  .primary-button { min-height: 52px; }
  .control-deck { min-height: 88px; grid-template-columns: 78px 1fr; gap: 12px; padding: 13px; }
  .hold-readout { width: 76px; }
  .hold-bubble-one { left: 9px; }
  .hold-bubble-two { left: 25px; }
  .hold-bubble-three { left: 45px; }
  .hold-bubble-four { display: none; }
  .hold-readout b { right: 7px; font-size: .48rem; }
  .keyboard-note { display: none; }
  .control-instruction { font-size: .78rem; }
  .status-line { font-size: .69rem; }
  footer { min-height: 64px; font-size: .48rem; }
  footer span:last-child { display: none; }
}

@media (max-height: 700px) and (min-width: 721px) {
  main { padding-top: 24px; }
  .hero { margin-bottom: 20px; }
  h1 { font-size: clamp(3.3rem, 7vw, 5rem); }
  .sea-stage { max-height: 52vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
