:root {
  --ink: #12353a;
  --ink-soft: #3a6268;
  --water: #0ea5b7;
  --water-deep: #067b96;
  --sun: #ffd04d;
  --tea: #79c241;
  --paper: rgba(255, 255, 255, 0.9);
  --line: rgba(255, 255, 255, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #8ee8ee 0%, #097f98 100%);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  letter-spacing: 0;
}

body {
  display: grid;
  place-items: center;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: min(100vw, 480px);
  height: 100dvh;
  max-height: 960px;
  overflow: hidden;
  background: #74dbe8;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 24px 80px rgba(3, 77, 91, 0.35);
  touch-action: none;
  user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 10px;
  right: 10px;
  z-index: 4;
  display: grid;
  grid-template-columns: 82px 1fr 82px;
  gap: 8px;
  align-items: stretch;
  pointer-events: none;
}

.stat,
.timer {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 22px rgba(5, 80, 96, 0.18);
  backdrop-filter: blur(10px);
}

.stat {
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 7px 6px 6px;
}

.stat span,
.timer span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.stat strong {
  font-size: 22px;
  line-height: 1;
}

.timer {
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 8px 10px;
  text-align: center;
}

#timeText {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.time-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(18, 53, 58, 0.14);
}

.time-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tea), var(--sun));
  transform-origin: left center;
}

.screen,
.countdown {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: end center;
  padding: calc(env(safe-area-inset-top) + 76px) 14px calc(env(safe-area-inset-bottom) + 16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.screen.is-active,
.countdown.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 116, 133, 0.08) 0%, rgba(6, 84, 100, 0.46) 100%);
}

.panel {
  position: relative;
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 48px rgba(4, 74, 90, 0.26);
  padding: 20px 18px 18px;
  text-align: center;
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--water-deep);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-weight: 950;
  line-height: 1.03;
}

h1 {
  font-size: clamp(34px, 9vw, 48px);
}

h2 {
  font-size: clamp(27px, 7vw, 38px);
}

.lead {
  margin: 13px auto 17px;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.62;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  font-weight: 950;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary-button {
  color: #1d3310;
  background: linear-gradient(180deg, #ffe178 0%, #ffc02f 100%);
  box-shadow: inset 0 -3px 0 rgba(112, 74, 0, 0.18), 0 10px 20px rgba(185, 130, 11, 0.23);
}

.secondary-button {
  color: var(--ink);
  background: #dff7f8;
  border: 1px solid rgba(8, 116, 136, 0.22);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 13px;
}

.tips span {
  border-radius: 999px;
  background: rgba(14, 165, 183, 0.13);
  color: #0a6474;
  font-size: 12px;
  font-weight: 900;
  padding: 6px 9px;
}

.countdown {
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
}

.countdown span {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  color: var(--water-deep);
  font-size: 72px;
  font-weight: 950;
  box-shadow: 0 18px 48px rgba(5, 80, 96, 0.28);
}

.result-score {
  margin: 11px 0 0;
  color: var(--water-deep);
  font-size: 19px;
  font-weight: 950;
}

.result-score span {
  font-size: 48px;
  line-height: 1;
}

.result-actions {
  display: grid;
  gap: 9px;
}

.copy-status {
  min-height: 18px;
  margin: 11px 0 0;
  color: var(--water-deep);
  font-size: 12px;
  font-weight: 900;
}

@media (max-height: 660px) {
  .hud {
    grid-template-columns: 74px 1fr 74px;
  }

  .stat,
  .timer {
    min-height: 48px;
  }

  .panel {
    padding: 16px 14px 14px;
  }

  h1 {
    font-size: 32px;
  }

  .lead {
    margin: 10px auto 13px;
    font-size: 14px;
    line-height: 1.48;
  }
}

@media (min-width: 900px) {
  .game-shell {
    border-radius: 8px;
  }
}
