/* H5 Game Kit base styles v1.0.0 — shared layout, HUD, buttons and screens. */
:root {
  --bg1: #6a5cff;
  --bg2: #ff6fb1;
  --accent: #ffcc33;
  --accent-ink: #3a2a00;
  --ink: #1f1b3a;
  --panel: #ffffff;
  --panel-ink: #2b2552;
  --muted: #7a74a8;
  --good: #2ecc71;
  --bad: #ff5a5f;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(20, 10, 60, .25);
  --hud-h: 64px;
  --focus: #FFC107;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: var(--font);
  color: #062A5F;
  background: #F3F7FF;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
button { font-family: inherit; }

.app {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; height: 100vh; height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 8px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; row-gap: 6px;
  min-height: var(--hud-h); flex: 0 0 auto;
}
.game-title {
  margin: 0; font-size: clamp(18px, 4.2vw, 28px); font-weight: 900; letter-spacing: .5px;
  color: #062A5F; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.game-title img { width: 36px; height: 36px; }
.stats { display: flex; gap: 6px; margin-left: auto; }
.stat {
  background: #fff; color: #0B4DA2; border: 2px solid #C9DAF5; border-radius: 14px; padding: 4px 12px; min-width: 66px; text-align: center;
}
.stat .label { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; opacity: .85; letter-spacing: .8px; }
.stat .value { display: block; font-size: clamp(18px, 4vw, 24px); font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud-actions { display: flex; gap: 6px; }

.icon { width: 26px; height: 26px; display: block; }
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 14px; cursor: pointer;
  display: grid; place-items: center; color: #0B4DA2; background: #fff; border: 2px solid #0B4DA2;
  box-shadow: 0 3px 0 #C9DAF5; transition: transform .08s ease, box-shadow .08s ease;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.icon-btn:focus-visible, .btn:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }

@media (max-width: 820px) {
  .game-title { flex: 1 1 auto; min-width: 0; }
  .stats { order: 3; width: 100%; margin-left: 0; justify-content: center; }
  .stat { flex: 1; }
}
@media (max-width: 560px) {
  .icon-btn { width: 44px; height: 44px; }
}

/* ---------- Stage ---------- */
.stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 28px; border-radius: 999px;
  font-size: 20px; font-weight: 900; letter-spacing: .4px;
  color: #fff; background: #0B4DA2;
  box-shadow: 0 5px 0 #062A5F;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.22); }
.btn .icon { width: 24px; height: 24px; }
.btn-secondary { background: #fff; color: #0B4DA2; box-shadow: inset 0 0 0 2px #0B4DA2, 0 5px 0 #C9DAF5; }
.btn-ghost { background: transparent; color: var(--panel-ink); box-shadow: none; text-decoration: underline; min-height: 44px; font-size: 16px; }
.btn-ghost:active { transform: none; }
.btn-reward { background: linear-gradient(180deg, #7cf29a, #2ecc71); color: #063d1d; }
.btn-group { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* Segmented choice (difficulty etc.) */
.choice { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.choice button {
  min-height: 48px; min-width: 88px; padding: 0 16px; border-radius: 14px; border: 3px solid transparent; cursor: pointer;
  font-size: 16px; font-weight: 900; background: #E6F0FF; color: #0B4DA2;
}
.choice button[aria-pressed="true"] { border-color: #0B4DA2; background: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.12); }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 42, 95, .45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
}
.screen.is-visible { opacity: 1; visibility: visible; }
.card {
  width: min(440px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); color: var(--panel-ink); border-radius: 26px; padding: 26px 22px 22px;
  box-shadow: var(--shadow); text-align: center; border-top: 8px solid #0B4DA2;
  transform: translateY(12px) scale(.96); transition: transform .25s cubic-bezier(.2,1.4,.4,1);
}
.screen.is-visible .card { transform: none; }
.card h2 { margin: 0 0 6px; font-size: 32px; font-weight: 900; color: var(--panel-ink); }
.card p { margin: 6px 0 14px; color: var(--muted); font-size: 17px; line-height: 1.4; font-weight: 600; }
.card .hero { width: 96px; height: 96px; margin: -4px auto 8px; display: block; }
.how { text-align: left; margin: 0 auto 18px; padding: 0; list-style: none; display: grid; gap: 8px; max-width: 340px; }
.how li { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 16px; color: var(--panel-ink); }
.how .k { flex: 0 0 auto; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; background: #E6F0FF; color: #0B4DA2; display: grid; place-items: center; font-size: 14px; font-weight: 900; }
.result { display: flex; gap: 10px; justify-content: center; margin: 10px 0 18px; }
.result .stat { background: #F3F7FF; color: var(--panel-ink); box-shadow: none; padding: 8px 14px; }
.badge-new {
  display: inline-block; margin: 0 0 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 15px;
  animation: pulse 1s ease-in-out infinite alternate;
}
.hidden { display: none !important; }
.stars { display: flex; justify-content: center; gap: 4px; color: #e5e2f5; margin-bottom: 6px; }
.stars .icon { width: 40px; height: 40px; }
.stars .on { color: #ffc531; filter: drop-shadow(0 2px 0 rgba(0,0,0,.15)); }

/* ---------- Feedback ---------- */
.popup {
  position: absolute; z-index: 15; pointer-events: none; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 26px; color: #0B4DA2; text-shadow: 0 2px 0 #fff, 0 0 6px #fff;
  animation: floatUp .9s ease-out forwards;
}
.popup.bad { color: #C92A2A; }
.popup.gold { color: #B8860B; }
.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(6,42,95,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800;
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.bump { animation: bump .25s ease; }

@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes pulse { to { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Short screens (phones in landscape, small laptops with zoom): keep the whole start/pause card visible. */
@media (max-height: 520px) {
  :root { --hud-h: 52px; }
  .app { gap: 4px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .game-title img { width: 28px; height: 28px; }
  .stat { padding: 2px 10px; }
  .icon-btn { width: 42px; height: 42px; }
  .screen { padding: 8px; }
  .card { width: min(620px, 100%); padding: 12px 18px 14px; border-top-width: 6px; border-radius: 20px; }
  .card .hero, .stars { display: none; }
  .card h2 { font-size: 24px; margin-bottom: 2px; }
  .card p { font-size: 15px; margin: 2px 0 8px; }
  .how { gap: 4px; margin-bottom: 10px; max-width: 520px; }
  .how li { font-size: 14px; }
  .how .k { min-width: 28px; height: 28px; }
  .result { margin: 4px 0 10px; }
  .choice button { min-height: 40px; }
  .btn { min-height: 48px; font-size: 18px; }
  .btn-group { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
