:root {
  --sky-1: #b9f3ff;
  --sky-2: #f7f1ff;
  --grass: #8ee58c;
  --deep: #24425f;
  --ink: #24425f;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --pink: #ff7db5;
  --orange: #ffb657;
  --mint: #80e6b1;
  --shadow: rgba(58, 67, 96, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-rounded, "Nunito", "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff4a8 0 10%, transparent 22%), linear-gradient(145deg, var(--sky-1), var(--sky-2));
  touch-action: none;
  user-select: none;
}

button {
  font: inherit;
}

.game-shell {
  width: 100vw;
  min-height: 100svh;
  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));
  display: grid;
  place-items: center;
}

.game-card {
  width: min(1120px, 100%);
  max-height: calc(100svh - 20px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud,
.progress-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 12px 30px var(--shadow);
  backdrop-filter: blur(12px);
}

.hud {
  justify-content: space-between;
}

.brand-chip,
.stat,
.progress-panel > div:first-child,
.result-grid div {
  display: grid;
  gap: 1px;
  min-width: 72px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.brand-chip {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  min-width: 162px;
  font-weight: 900;
}

.mascot-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 16%, transparent 17%), linear-gradient(135deg, #ffe2ef, #ff7db5);
  box-shadow: inset -2px -3px 0 rgba(133, 42, 91, 0.16);
}

.stat span,
.progress-panel span,
.result-grid span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.72;
  font-weight: 800;
}

.stat strong,
.progress-panel strong,
.result-grid strong {
  font-size: 1.05rem;
  line-height: 1.1;
}

.icon-button,
.primary-button {
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  box-shadow: 0 8px 0 rgba(196, 93, 103, 0.28), 0 14px 24px var(--shadow);
  cursor: pointer;
  transform: translateY(0);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  font-weight: 900;
}

.primary-button {
  min-width: 180px;
  padding: 14px 22px;
  font-weight: 900;
  font-size: 1rem;
}

.icon-button:active,
.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(196, 93, 103, 0.28), 0 8px 18px var(--shadow);
}

.progress-panel {
  align-items: stretch;
}

.progress-panel > div:first-child {
  min-width: 164px;
}

.progress-track {
  flex: 1;
  align-self: center;
  min-height: 22px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(36, 66, 95, 0.12);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: repeating-linear-gradient(-45deg, #ff9ec8 0 12px, #ffd36b 12px 24px);
  transition: width 240ms ease;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(70svh, calc(100svh - 150px));
  overflow: hidden;
  border-radius: 34px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 22px 48px rgba(39, 67, 95, 0.22);
  background: linear-gradient(#b9f3ff, #f9f3ff 58%, #91df89 59%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(116, 218, 244, 0.18);
  backdrop-filter: blur(6px);
}

.hidden {
  display: none !important;
}

.modal-card {
  width: min(460px, 100%);
  padding: clamp(18px, 4vw, 34px);
  border-radius: 34px;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 24px 60px rgba(42, 67, 92, 0.24);
}

.modal-card.small {
  width: min(340px, 100%);
}

.modal-card h1,
.modal-card h2,
.modal-card p {
  margin: 0 0 14px;
}

.modal-card h1,
.modal-card h2 {
  line-height: 1;
  font-size: clamp(2rem, 6vw, 3.2rem);
  color: #274362;
}

.modal-card p {
  line-height: 1.45;
  font-weight: 700;
}

.cute-face {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff2a7, #ffa7ce);
  box-shadow: inset -8px -10px 0 rgba(172, 79, 121, 0.13), 0 12px 25px var(--shadow);
  font-size: 1.5rem;
  font-weight: 900;
}

.control-hint,
.touch-help {
  opacity: 0.72;
  font-size: 0.86rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.touch-help {
  display: none;
  justify-content: center;
  font-weight: 800;
}

@media (max-width: 760px) {
  .game-shell {
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .game-card {
    gap: 6px;
    max-height: calc(100svh - 12px);
  }

  .hud,
  .progress-panel {
    border-radius: 18px;
    gap: 6px;
    padding: 7px;
  }

  .hud {
    display: grid;
    grid-template-columns: 1.45fr repeat(3, minmax(52px, 0.62fr)) 38px 38px;
  }

  .brand-chip,
  .stat,
  .progress-panel > div:first-child {
    min-width: 0;
    padding: 7px;
    border-radius: 14px;
  }

  .brand-chip {
    font-size: 0.8rem;
  }

  .stat span,
  .progress-panel span,
  .result-grid span {
    font-size: 0.54rem;
  }

  .stat strong,
  .progress-panel strong {
    font-size: 0.86rem;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .progress-panel > div:first-child {
    min-width: 118px;
  }

  .canvas-wrap {
    border-width: 3px;
    border-radius: 24px;
    max-height: calc(100svh - 128px);
  }

  .touch-help {
    display: flex;
  }
}

@media (max-width: 520px), (max-height: 560px) {
  .hud {
    grid-template-columns: repeat(4, 1fr) 34px 34px;
  }

  .brand-chip span:last-child {
    display: none;
  }

  .brand-chip {
    min-width: 0;
    place-items: center;
  }

  .mascot-dot {
    width: 22px;
    height: 22px;
  }

  .canvas-wrap {
    max-height: calc(100svh - 112px);
  }

  .modal-card {
    border-radius: 24px;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .canvas-wrap {
    aspect-ratio: 10 / 13;
    max-height: calc(100svh - 142px);
  }
}
