/* game.css — mobile-first, minimal, no external fonts/images (#32/#35/#36) */

:root {
  --bg: #0b0e1a;
  --bg-elevated: #141a2e;
  --accent: #4fd6ff;
  --accent-2: #4ce096;
  --danger: #ff5470;
  --text: #f4f6fb;
  --text-dim: #9aa3c0;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  min-height: 100vh;
}
.screen.active {
  display: flex;
}

/* ---------- Main menu ---------- */
#screen-menu {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  background: radial-gradient(circle at 50% 20%, #1a2340 0%, var(--bg) 65%);
}
#screen-menu h1 {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  margin: 0 0 4px;
  letter-spacing: 0.5px;
}
.tagline {
  color: var(--text-dim);
  margin: 0 0 28px;
  font-size: 1rem;
}
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary,
.menu-buttons button {
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #6a8dff);
  color: #061021;
  font-weight: 700;
  font-size: 1rem;
}
.menu-buttons button:not(:first-child) {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
}
button:active {
  transform: scale(0.97);
}

/* ---------- Level select ---------- */
#screen-levels .top-bar,
#screen-game .game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: var(--bg-elevated);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tier-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.tier-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}
.tier-card .tier-progress {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding-bottom: 12px;
}
.level-cell {
  min-height: 56px;
  border-radius: 12px;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
}
.level-cell .stars {
  font-size: 0.6rem;
  color: #ffd166;
  letter-spacing: 1px;
}
.level-cell.locked {
  opacity: 0.35;
  pointer-events: none;
}
.level-cell.current {
  outline: 2px solid var(--accent);
}
.hidden-el { display: none !important; }

/* ---------- Game screen ---------- */
#screen-game {
  padding-bottom: calc(12px + var(--safe-bottom));
}
.hud-info {
  text-align: center;
  flex: 1;
}
#hud-level-label {
  display: block;
  font-weight: 700;
}
#hud-timer {
  display: block;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}
#game-canvas {
  touch-action: none;
  border-radius: var(--radius);
  background: #0f1424;
  max-width: 100%;
  max-height: 100%;
}

.toast {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 84, 112, 0.92);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
  animation: toastIn 220ms ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.game-controls {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.game-controls button {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  background: var(--bg-elevated);
  font-weight: 600;
}
.game-controls #btn-hint {
  background: linear-gradient(135deg, #ffb454, #ff8a54);
  color: #201200;
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
@media (min-width: 640px) {
  .modal { align-items: center; }
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 420px;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  animation: modalIn 320ms cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 85vh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-card { border-radius: 20px; }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-card h2 {
  margin: 0 0 8px;
  text-align: center;
}
.stars {
  text-align: center;
  font-size: 2.2rem;
  color: #ffd166;
  margin: 8px 0 16px;
}
.complete-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.complete-stats span {
  color: var(--text);
  font-weight: 700;
}
.modal-buttons {
  display: flex;
  gap: 10px;
}
.modal-buttons button {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  font-weight: 700;
}
#btn-replay { background: var(--bg); }
#btn-next-level { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #051609; }

.modal-close {
  display: block;
  margin: 16px auto 0;
  background: none;
  color: var(--text-dim);
  min-height: 44px;
  padding: 0 16px;
}

.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.lb-tabs button {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
}
.lb-tabs button.active {
  background: var(--accent);
  color: #051627;
}
.lb-status { color: var(--text-dim); text-align: center; padding: 24px 0; }
#lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.lb-rank { width: 32px; color: var(--text-dim); font-weight: 700; }
.lb-name { flex: 1; }
.lb-score { font-weight: 700; color: var(--accent); }
.lb-row--you { background: rgba(79, 214, 255, 0.08); border-radius: 8px; }
.lb-empty { text-align: center; color: var(--text-dim); padding: 20px 0; }
#lb-personal { text-align: center; margin-top: 10px; color: var(--text-dim); font-size: 0.9rem; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  background: var(--bg);
  border-radius: 999px;
  cursor: pointer;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 160ms ease, background 160ms ease;
}
.switch.on { background: rgba(79,214,255,0.25); }
.switch.on::after { transform: translateX(20px); background: var(--accent); }

.menu-nickname {
  width: 100%;
  max-width: 320px;
  margin: 0 0 16px;
}
#input-nickname {
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  text-align: center;
}
#input-nickname::placeholder {
  color: var(--text-dim);
}
#input-nickname:focus {
  outline: none;
  border-color: var(--accent);
}
#input-nickname.invalid {
  border-color: var(--danger);
}
.nickname-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin: 6px 0 0;
  text-align: center;
}

.achv-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.achv-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 12px;
}
.achv-item.unlocked { border: 1px solid rgba(76,224,150,0.4); }
.achv-icon { font-size: 1.4rem; width: 32px; text-align: center; }
.achv-title { font-weight: 700; font-size: 0.9rem; }
.achv-desc { color: var(--text-dim); font-size: 0.78rem; }

/* ---------- Daily streak ---------- */
.daily-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}
.streak-badge {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffb454;
}

/* ---------- SEO content below the game ---------- */
#seo-content {
  padding: 32px 16px calc(48px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
  color: var(--text-dim);
  line-height: 1.6;
}
#seo-content h2 { color: var(--text); font-size: 1.2rem; margin-top: 28px; }
#seo-content h1 { color: var(--text); font-size: 1.6rem; }

/* ---------- Ad slots (never overlapping gameplay, #38) ---------- */
.ad-slot {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  margin-bottom: 12px;
}

@media (min-width: 720px) {
  .screen { max-width: 900px; margin: 0 auto; width: 100%; }
}
