/* ============================================================
   Bamzo Penalty Challenge — style.css
   Mobile-first portrait. Festive World Cup palette.
   ============================================================ */

:root {
  --navy:   #0a1e3f;
  --navy-2: #123464;
  --gold:   #ffcb2d;
  --gold-2: #ffa41b;
  --purple: #6a2fb5;
  --purple-2:#8b3ff0;
  --green:  #2fbf5a;
  --red:    #e23b4e;
  --white:  #ffffff;
  --ink:    #0c1830;
  --card-bg: rgba(10, 26, 55, 0.72);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--white);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw; height: 100dvh; height: 100vh;
  max-width: 560px; margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #1b3e78 0%, #0a1e3f 55%, #06132a 100%);
}

/* ---------- Canvas ---------- */
#game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: var(--safe-top); left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; gap: 8px;
  z-index: 20;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.hud-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-flag { font-size: 26px; line-height: 1; display: inline-flex; }
.hud-flag .hud-flag-img { width: 34px; height: auto; border-radius: 3px; display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.hud-user {
  font-weight: 700; font-size: 15px; max-width: 34vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-center { flex: 0 0 auto; }
.hud-timer {
  font-size: 30px; font-weight: 900; letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,0.35); border-radius: 12px; padding: 2px 14px;
  border: 2px solid rgba(255,255,255,0.15);
}
.hud-timer.urgent { color: var(--red); animation: pulse 0.5s ease-in-out infinite; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; min-width: 54px; margin-right: 46px; }
.hud-score { font-size: 34px; font-weight: 900; color: var(--gold); line-height: 1; }
.hud-streak { font-size: 15px; font-weight: 800; min-height: 18px; color: var(--gold-2); }

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- Banners ---------- */
.banner {
  position: absolute; top: 24%; left: 50%; transform: translate(-50%, -50%) scale(0.6);
  z-index: 30; pointer-events: none;
  font-size: 42px; font-weight: 900; letter-spacing: 1px; text-align: center;
  color: var(--gold);
  text-shadow: 0 4px 0 #a05a00, 0 8px 22px rgba(0,0,0,0.6);
  -webkit-text-stroke: 2px #5a2b00;
  opacity: 0;
}
.banner.show { animation: bannerPop 1.15s ease-out forwards; }
@keyframes bannerPop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.4) rotate(-6deg); }
  18%  { opacity: 1; transform: translate(-50%,-50%) scale(1.15) rotate(2deg); }
  30%  { transform: translate(-50%,-50%) scale(1.0) rotate(0deg); }
  78%  { opacity: 1; transform: translate(-50%,-50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%,-58%) scale(1.05); }
}

.stoppage-banner {
  position: absolute; top: 12%; left: 50%; transform: translateX(-50%);
  z-index: 30; pointer-events: none;
  background: var(--red); color: #fff; font-weight: 900; font-size: 18px;
  padding: 8px 18px; border-radius: 30px; letter-spacing: 1px;
  box-shadow: var(--shadow); border: 2px solid #fff;
  animation: floatIn 0.4s ease-out;
}
@keyframes floatIn { from { opacity:0; transform: translateX(-50%) translateY(-10px);} to {opacity:1;} }

/* ---------- Mute button ---------- */
.mute-btn {
  position: absolute; top: calc(var(--safe-top) + 8px); right: 10px;
  z-index: 40; display: none;
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.4); color: #fff; font-size: 18px;
  cursor: pointer;
}
.mute-btn.visible { display: block; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: none; overflow-y: auto;
  padding: calc(var(--safe-top) + 18px) 18px calc(var(--safe-bottom) + 18px);
}
.screen.active { display: block; }
.screen-inner {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; max-width: 460px; margin: 0 auto;
}
.screen-title { font-size: 26px; font-weight: 900; margin: 4px 0 6px; }

/* Start screen */
.start-inner { justify-content: center; }
.title-badge {
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  color: var(--ink); font-weight: 900; font-size: 13px; letter-spacing: 2px;
  padding: 6px 16px; border-radius: 30px; box-shadow: var(--shadow);
}
.game-title {
  font-size: 40px; line-height: 1.02; font-weight: 900; margin: 6px 0 0;
  letter-spacing: 1px; text-shadow: 0 4px 0 #071433, 0 10px 24px rgba(0,0,0,0.5);
}
.game-title span {
  display: inline-block; font-size: 24px; color: var(--gold);
  -webkit-text-stroke: 1px #6b4a00;
}
.subtitle { color: #cfe0ff; font-size: 15px; margin: 2px 0 8px; max-width: 320px; }

.field-label { font-size: 13px; color: #a9c2ee; align-self: flex-start; margin-left: 4px; }
.text-input {
  width: 100%; font-size: 18px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.2); outline: none;
  background: rgba(255,255,255,0.95); color: var(--ink); font-weight: 700;
  text-align: center;
}
.text-input:focus { border-color: var(--gold); }
.field-error { color: #ffd0d5; font-size: 13px; background: rgba(226,59,78,0.35);
  padding: 6px 12px; border-radius: 10px; }

.foot-note { color: #90a8d6; font-size: 12px; margin-top: 6px; }

/* Buttons */
.btn-col { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 6px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.btn {
  font-family: inherit; font-weight: 800; font-size: 17px;
  padding: 14px 18px; border-radius: 14px; border: none; cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(2px) scale(0.99); }
.btn-primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--ink);
  box-shadow: 0 6px 0 #9c6400, var(--shadow); }
.btn-primary:active { box-shadow: 0 2px 0 #9c6400; }
.btn-secondary { background: linear-gradient(180deg, var(--purple-2), var(--purple)); color:#fff;
  box-shadow: 0 6px 0 #431d78, var(--shadow); }
.btn-secondary:active { box-shadow: 0 2px 0 #431d78; }
.btn-ghost { background: rgba(255,255,255,0.08); color: #fff; border: 2px solid rgba(255,255,255,0.22); }

/* Flag grid */
.flag-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%;
}
.flag-cell {
  background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.14);
  border-radius: 12px; padding: 8px 4px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform 0.08s ease, background 0.15s;
}
.flag-cell:active { transform: scale(0.94); }
.flag-cell .fc-flag { width: 52px; height: auto; border-radius: 4px; display: block;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45); }
.flag-cell .fc-name { font-size: 10px; color: #c6d7f5; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.flag-cell.selected { background: rgba(255,203,45,0.22); border-color: var(--gold); }

/* Countdown */
.countdown {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,10,24,0.5);
}
.countdown span {
  font-size: 140px; font-weight: 900; color: var(--gold);
  text-shadow: 0 6px 0 #7a4d00, 0 14px 40px rgba(0,0,0,0.7);
  animation: countPop 1s ease-out;
}
@keyframes countPop {
  0% { transform: scale(0.2); opacity: 0; }
  25% { transform: scale(1.15); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Result screen */
.result-inner { justify-content: flex-start; }
.result-card-wrap { width: 100%; max-width: 360px; }
#result-card {
  width: 100%; height: auto; border-radius: var(--radius);
  box-shadow: var(--shadow); background: #0d1f42;
}

/* Modals */
.modal {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3,8,20,0.72); padding: 20px;
}
.modal-box {
  background: linear-gradient(180deg, #16305e, #0c1f42);
  border: 2px solid rgba(255,255,255,0.16); border-radius: var(--radius);
  padding: 20px; max-width: 420px; width: 100%; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-box h3 { margin: 0 0 12px; font-size: 22px; color: var(--gold); }
.modal-body { font-size: 15px; line-height: 1.5; color: #d9e6ff; margin-bottom: 16px; }
.modal-body ol, .modal-body ul { padding-left: 20px; margin: 8px 0; }
.modal-body li { margin: 6px 0; }
.modal-body .hist-row {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.06); border-radius: 10px; padding: 10px 12px; margin: 6px 0;
}
.modal-body .hist-rank { font-weight: 900; color: var(--gold); font-size: 18px; width: 28px; }
.modal-body .hist-main { flex: 1; text-align: left; }
.modal-body .hist-score { font-size: 22px; font-weight: 900; color: var(--gold); }
.modal-body .hist-sub { font-size: 12px; color: #a9c2ee; }
.modal-body .empty { color: #a9c2ee; text-align: center; padding: 16px 0; }

.hidden { display: none !important; }

/* Landscape / desktop hint */
@media (min-width: 640px) and (orientation: landscape) {
  #app { max-width: 480px; }
}
