:root {
  color-scheme: light;
  --page-bg: #f4efe4;
  --panel-bg: rgba(255, 250, 245, 0.8);
  --panel-border: rgba(102, 73, 52, 0.14);
  --ink-strong: #35261d;
  --ink-soft: #6b5546;
  --rose: #f3b7cd;
  --rose-deep: #dd7ba4;
  --leaf: #6f8c46;
  --shadow: 0 24px 60px rgba(91, 58, 41, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Apple SD Gothic Neo", sans-serif;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 218, 230, 0.55), transparent 35%),
    linear-gradient(180deg, #fffaf6 0%, var(--page-bg) 100%);
  color: var(--ink-strong);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  width: 100%;
  padding:
    24px
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}

.shell {
  width: min(1040px, 100%);
  max-width: 100%;
  display: grid;
  gap: 18px;
}

.hud,
.game-panel {
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
  align-items: flex-start;
}

.hud > * {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rose-deep);
}

.hud h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.92;
}

.subcopy {
  margin: 10px 0 0;
  max-width: 36rem;
  line-height: 1.5;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.language-switcher {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.language-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(102, 73, 52, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-strong);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}

.language-link.is-current {
  background: linear-gradient(135deg, #df7fa7 0%, #567cff 100%);
  color: #fffaf6;
  border-color: transparent;
}

.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  flex: 1 1 360px;
}

.stat-card {
  min-width: 124px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(102, 73, 52, 0.08);
}

.stat-card--control {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

.game-panel {
  padding: 18px;
  width: 100%;
  max-width: 100%;
}

.game-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(250, 232, 243, 0.95) 0%, rgba(244, 244, 216, 0.95) 100%);
  border: 1px solid rgba(102, 73, 52, 0.08);
}

.game-frame.is-fever {
  box-shadow:
    inset 0 0 0 2px rgba(255, 214, 102, 0.72),
    0 0 48px rgba(255, 126, 74, 0.22);
}

.game-frame.is-fever::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 214, 102, 0.2), transparent 38%),
    linear-gradient(180deg, rgba(255, 126, 74, 0.08), transparent 36%);
  mix-blend-mode: screen;
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 10px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 0.88rem;
  pointer-events: none;
}

.overlay p {
  margin: 0;
  overflow-wrap: anywhere;
}

.fever-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 109, 79, 0.96), rgba(255, 200, 87, 0.96));
  color: #fffaf6;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 16px 28px rgba(255, 127, 80, 0.28);
  animation: feverPulse 0.8s ease-in-out infinite alternate;
  z-index: 2;
}

.fever-banner.is-hidden {
  display: none;
}

@keyframes feverPulse {
  from {
    transform: translateX(-50%) scale(1);
  }

  to {
    transform: translateX(-50%) scale(1.06);
  }
}

.game-state-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(53, 38, 29, 0.22);
  z-index: 3;
}

.game-state-layer.is-hidden {
  display: none;
}

.game-state-card {
  width: min(420px, 100%);
  padding: 24px 22px;
  border-radius: 24px;
  background: rgba(255, 250, 245, 0.9);
  border: 1px solid rgba(102, 73, 52, 0.12);
  box-shadow: 0 20px 54px rgba(53, 38, 29, 0.2);
  text-align: center;
}

.layer-kicker {
  margin: 0 0 8px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rose-deep);
}

.game-state-card h2 {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1;
}

.game-state-card p[data-layer-body] {
  margin: 12px 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.result-summary {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--ink-strong);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.result-stats[hidden] {
  display: none;
}

.result-stat {
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(102, 73, 52, 0.08);
}

.result-stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.result-stat-value {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
  color: var(--ink-strong);
}

.action-row {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.primary-button {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  color: #fffaf6;
  background: linear-gradient(135deg, #df7fa7 0%, #567cff 100%);
  box-shadow: 0 14px 34px rgba(89, 103, 201, 0.24);
}

.primary-button:disabled {
  opacity: 0.58;
  box-shadow: none;
}

.secondary-button,
.control-button {
  border: 1px solid rgba(102, 73, 52, 0.12);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  color: var(--ink-strong);
  background: rgba(255, 255, 255, 0.9);
}

.secondary-button[hidden] {
  display: none;
}

.control-button {
  margin-top: 10px;
}

@media (max-width: 720px) {
  .page {
    padding:
      8px
      max(8px, env(safe-area-inset-right))
      calc(12px + env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .hud {
    flex-direction: column;
    padding: 18px;
  }

  .language-switcher {
    margin-top: 12px;
    flex-wrap: wrap;
  }

  .stats {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    flex-basis: auto;
  }

  .stat-card {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
    padding: 14px 14px;
  }

  .stat-value {
    font-size: 1.7rem;
  }

  .game-panel {
    padding: 8px;
  }

  .shell {
    gap: 12px;
  }

  .game-frame {
    aspect-ratio: 9 / 14;
    min-height: min(72dvh, 720px);
  }

  .overlay {
    left: 12px;
    right: 12px;
    bottom: 12px;
    border-radius: 16px;
    font-size: 0.82rem;
  }

  .fever-banner {
    top: 12px;
    font-size: 0.82rem;
    padding: 9px 14px;
  }

  .game-state-layer {
    padding: 14px;
  }

  .game-state-card {
    padding: 20px 18px;
    border-radius: 20px;
  }

  .primary-button,
  .secondary-button,
  .control-button {
    width: 100%;
  }

  .game-state-card h2 {
    font-size: 1.65rem;
  }

  .result-stats {
    gap: 8px;
  }

  .result-stat {
    padding: 10px 8px;
  }

  .result-stat-value {
    font-size: 1.08rem;
  }

  .action-row {
    gap: 8px;
  }
}

@media (max-width: 420px) {
  .page {
    padding:
      6px
      max(6px, env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
  }

  .hud,
  .game-panel {
    border-radius: 22px;
  }

  .hud {
    padding: 16px;
  }

  .stat-card {
    flex-basis: 100%;
  }

  .overlay {
    font-size: 0.78rem;
  }

  .game-state-layer {
    padding: 10px;
  }

  .game-state-card {
    padding: 18px 14px;
  }

  .result-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}
