:root {
  --bg-top: #fff7cf;
  --bg-bottom: #ffc95a;
  --panel: rgba(255, 251, 238, 0.9);
  --panel-border: rgba(93, 68, 10, 0.18);
  --text-main: #3c2e0f;
  --text-soft: #725718;
  --accent: #ffb703;
  --accent-strong: #fb8500;
  --track: rgba(99, 74, 9, 0.14);
  --shadow: 0 16px 40px rgba(81, 52, 0, 0.16);
  font-family: "Trebuchet MS", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
}

button {
  font: inherit;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 999px;
  background: rgba(255, 183, 3, 0.2);
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.game-card {
  width: min(100%, 460px);
  display: grid;
  gap: 14px;
}

.game-header,
.status-panel,
.meter-panel,
.guide-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.game-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--text-soft);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.header-copy {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
  text-align: right;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fffdf6;
}

.secondary-button {
  background: rgba(255, 183, 3, 0.16);
  color: var(--text-main);
}

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

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
}

.status-item {
  background: rgba(255, 255, 255, 0.58);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: center;
}

.status-item .label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.meter-panel {
  padding: 12px 14px 14px;
}

.meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.meter-label {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.meter-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd166, #fb8500, #d94841);
  transition: width 80ms linear;
}

.meter-threshold {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  border-radius: 999px;
  background: rgba(60, 46, 15, 0.8);
}

.game-stage-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  box-shadow: var(--shadow);
  aspect-ratio: 9 / 16;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.5), transparent 22%),
    linear-gradient(180deg, #bdeeff, #fef2bf 78%, #e7c875 78%, #d4ae58);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(64, 42, 0, 0.22);
  backdrop-filter: blur(4px);
}

.overlay-card {
  width: min(100%, 328px);
  padding: 22px 20px;
  border-radius: 24px;
  text-align: center;
  background: rgba(255, 251, 241, 0.97);
  color: var(--text-main);
  box-shadow: var(--shadow);
}

.overlay-kicker {
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-card h2 {
  margin: 0 0 10px;
}

.overlay-card p {
  margin: 0 0 14px;
  line-height: 1.5;
}

.overlay-notice {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 183, 3, 0.12);
  color: var(--text-soft);
  font-size: 0.92rem;
}

.overlay-actions {
  display: grid;
  gap: 10px;
}

.guide-panel {
  padding: 16px 18px;
  line-height: 1.55;
}

.guide-panel p {
  margin: 0;
}

.guide-panel p + p {
  margin-top: 8px;
}

@media (max-width: 420px) {
  .app-shell {
    padding: 12px;
  }

  .game-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-copy {
    text-align: left;
  }

  .status-panel {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 900px) {
  .game-card {
    width: min(100%, 520px);
  }
}
