/* --- Cute UI design tokens --- */
:root {
  --font: 'Nunito', system-ui, -apple-system, sans-serif;
  --bg: #fef9f5;
  --bg-warm: #fdf5ee;
  --text: #3d2c29;
  --text-muted: #8b7355;
  --accent: #e8a87c;
  --accent-light: #f0c4a8;
  --accent-dark: #d4926a;
  --mint: #85cdca;
  --mint-soft: rgba(133, 205, 202, 0.35);
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-border: rgba(232, 168, 124, 0.25);
  --input-bg: rgba(255, 255, 255, 0.95);
  --shadow: 0 4px 20px rgba(61, 44, 41, 0.06);
  --shadow-lg: 0 20px 50px rgba(61, 44, 41, 0.08);
  --radius: 16px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --transition: 0.25s ease;
}

html {
  box-sizing: border-box;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font), system-ui, sans-serif;
  font-weight: 500;
  background: #fef9f5;
  background: var(--bg);
  color: #3d2c29;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* --- Auth screen (cute) --- */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: #fdf5ee;
  background: var(--bg-warm);
}

.auth-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.auth-bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, var(--mint-soft) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 80%, rgba(232, 168, 124, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 0% 70%, rgba(232, 168, 124, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 100%);
}

.auth-bg-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(61, 44, 41, 0.06) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, black 25%, transparent 72%);
}

.auth-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.95);
  background: var(--card-bg);
  border: 2px solid rgba(232, 168, 124, 0.4);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 56px 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(61, 44, 41, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.9) inset;
  backdrop-filter: blur(16px);
  animation: fadeUp 0.5s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header {
  margin-bottom: 40px;
}

.auth-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0 0 14px 0;
  letter-spacing: -0.02em;
  color: var(--text);
}

.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.5;
}

.auth-welcome { margin-bottom: 0; }
.auth-welcome-msg {
  margin: 0 0 28px 0;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 600;
}
.auth-welcome .btn { margin-bottom: 18px; }
.auth-welcome .auth-toggle { margin-bottom: 0; }

.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 18px;
}

.auth-email-form input {
  padding: 16px 20px;
  font-size: 1rem;
  font-family: var(--font);
  font-weight: 500;
  border: 2px solid rgba(61, 44, 41, 0.12);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-email-form input::placeholder { color: var(--text-muted); }
.auth-email-form input:hover { border-color: var(--accent-light); }
.auth-email-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--mint-soft);
}

.auth-toggle { margin: 0 0 26px 0; }
.auth-toggle a {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
}
.auth-toggle a:hover { text-decoration: underline; }

.auth-divider {
  margin: 0 0 26px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 18px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(61, 44, 41, 0.1), transparent);
}

.auth-buttons { display: flex; flex-direction: column; gap: 14px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 16px 24px;
  font-size: 1.05rem;
  font-family: var(--font);
  font-weight: 700;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-2px); }

.btn-google {
  background: #fff;
  color: var(--text);
  border: 2px solid rgba(61, 44, 41, 0.12);
  box-shadow: var(--shadow);
}
.btn-google:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(61, 44, 41, 0.1);
}

.btn-guest {
  background: var(--bg-warm);
  color: var(--text-muted);
  border: 2px solid rgba(61, 44, 41, 0.12);
}
.btn-guest:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--text);
  border-color: var(--accent);
}

.btn-email {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(232, 168, 124, 0.4);
}
.btn-email:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(232, 168, 124, 0.45);
}

.btn-icon { flex-shrink: 0; }

.auth-error {
  margin-top: 22px;
  padding: 14px 18px;
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-loading {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--mint-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Game: one unified page (no frame-in-frame) --- */
.game-wrapper {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  box-sizing: border-box;
  /* Same ambient background as auth so the whole app feels like one page */
  background: var(--bg-warm);
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, var(--mint-soft) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 80%, rgba(232, 168, 124, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 0% 70%, rgba(232, 168, 124, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 100%);
}
.game-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(61, 44, 41, 0.05) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  pointer-events: none;
}

.game-frame {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  /* Transparent so wrapper gradient shows in letterbox — one fused page */
  background: transparent;
}

.game-wrapper:fullscreen {
  background: #000;
}
.game-wrapper:fullscreen .game-frame {
  /* unchanged */
}

#game-frame {
  display: block;
  width: 100%;
  height: 100%;
}
#game-frame canvas {
  display: block;
  vertical-align: top;
}

/* --- Game UI overlay (same page, not a second layer) --- */
.game-ui-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: 20px 24px;
  gap: 12px;
}
.game-ui-overlay > * { pointer-events: none; }
.game-ui-overlay .game-ui-btn { pointer-events: auto; }
.game-ui-overlay .game-ui-points { pointer-events: auto; }

.game-ui-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-ui-menu-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.game-ui-menu-actions.hidden {
  display: none;
}

.game-ui-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-ui-points {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
}

.game-ui-btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
  backdrop-filter: blur(10px);
}
.game-ui-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}
.game-ui-btn-icon { padding: 12px; display: inline-flex; align-items: center; justify-content: center; }
.game-ui-icon { display: block; }
.game-ui-icon.hidden { display: none; }

/* Progress bar: only visible on camera (video) screens */
.game-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 82%;
  max-width: 480px;
  margin: 0 auto;
  transition: opacity var(--transition);
}

.game-progress-bar {
  width: 100%;
  height: 24px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.game-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mint) 0%, #6bb8b5 100%);
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
  box-shadow: 0 0 12px rgba(133, 205, 202, 0.5);
}

.game-progress-label {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Focus styles (a11y) */
.btn:focus-visible,
.auth-toggle a:focus-visible,
.game-ui-btn:focus-visible,
.auth-email-form input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--mint-soft), 0 0 0 1px var(--accent);
}
