/* 3·2·1 Futbol iOS Design System — Marble Blast (flat, zero shadow, uppercase) */

:root {
  --bg-top: #2F4BB0;
  --bg: #1B2D6E;
  --bg-deep: #10194A;
  --purple: #7B3FE4;
  --yellow: #FFD23F;
  --blue: #3B8BFF;
  --green: #35D07F;
  --red: #FF5470;
  --ink: #1D2B64;
  --muted: #B8C4EE;
  --panel-fill: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.12);
  --ghost-fill: rgba(255, 255, 255, 0.14);
  --font: 'Nunito', ui-rounded, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Baloo 2', 'Nunito', ui-rounded, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 55%, var(--bg-deep) 100%);
  color: #FFFFFF;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
}

#app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  background: transparent;
  border-radius: 0;
  border: none;
  overflow: hidden;
}

/* ==================== SCREENS ==================== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.screen > * {
  width: 100%;
  max-width: 480px;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.screen-game {
  padding: 0;
  align-items: stretch;
}

.screen-game > * {
  max-width: none;
}

/* ==================== TOPBAR ==================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-fill);
  border: 1.5px solid var(--panel-border);
  padding: 6px 13px;
  height: 38px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.92rem;
  color: var(--yellow);
}

.trophy-ico {
  width: 15px;
  height: 15px;
  color: var(--yellow);
  flex-shrink: 0;
}

/* ==================== FLAT ZERO-SHADOW BUTTONS (iOS BigButtonStyle & PillButtonStyle) ==================== */
.btn {
  appearance: none;
  border: none;
  outline: none;
  box-shadow: none;
  font-family: var(--font);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 16px;
  height: 46px;
  padding: 0 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #FFFFFF;
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
}

.btn-lg {
  width: 100%;
  height: 56px;
  font-size: 18px;
}

.btn:active:not(:disabled) {
  opacity: 0.7;
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  width: 18px;
  height: 18px;
}

.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-blue { background: var(--blue); color: #FFFFFF; }
.btn-green { background: var(--green); color: #FFFFFF; }
.btn-ghost { background: var(--ghost-fill); color: #FFFFFF; }
.btn-danger { background: var(--red); color: #FFFFFF; }

.btn-pill {
  appearance: none;
  border: none;
  outline: none;
  box-shadow: none;
  font-family: var(--font);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  height: 34px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #FFFFFF;
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
}

.btn-pill:active:not(:disabled) {
  opacity: 0.7;
  transform: scale(0.97);
}

.btn-pill:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-pill-yellow { background: var(--yellow); color: var(--ink); }
.btn-pill-ghost { background: var(--ghost-fill); color: #FFFFFF; }

.icon-btn {
  appearance: none;
  border: none;
  box-shadow: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ghost-fill);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-weight: 900;
  font-size: 12.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { opacity: 0.7; transform: scale(0.95); }
.icon-btn-sm { width: 34px; height: 34px; }
.icon-btn-sm svg { width: 16px; height: 16px; }

.panel-card {
  background: var(--panel-fill);
  border: 1.5px solid var(--panel-border);
  border-radius: 22px;
  padding: 14px;
}

/* ==================== 1. MAIN MENU ==================== */
.menu-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}

.logo-321 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.logo-tiles {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.logo-tile {
  width: 46px;
  height: 52px;
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.logo-tile.t1 { transform: rotate(-8deg) translateY(4px); }
.logo-tile.t2 { transform: rotate(3deg) translateY(-3px); }
.logo-tile.t3 { transform: rotate(9deg) translateY(4px); }

.logo-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--yellow);
  text-transform: uppercase;
}

.logo-sub {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-canvas {
  width: min(100%, 260px);
  height: clamp(160px, 28dvh, 240px);
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.menu-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-row-2 .btn {
  padding: 0 10px;
  font-size: clamp(12px, 3.5vw, 15px);
  white-space: nowrap;
}

/* ==================== 2. LEVELS LIST (5 LEVELS) ==================== */
.levels-list {
  flex: 1;
  margin-top: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.level-card {
  background: var(--panel-fill);
  border: 1.5px solid var(--panel-border);
  border-radius: 20px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-card.locked {
  opacity: 0.58;
}

.level-thumb {
  border-radius: 12px;
  flex-shrink: 0;
}

.level-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.level-num {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
}

.level-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.05;
  color: #FFFFFF;
}

.level-best {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

/* ==================== 3. ACTIVE GAME & HUD ==================== */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.game-hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 520px);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hud-chip {
  background: rgba(16, 25, 74, 0.88);
  border: 1.5px solid var(--panel-border);
  border-radius: 14px;
  height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hud-lvl {
  color: var(--muted);
  white-space: nowrap;
}

.hud-score {
  flex: 1;
  color: #FFFFFF;
  font-size: 15px;
}

.hud-prog-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  min-width: 40px;
}

.hud-prog-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.2s ease;
}

.hud-pause {
  pointer-events: auto;
  background: rgba(16, 25, 74, 0.88);
  border: 1.5px solid var(--panel-border);
  flex-shrink: 0;
}

.game-bottom-bar {
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.swap-btn {
  pointer-events: auto;
  background: rgba(16, 25, 74, 0.88);
  border: 1.5px solid var(--panel-border);
}

.hint-bubble {
  position: absolute;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 460px);
  background: var(--purple);
  border-radius: 18px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 800;
  color: #FFFFFF;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 48, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 30;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  border: 1.5px solid var(--panel-border);
  border-radius: 22px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-sm { max-width: 320px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--yellow);
}

.modal-big-title {
  font-family: var(--font-display);
  text-align: center;
  font-size: 1.55rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--yellow);
}

.modal-big-title.danger {
  color: var(--red);
}

.modal-text {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 18px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.4;
  color: #FFFFFF;
}

/* Victory 5-Row Results Table */
.results-table {
  background: var(--panel-fill);
  border: 1.5px solid var(--panel-border);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.res-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  align-items: center;
}

.res-label { color: var(--muted); }
.res-meta { color: #FFFFFF; opacity: 0.85; font-variant-numeric: tabular-nums; }
.res-pts { color: var(--yellow); min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

.results-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tot-box {
  background: var(--panel-fill);
  border-radius: 14px;
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tot-lbl {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.tot-val {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFFFFF;
}

.tot-val.green { color: var(--green); }
.tot-val.yellow { color: var(--yellow); }

.hidden { display: none !important; }
