:root {
  color-scheme: light;
  --ink: #2c1710;
  --paper: #fff7df;
  --sun: #ffc857;
  --red: #e94b2f;
  --sea: #0d89aa;
  --leaf: #5f8f3a;
  --charcoal: #171411;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(13, 137, 170, 0.32), transparent 44%),
    linear-gradient(20deg, rgba(233, 75, 47, 0.26), transparent 48%),
    #fff1c5;
  color: var(--ink);
  font-family:
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    system-ui,
    sans-serif;
  letter-spacing: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  width: 100vw;
  height: 100svh;
  min-height: 560px;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.game-stage {
  position: relative;
  width: min(100%, calc(100svh * 390 / 844));
  max-width: 440px;
  aspect-ratio: 390 / 844;
  overflow: hidden;
  border: 4px solid rgba(44, 23, 16, 0.82);
  border-radius: 8px;
  background: #8ccde0;
  box-shadow: 0 22px 60px rgba(82, 42, 18, 0.25);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  pointer-events: none;
}

.metric {
  min-width: 0;
  border: 2px solid rgba(44, 23, 16, 0.72);
  border-radius: 8px;
  background: rgba(255, 247, 223, 0.88);
  box-shadow: 0 4px 0 rgba(44, 23, 16, 0.18);
  padding: 6px 4px 5px;
  text-align: center;
}

.metric span {
  display: block;
  color: rgba(44, 23, 16, 0.78);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.metric strong {
  display: block;
  margin-top: 2px;
  color: var(--charcoal);
  font-size: clamp(18px, 5.1vw, 24px);
  font-weight: 950;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-time {
  background: rgba(255, 200, 87, 0.92);
}

.heat-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 86px;
  border: 2px solid rgba(44, 23, 16, 0.74);
  border-radius: 8px;
  background: rgba(255, 247, 223, 0.9);
  box-shadow: 0 5px 0 rgba(44, 23, 16, 0.16);
  padding: 8px 10px 9px;
  pointer-events: none;
}

.heat-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 5px;
  color: rgba(44, 23, 16, 0.72);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

.heat-track {
  position: relative;
  width: 100%;
  height: 16px;
  overflow: hidden;
  border: 2px solid rgba(44, 23, 16, 0.62);
  border-radius: 999px;
  background: linear-gradient(90deg, #fff1ad 0%, #ffb637 48%, #6a2b15 100%);
}

.heat-perfect {
  position: absolute;
  left: 42%;
  top: 0;
  width: 18%;
  height: 100%;
  background: rgba(255, 255, 255, 0.52);
}

.heat-needle {
  position: absolute;
  left: 0;
  top: -4px;
  width: 8px;
  height: 24px;
  border-radius: 6px;
  background: var(--red);
  box-shadow: 0 0 0 2px rgba(255, 247, 223, 0.88);
  transform: translateX(-4px);
}

.judge-text {
  display: block;
  margin-top: 5px;
  color: var(--red);
  font-size: 15px;
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
}

.action-button {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  height: 52px;
  border: 3px solid rgba(44, 23, 16, 0.86);
  border-radius: 8px;
  background: linear-gradient(#ffe07a, #ffad32);
  box-shadow: 0 6px 0 rgba(44, 23, 16, 0.72), 0 18px 28px rgba(77, 38, 13, 0.22);
  color: var(--charcoal);
  cursor: pointer;
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
}

.action-button:active {
  bottom: 16px;
  box-shadow: 0 2px 0 rgba(44, 23, 16, 0.72), 0 12px 20px rgba(77, 38, 13, 0.2);
}

@media (max-height: 650px) {
  .app-shell {
    min-height: 500px;
  }

  .heat-panel {
    bottom: 76px;
  }

  .action-button {
    bottom: 14px;
    height: 48px;
  }
}
