/* src/css/styles.css */

:root,
html[data-theme="emerald"],
body[data-theme="emerald"] {
  --bg-primary: #06131c;
  --bg-secondary: #0a221d;
  --card-bg: rgba(11, 25, 36, 0.82);
  --card-border: rgba(16, 185, 129, 0.35);
  --card-glow: rgba(16, 185, 129, 0.22);
  --accent-primary: #10b981;
  --accent-secondary: #14b8a6;
  --hud-border: rgba(52, 211, 153, 0.45);
}

html[data-theme="ucl"],
body[data-theme="ucl"] {
  --bg-primary: #06091e;
  --bg-secondary: #121842;
  --card-bg: rgba(13, 18, 50, 0.82);
  --card-border: rgba(56, 189, 248, 0.4);
  --card-glow: rgba(56, 189, 248, 0.25);
  --accent-primary: #38bdf8;
  --accent-secondary: #6366f1;
  --hud-border: rgba(56, 189, 248, 0.5);
}

html[data-theme="gold"],
body[data-theme="gold"] {
  --bg-primary: #120c04;
  --bg-secondary: #291a07;
  --card-bg: rgba(28, 19, 8, 0.84);
  --card-border: rgba(245, 158, 11, 0.45);
  --card-glow: rgba(245, 158, 11, 0.28);
  --accent-primary: #f59e0b;
  --accent-secondary: #fbbf24;
  --hud-border: rgba(251, 191, 36, 0.55);
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-primary);
  color: #f8fafc;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  transition: background-color 0.4s ease;
}

/* ==========================================================================
   DISTINCT THEME BACKGROUNDS (Pitch, UCL Starball, Ballon d'Or Trophy)
   ========================================================================== */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.4s ease;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center center;
  transition: all 0.4s ease;
}

/* 1. STADIUM NIGHT: Floodlights + Mowed Turf Stripes + Chalk Pitch Markings */
body[data-theme="emerald"]::before,
body:not([data-theme])::before {
  background:
    radial-gradient(circle at 10% 0%, rgba(52, 211, 153, 0.28) 0%, transparent 45%),
    radial-gradient(circle at 90% 0%, rgba(45, 212, 191, 0.28) 0%, transparent 45%),
    repeating-linear-gradient(
      0deg,
      rgba(16, 185, 129, 0.06) 0px,
      rgba(16, 185, 129, 0.06) 44px,
      rgba(6, 78, 59, 0.12) 44px,
      rgba(6, 78, 59, 0.12) 88px
    ),
    linear-gradient(180deg, #041118 0%, #07261d 55%, #041510 100%);
}

body[data-theme="emerald"]::after,
body:not([data-theme])::after {
  opacity: 0.22;
  background-size: min(92vw, 860px) min(88vh, 860px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 1000' fill='none' stroke='%2334d399' stroke-width='4'%3E%3Crect x='40' y='40' width='720' height='920' rx='12'/%3E%3Cline x1='40' y1='500' x2='760' y2='500'/%3E%3Ccircle cx='400' cy='500' r='110'/%3E%3Ccircle cx='400' cy='500' r='6' fill='%2334d399'/%3E%3Crect x='200' y='40' width='400' height='150'/%3E%3Crect x='290' y='40' width='220' height='60'/%3E%3Cpath d='M 310 190 A 95 95 0 0 0 490 190'/%3E%3Crect x='200' y='810' width='400' height='150'/%3E%3Crect x='290' y='900' width='220' height='60'/%3E%3Cpath d='M 310 810 A 95 95 0 0 1 490 810'/%3E%3C/svg%3E");
}

/* 2. UCL NAVY: Royal Indigo + Iconic Center-Circle Champions League Starball */
body[data-theme="ucl"]::before {
  background:
    radial-gradient(circle at 15% 10%, rgba(56, 189, 248, 0.3) 0%, transparent 48%),
    radial-gradient(circle at 85% 10%, rgba(99, 102, 241, 0.32) 0%, transparent 48%),
    radial-gradient(circle at 50% 50%, rgba(30, 58, 138, 0.45) 0%, #05081c 75%),
    linear-gradient(160deg, #05081a 0%, #0f1742 50%, #06091e 100%);
}

body[data-theme="ucl"]::after {
  opacity: 0.26;
  background-size: min(85vw, 560px) min(85vw, 560px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500 500' fill='none'%3E%3Ccircle cx='250' cy='250' r='220' stroke='%2338bdf8' stroke-width='4' stroke-dasharray='10 8'/%3E%3Ccircle cx='250' cy='250' r='195' stroke='%23818cf8' stroke-width='2'/%3E%3Cg stroke='%23e0f2fe' stroke-width='3' fill='%2338bdf8' fill-opacity='0.28'%3E%3Cpolygon points='250,70 269,128 330,128 281,164 299,222 250,186 201,222 219,164 170,128 231,128'/%3E%3Cpolygon points='250,430 269,372 330,372 281,336 299,278 250,314 201,278 219,336 170,372 231,372'/%3E%3Cpolygon points='85,205 135,235 190,210 155,260 175,315 125,285 75,315 95,260 60,210 115,235'/%3E%3Cpolygon points='415,205 365,235 310,210 345,260 325,315 375,285 425,315 405,260 440,210 385,235'/%3E%3Cpolygon points='145,100 175,145 225,135 190,175 205,220 160,195 115,220 130,175 95,135 145,145'/%3E%3Cpolygon points='355,100 325,145 275,135 310,175 295,220 340,195 385,220 370,175 405,135 355,145'/%3E%3C/g%3E%3Ccircle cx='250' cy='250' r='55' stroke='%2338bdf8' stroke-width='3' fill='%230ea5e9' fill-opacity='0.15'/%3E%3C/svg%3E");
}

/* 3. BALLON D'OR: Velvet Obsidian + Golden Trophy & Pyrite Base Watermark */
body[data-theme="gold"]::before {
  background:
    radial-gradient(circle at 50% 18%, rgba(251, 191, 36, 0.28) 0%, transparent 52%),
    radial-gradient(circle at 15% 85%, rgba(217, 119, 6, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(217, 119, 6, 0.22) 0%, transparent 45%),
    linear-gradient(180deg, #0d0903 0%, #241705 52%, #0c0802 100%);
}

body[data-theme="gold"]::after {
  opacity: 0.26;
  background-size: min(82vw, 500px) min(82vw, 500px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500 560' fill='none'%3E%3Ccircle cx='250' cy='200' r='165' stroke='%23f59e0b' stroke-width='2' stroke-dasharray='6 8'/%3E%3Ccircle cx='250' cy='200' r='125' fill='%23f59e0b' fill-opacity='0.22' stroke='%23fbbf24' stroke-width='5'/%3E%3Cpolygon points='250,125 288,152 274,198 226,198 212,152' stroke='%23fde68a' stroke-width='3' fill='%23f59e0b' fill-opacity='0.35'/%3E%3Cpath d='M250,75 L250,125 M325,135 L288,152 M310,235 L274,198 M190,235 L226,198 M175,135 L212,152' stroke='%23fbbf24' stroke-width='3'/%3E%3Cpath d='M185,315 L145,455 L205,435 L250,470 L295,435 L355,455 L315,315 Z' fill='%23d97706' fill-opacity='0.35' stroke='%23fbbf24' stroke-width='4'/%3E%3Cpath d='M210,325 L250,465 M290,325 L250,465' stroke='%23fde68a' stroke-width='2'/%3E%3Crect x='120' y='455' width='260' height='26' rx='6' fill='%23f59e0b' fill-opacity='0.4' stroke='%23fbbf24' stroke-width='3'/%3E%3C/svg%3E");
}

/* ==========================================================================
   SAFE-AREA HEADER, FOOTER & STICKY SCOREBOARD
   ========================================================================== */

.app-top-header {
  padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
  padding-bottom: 0.65rem;
}

.app-bottom-footer {
  padding-top: 0.75rem;
  padding-bottom: calc(0.95rem + env(safe-area-inset-bottom, 0px));
}

.modal-safe-bottom {
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
}

.sticky-scoreboard {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(8, 15, 28, 0.88);
  border: 1px solid var(--hud-border);
  box-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.7), 0 0 18px var(--card-glow);
}

.pm-card-glass {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.pm-card-glass:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--card-glow);
}

/* ==========================================================================
   EQUAL-SIZED DUAL HERO MODE CARDS (H2H ARENA vs DAILY CHALLENGE)
   ========================================================================== */

.pm-hero-mode-card {
  position: relative;
  overflow: hidden;
  border-radius: 1.25rem;
  padding: 1.15rem 1.05rem;
  min-height: 205px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, border-color 0.22s ease;
  cursor: pointer;
}

@media (min-width: 640px) {
  .pm-hero-mode-card {
    padding: 1.35rem 1.15rem;
    min-height: 230px;
  }
}

.pm-hero-mode-card:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.01);
}

.pm-hero-mode-card:active:not(:disabled) {
  transform: scale(0.98);
}

.pm-hero-h2h {
  background:
    radial-gradient(circle at 90% 15%, rgba(16, 185, 129, 0.32) 0%, transparent 55%),
    linear-gradient(145deg, rgba(6, 46, 36, 0.92) 0%, rgba(9, 22, 34, 0.96) 100%);
  border: 2px solid rgba(52, 211, 153, 0.55);
  box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.65), 0 0 24px rgba(16, 185, 129, 0.2);
}

.pm-hero-h2h:hover:not(:disabled) {
  border-color: #34d399;
  box-shadow: 0 16px 34px -6px rgba(0, 0, 0, 0.75), 0 0 32px rgba(52, 211, 153, 0.38);
}

.pm-hero-daily {
  background:
    radial-gradient(circle at 90% 15%, rgba(251, 191, 36, 0.32) 0%, transparent 55%),
    linear-gradient(145deg, rgba(58, 34, 6, 0.92) 0%, rgba(18, 15, 28, 0.96) 100%);
  border: 2px solid rgba(251, 191, 36, 0.6);
  box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.65), 0 0 24px rgba(245, 158, 11, 0.22);
}

.pm-hero-daily:hover:not(:disabled) {
  border-color: #fbbf24;
  box-shadow: 0 16px 34px -6px rgba(0, 0, 0, 0.75), 0 0 32px rgba(251, 191, 36, 0.4);
}

.pm-hero-daily-calculating {
  opacity: 0.85;
  cursor: wait !important;
  border-color: rgba(56, 189, 248, 0.6) !important;
}

.pm-hero-watermark {
  position: absolute;
  right: -14px;
  bottom: -14px;
  width: 132px;
  height: 132px;
  opacity: 0.14;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.pm-hero-mode-card:hover .pm-hero-watermark {
  transform: scale(1.08) rotate(-4deg);
  opacity: 0.22;
}

/* ==========================================================================
   DAILY CHALLENGE 10" READ BAR & TIERED COUNTDOWN BAR
   ========================================================================== */

.pm-timer-track {
  width: 100%;
  height: 10px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 9999px;
  overflow: hidden;
  padding: 1px;
}

.pm-read-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
  transition: width 0.1s linear;
}

.pm-play-bar-drain {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #10b981, #fbbf24, #f43f5e);
  transition: width 0.1s linear;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ==========================================================================
   TACTICAL PITCH & 3D COIN TOSS
   ========================================================================== */

.pitch-surface {
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.14) 0%, transparent 40%),
    radial-gradient(circle at 85% 0%, rgba(255, 255, 255, 0.14) 0%, transparent 40%),
    repeating-linear-gradient(
      0deg,
      #065f46 0px,
      #065f46 28px,
      #047857 28px,
      #047857 56px
    );
  border: 2px solid rgba(167, 243, 208, 0.65);
  border-radius: 16px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.55), 0 8px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.pitch-line-half {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.45);
}

.pitch-center-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 76px;
  height: 76px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 9999px;
}

.pitch-box-top {
  position: absolute;
  top: 0;
  left: 50%;
  width: 46%;
  height: 18%;
  transform: translateX(-50%);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top: 0;
}

.pitch-box-bottom {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 46%;
  height: 18%;
  transform: translateX(-50%);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-bottom: 0;
}

.coin-scene {
  width: 112px;
  height: 112px;
  perspective: 900px;
}

.coin-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 4px solid #fde68a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.55);
}

.coin-heads {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  color: #0f172a;
}

.coin-tails {
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
  transform: rotateY(180deg);
}

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

.animate-screen {
  animation: screenFadeIn 0.22s ease-out;
}