/* ============================================================
   TIC-TAC-TOE — styles.css  (v3 — caverna profissional)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Lilita+One&family=Nunito:wght@400;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:          #0d0a06;
  --stone:       #3a2e1e;
  --stone-lt:    #5a4830;
  --stone-dk:    #0d0a06;
  --green-cell:  linear-gradient(145deg, #9ab060, #6a8040);
  --green-sh:    #3a5020;
  --orange-cell: linear-gradient(145deg, #e8a020, #c07010);
  --orange-sh:   #804808;
  --xgreen-cell: linear-gradient(145deg, #a0c040, #70900a);
  --xgreen-sh:   #486008;
  --gold:        #f0c040;
  --sky:         #60c8f0;
  --white:       #f0e8d8;
  --muted:       #7a6a50;
  --danger:      #e84040;
  --success:     #50d870;
  --radius:      20px;
  --font-head:   'Lilita One', cursive;
  --font-body:   'Fredoka One', cursive;
  --font-ui:     'Nunito', sans-serif;
  --transition:  0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════
   BODY — CAVERNA (background via #cave-bg SVG element no HTML)
═══════════════════════════════════════════════════════════ */
body {
  background-color: #100804;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  color: var(--white);
  min-height: 100vh;
  position: relative;
}

/* Torch flicker overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 22% 40% at 3% 55%, rgba(200,100,20,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 22% 40% at 97% 55%, rgba(200,100,20,0.22) 0%, transparent 65%);
  animation: torchFlicker 3.2s ease-in-out infinite alternate;
}
@keyframes torchFlicker {
  0%   { opacity: 1;    }
  18%  { opacity: 0.75; }
  35%  { opacity: 0.95; }
  52%  { opacity: 0.65; }
  68%  { opacity: 0.9;  }
  84%  { opacity: 0.62; }
  100% { opacity: 0.85; }
}

/* Noise grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  mix-blend-mode: overlay;
}

/* ── Cave SVG background element ── */
#cave-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
#cave-bg svg {
  width: 100%;
  height: 100%;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* ── Screen Base ───────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: scale(0.97);
  z-index: 2;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

/* ── Stone Card ─────────────────────────────────────────────── */
.stone-card {
  background: linear-gradient(160deg, #2e2018 0%, #1e1610 25%, #161008 55%, #0e0b06 100%);
  border-radius: var(--radius);
  position: relative;
  box-shadow:
    0 1px 0 rgba(180,130,60,0.3) inset,
    1px 0 0 rgba(140,100,40,0.18) inset,
    0 -2px 6px rgba(0,0,0,0.5) inset,
    0 0 0 1px #0a0704,
    0 0 0 3px rgba(80,55,25,0.75),
    0 0 0 5px rgba(40,28,12,0.5),
    0 0 0 7px #06040200,
    0 28px 72px rgba(0,0,0,0.95),
    0 12px 30px rgba(0,0,0,0.6),
    0 0 35px rgba(150,75,15,0.1);
  border: 1.5px solid rgba(110,80,30,0.48);
  overflow: hidden;
}
.stone-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65 0.45' numOctaves='5' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.085 0 0 0 0 0.055 0 0 0 0 0.022 0 0 0 0.25 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 260px 260px;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}
.stone-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background:
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(200,100,20,0.09) 0%, transparent 70%),
    radial-gradient(ellipse 35% 25% at 18% 100%, rgba(255,130,30,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 35% 25% at 82% 100%, rgba(255,130,30,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: cardGlow 4s ease-in-out infinite alternate;
}
@keyframes cardGlow { from { opacity: 0.7; } to { opacity: 1; } }

/* ── Ribbon ─────────────────────────────────────────────────── */
.ribbon {
  position: relative;
  background: linear-gradient(135deg,
    #3a2200 0%, #8a4800 15%, #c07010 32%,
    #f0a030 50%, #e09020 65%, #a05808 80%, #4a2800 100%);
  color: #fff8e0;
  font-family: var(--font-head);
  font-size: 0.85rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 10px 32px;
  text-align: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.28), inset 0 -1px 0 rgba(0,0,0,0.3);
  z-index: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5), 0 0 20px rgba(255,200,80,0.25);
  border-top: 1px solid rgba(255,200,100,0.18);
  border-bottom: 1px solid rgba(0,0,0,0.4);
}
.ribbon::before, .ribbon::after {
  content: '';
  position: absolute;
  bottom: -9px;
  border-top: 9px solid #2a1500;
}
.ribbon::before { left: 0; border-left: 11px solid transparent; }
.ribbon::after  { right: 0; border-right: 11px solid transparent; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  outline: none;
  border-radius: 12px;
  transition: transform var(--transition), filter var(--transition), box-shadow var(--transition);
  position: relative;
  user-select: none;
}
.btn:active { transform: translateY(3px) !important; }

.btn-play {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(145deg, #e8a020, #c07010);
  color: var(--stone-dk);
  box-shadow: 0 6px 0 #804808, 0 10px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
  font-size: 1.1rem;
  border: 2px solid #d09030;
}
.btn-play:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 8px 0 #804808, 0 14px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.25); }

.btn-secondary {
  width: 100%;
  padding: 11px 24px;
  background: linear-gradient(145deg, #2e2015, #1a1208);
  color: var(--white);
  box-shadow: 0 5px 0 #0a0602, 0 8px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(180,120,50,0.15);
  border: 1.5px solid rgba(100,70,25,0.55);
}
.btn-secondary:hover { transform: translateY(-2px); filter: brightness(1.15); }

.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  background: linear-gradient(145deg, #2e2015, #1a1208);
  color: var(--white);
  box-shadow: 0 4px 0 #0a0602, 0 6px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(180,120,50,0.15);
  border: 1.5px solid rgba(100,70,25,0.55);
  border-radius: 10px;
}
.btn-icon:hover { transform: translateY(-2px); filter: brightness(1.15); }
.btn-icon svg { width: 20px; height: 20px; fill: currentColor; pointer-events: none; }

.btn-danger {
  background: linear-gradient(145deg, #e84040, #b02020);
  color: #fff;
  box-shadow: 0 4px 0 #701010, 0 8px 16px rgba(0,0,0,0.4);
  border: 2px solid #f06060;
}
.btn-success {
  background: linear-gradient(145deg, #50d870, #30a040);
  color: var(--stone-dk);
  box-shadow: 0 4px 0 #186028, 0 8px 16px rgba(0,0,0,0.4);
  border: 2px solid #70e890;
}

.btn-group { display: flex; flex-direction: column; gap: 10px; width: 100%; }

/* ═══════════════════════════════════════════════════════════
   SCREEN 1 — SPLASH
═══════════════════════════════════════════════════════════ */
#screen-splash { flex-direction: column; }

.splash-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 56px;
}
.splash-title {
  font-family: var(--font-head);
  font-size: clamp(3.5rem, 10vw, 6.5rem);
  letter-spacing: 10px;
  line-height: 1;
  text-shadow: 0 4px 24px rgba(0,0,0,0.7), 0 0 60px rgba(240,192,64,0.12);
}
.splash-title .t1 { color: #e84040; }
.splash-title .t2 { color: var(--sky); }
.splash-title .t3 { color: var(--gold); }

.splash-progress-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.progress-bar-wrap {
  width: 320px; height: 12px;
  background: #0e0a05;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 0 0 2px rgba(80,55,20,0.5);
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #e84040, #f0a030, #f0c040, #50d870);
  border-radius: 12px;
  transition: width 0.04s linear;
  box-shadow: 0 0 14px rgba(240,192,64,0.5);
}
.progress-label { font-family: var(--font-ui); font-size: 0.82rem; color: var(--muted); letter-spacing: 3px; text-transform: uppercase; }

/* ═══════════════════════════════════════════════════════════
   SCREEN 2 — WELCOME
═══════════════════════════════════════════════════════════ */
#screen-welcome { padding: 16px; overflow: auto; }

.welcome-cards {
  display: flex;
  gap: 20px;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 880px;
}

.w-card {
  flex: 1 1 0;
  min-width: 0;
  max-width: 418px;
  display: flex;
  flex-direction: column;
}
.w-card-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 24px 28px;
  position: relative;
  z-index: 1;
}

.w-logo-wrap { position: relative; width: 130px; height: 130px; margin-top: 20px; }
.w-logo {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px rgba(100,70,30,0.6), 0 0 0 6px #0a0704, 0 10px 24px rgba(0,0,0,0.6);
}
.w-logo-fallback {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #2e2015, #1a1208);
  border: 3px solid rgba(100,70,30,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  box-shadow: 0 0 0 3px #0a0704, 0 10px 24px rgba(0,0,0,0.6);
}

.w-game-title { text-align: center; }
.w-game-title .big { font-family: var(--font-head); font-size: 2.1rem; letter-spacing: 4px; display: block; text-shadow: 0 3px 8px rgba(0,0,0,0.5); }
.w-game-title .big .t1 { color: #e84040; }
.w-game-title .big .t2 { color: var(--sky); }
.w-game-title .big .t3 { color: var(--gold); }
.w-game-title .sub { font-family: var(--font-body); font-size: 1rem; color: var(--muted); letter-spacing: 4px; }

/* ── Settings card ─────────────────────────────────────────── */
.settings-list { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 12px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(145deg, rgba(55,38,16,0.55), rgba(25,16,6,0.65));
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(95,65,25,0.38);
  box-shadow: 0 1px 0 rgba(180,130,60,0.12) inset, 0 4px 12px rgba(0,0,0,0.45);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.setting-row::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200,150,60,0.28), transparent);
}
.setting-row:hover { border-color: rgba(150,105,38,0.5); box-shadow: 0 1px 0 rgba(180,130,60,0.18) inset, 0 6px 18px rgba(0,0,0,0.5); }
.setting-col { flex-direction: column; align-items: flex-start; }

.setting-label {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.setting-label svg { width: 18px; height: 18px; fill: var(--gold); opacity: 0.85; filter: drop-shadow(0 0 4px rgba(240,192,64,0.35)); }

/* Toggle */
.toggle-wrap { position: relative; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-label {
  display: block;
  width: 52px; height: 28px;
  background: linear-gradient(145deg, #0e0a05, #1a1208);
  border-radius: 14px;
  cursor: pointer;
  border: 2px solid rgba(75,52,18,0.7);
  position: relative;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.65), inset 0 1px 2px rgba(0,0,0,0.4);
}
.toggle-label::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(145deg, #6a5030, #3a2810);
  transition: left 0.22s cubic-bezier(0.34,1.56,0.64,1), background 0.22s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
}
.toggle-input:checked + .toggle-label {
  background: linear-gradient(145deg, #1a4010, #2a6018);
  border-color: rgba(75,195,75,0.5);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 0 10px rgba(80,200,80,0.14);
}
.toggle-input:checked + .toggle-label::after {
  left: 26px;
  background: linear-gradient(145deg, #80e890, #40c060);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 8px rgba(80,220,100,0.38), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Lang buttons */
.lang-buttons { display: flex; gap: 5px; }
.lang-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid rgba(78,52,18,0.6);
  background: linear-gradient(145deg, #1e1610, #100c06);
  color: var(--muted);
  transition: all 0.15s;
  letter-spacing: 1px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04);
}
.lang-btn:hover { border-color: rgba(135,95,38,0.7); color: var(--white); transform: translateY(-1px); box-shadow: 0 4px 0 rgba(0,0,0,0.45), 0 4px 8px rgba(0,0,0,0.3); }
.lang-btn.active {
  background: linear-gradient(145deg, #d08020, #a05c10);
  border-color: #e09030;
  color: #1a0e04;
  font-weight: 900;
  box-shadow: 0 2px 0 #602800, 0 4px 12px rgba(200,120,20,0.32), inset 0 1px 0 rgba(255,255,255,0.22);
  transform: translateY(1px);
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(75,52,18,0.6);
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.55), 0 2px 4px rgba(0,0,0,0.3);
  width: 100%;
  background: linear-gradient(145deg, #0e0a05, #1a1208);
}
.mode-btn {
  flex: 1;
  padding: 9px 6px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
  border-right: 1px solid rgba(55,38,14,0.6);
  letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.mode-btn:last-child { border-right: none; }
.mode-btn.active {
  background: linear-gradient(145deg, #c07010, #e8a020);
  color: #1a0e04;
  font-weight: 900;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}
.mode-btn:hover:not(.active) { background: rgba(55,38,14,0.5); color: #c0a070; }

/* ═══════════════════════════════════════════════════════════
   SCREEN 3 — GAME  (HUD 30% + Canvas 70%)
═══════════════════════════════════════════════════════════ */
#screen-game {
  padding: 0;
  align-items: stretch;
  gap: 0;
  width: 100%;
  height: 100%;
}

/* ── HUD — coluna esquerda 30% ── */
.game-hud {
  width: 30%;
  min-width: 220px;
  max-width: 320px;
  height: 100%;
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  gap: 0;
  overflow: hidden;
  z-index: 3;
  flex-shrink: 0;
  overflow-y: auto;
}

/* Mascote */
.hud-mascot {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px 0;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.hud-mascot img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(200,120,30,0.5)) drop-shadow(0 2px 8px rgba(0,0,0,0.9));
  animation: mascotFloat 4s ease-in-out infinite alternate;
}
@keyframes mascotFloat {
  from { transform: translateY(0px); }
  to   { transform: translateY(-7px); }
}

/* Título no HUD */
.hud-title {
  font-family: var(--font-head);
  font-size: 1.4rem;
  letter-spacing: 3px;
  text-align: center;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  padding: 4px 12px 0;
  flex-shrink: 0;
}
.hud-title .t1 { color: #e84040; }
.hud-title .t2 { color: var(--sky); }
.hud-title .t3 { color: var(--gold); }

.hud-mode-label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  position: relative;
  z-index: 1;
  margin-bottom: 8px;
  padding: 0 12px;
  flex-shrink: 0;
}

/* Status no HUD */
.hud-status {
  width: calc(100% - 24px);
  background: linear-gradient(145deg, rgba(20,14,6,0.95), rgba(12,8,3,0.95));
  border: 1px solid rgba(78,52,18,0.5);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--white);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
  margin: 0 12px 8px;
  flex-shrink: 0;
}

/* Player cards no HUD */
.hud-player-card {
  width: calc(100% - 24px);
  background: linear-gradient(145deg, rgba(48,32,12,0.7), rgba(18,12,4,0.75));
  border-radius: 12px;
  padding: 12px 14px 10px;
  border: 1.5px solid rgba(78,52,18,0.48);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 1px 0 rgba(150,100,40,0.1);
  position: relative;
  z-index: 1;
  margin: 0 12px 8px;
  flex-shrink: 0;
}
.hud-player-card.active-player {
  border-color: rgba(200,155,40,0.7);
  box-shadow: 0 0 16px rgba(200,150,30,0.22), 0 3px 8px rgba(0,0,0,0.5), inset 0 0 10px rgba(200,150,30,0.05);
}
.hud-player-header { display: flex; align-items: center; gap: 8px; }
.player-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.o-icon { background: var(--orange-cell); border: 2px solid #d09030; }
.x-icon { background: var(--xgreen-cell); border: 2px solid #90b030; }
.mini-o {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid #c03010;
  box-shadow: 0 0 0 1px #e06030;
}
.mini-x { width: 16px; height: 16px; position: relative; }
.mini-x::before, .mini-x::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 4px;
  background: #3a6010;
  border-radius: 2px;
  transform-origin: center;
}
.mini-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.mini-x::after  { transform: translate(-50%, -50%) rotate(-45deg); }

.player-info { flex: 1; min-width: 0; }
.player-label { font-family: var(--font-ui); font-size: 0.68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.player-name {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--white);
  display: flex;
  align-items: center;
  min-height: 18px;
}
.crown { display: flex; align-items: center; }

.score-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 2px 2px;
  flex-wrap: wrap;
}
.score-dot {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  font-family: var(--font-ui);
  border: 1.5px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.score-dot.win  { background: linear-gradient(135deg, #30a040, #50d870); color: #fff; border-color: #70e890; box-shadow: 0 2px 6px rgba(50,180,70,0.35); }
.score-dot.loss { background: linear-gradient(135deg, #a02020, #e84040); color: #fff; border-color: #f06060; box-shadow: 0 2px 6px rgba(200,40,40,0.35); }
.score-dot.draw { background: linear-gradient(135deg, #3a2a10, #5a4820); color: #a09060; border-color: rgba(150,110,40,0.4); }
.score-dot.empty { background: rgba(0,0,0,0.35); border-color: rgba(80,55,20,0.3); }

/* micro:bit bar no HUD */
.mb-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(0,0,0,0.4);
  border-top: 1px solid rgba(55,38,14,0.5);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--muted);
  position: relative; z-index: 1;
  width: 100%;
  flex-shrink: 0;
}
.mb-bar.visible { display: flex; }
.mb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 5px var(--success); flex-shrink: 0; }
.mb-dot.dis { background: var(--danger); box-shadow: 0 0 5px var(--danger); }

/* HUD actions (botões logo abaixo dos player cards) */
.hud-actions {
  width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
  padding-top: 4px;
  position: relative;
  z-index: 1;
  margin-left: 12px;
  margin-right: 12px;
  flex-shrink: 0;
}

.btn-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 12px;
  background: linear-gradient(145deg, #e8a020, #c07010);
  color: var(--stone-dk);
  font-family: var(--font-head);
  font-size: 0.88rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 2px solid #d09030;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 #804808, 0 8px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.12s, filter 0.12s;
  position: relative;
}
.btn-reset:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn-reset:active { transform: translateY(3px); box-shadow: 0 2px 0 #804808; }

.hud-btn-back {
  font-size: 0.88rem;
  padding: 10px 12px;
  letter-spacing: 1.5px;
}

/* ── Canvas do jogo — coluna direita 70% ── */
.game-canvas-area {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 24px;
}

/* Board wrapper dentro do canvas */
.game-canvas-area .board-wrapper {
  background: linear-gradient(145deg, #1a1208, #0e0a05);
  padding: clamp(12px, 2vw, 20px);
  border-radius: 20px;
  box-shadow:
    inset 0 4px 16px rgba(0,0,0,0.75),
    inset 0 1px 0 rgba(100,70,25,0.18),
    0 0 0 1px rgba(55,38,14,0.5),
    0 8px 28px rgba(0,0,0,0.6),
    0 0 60px rgba(150,75,15,0.08);
  border: 1.5px solid rgba(78,52,18,0.5);
  width: min(90%, 480px);
  aspect-ratio: 1;
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.5vw, 14px);
  width: 100%;
  height: 100%;
}

/* Cells */
.cell {
  aspect-ratio: 1;
  border-radius: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: transform 0.12s, filter 0.12s;
  overflow: hidden;
  user-select: none;
}
.cell.empty {
  background: var(--green-cell);
  box-shadow: 0 6px 0 var(--green-sh), 0 8px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.18);
  border: 2px solid #8aa050;
  cursor: pointer;
}
.cell.empty.locked, .cell.empty:not([style*="cursor"]) {
  cursor: default;
}
.cell.empty:hover:not(.locked) { transform: translateY(-3px) scale(1.04); filter: brightness(1.14); }
.cell.empty:active:not(.locked) { transform: translateY(2px) scale(0.97); }
.cell.o-cell {
  background: var(--orange-cell);
  box-shadow: 0 6px 0 var(--orange-sh), 0 8px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.22);
  border: 2px solid #d09030;
  cursor: default;
}
.cell.x-cell {
  background: var(--xgreen-cell);
  box-shadow: 0 6px 0 var(--xgreen-sh), 0 8px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.18);
  border: 2px solid #90b030;
  cursor: default;
}
.cell.selected-mb {
  outline: 3px solid var(--gold) !important;
  outline-offset: 2px;
  animation: selectedPulse 0.5s infinite alternate;
}
@keyframes selectedPulse {
  from { outline-color: var(--gold); }
  to   { outline-color: #fff8d0; box-shadow: 0 6px 0 var(--green-sh), 0 0 18px 5px rgba(240,192,64,0.4); }
}
.cell.winner-cell {
  animation: winPulse 0.55s infinite alternate !important;
  cursor: default;
}
@keyframes winPulse {
  from { filter: brightness(1.1); transform: scale(1.02); }
  to   { filter: brightness(1.45); transform: scale(1.08); }
}
.ghost-mark { font-size: 2.2rem; color: rgba(60,80,40,0.18); pointer-events: none; font-weight: 900; }
.c-corner { position: absolute; width: 9px; height: 9px; pointer-events: none; }
.c-corner.tl { top: 4px; left: 4px; border-top: 2px solid rgba(255,255,255,0.22); border-left: 2px solid rgba(255,255,255,0.22); }
.c-corner.br { bottom: 4px; right: 4px; border-bottom: 2px solid rgba(0,0,0,0.2); border-right: 2px solid rgba(0,0,0,0.2); }

/* Symbols */
.symbol-o {
  width: 55%; height: 55%;
  border-radius: 50%;
  border: 9px solid #c03010;
  box-shadow: 0 0 0 3px #e06030, inset 0 0 0 3px #a02008, 0 3px 8px rgba(0,0,0,0.4);
  position: relative;
}
.symbol-o::before {
  content: '';
  position: absolute;
  top: 5px; left: 7px;
  width: 28%; height: 22%;
  border-radius: 50%;
  background: rgba(255,255,255,0.28);
  transform: rotate(-30deg);
}
.symbol-x { width: 55%; height: 55%; position: relative; }
.symbol-x::before, .symbol-x::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 11px;
  background: linear-gradient(180deg, #3a6010, #2a4808);
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), 0 0 0 2px #5a8020;
  transform-origin: center;
}
.symbol-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.symbol-x::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* Win overlay dentro do canvas */
.win-overlay {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: rgba(0,0,0,0.78);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
}
.win-overlay.show {
  visibility: visible;
  pointer-events: all;
  opacity: 1;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.win-emoji { display: flex; align-items: center; justify-content: center; animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-message {
  font-family: var(--font-head);
  font-size: 2rem;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(240,192,64,0.8), 0 4px 8px rgba(0,0,0,0.8);
  animation: bounce 0.5s ease infinite alternate;
  letter-spacing: 3px;
}
@keyframes bounce { from { transform: scale(1); } to { transform: scale(1.05); } }
.win-sub { font-family: var(--font-ui); font-size: 1rem; color: #b0a080; letter-spacing: 1px; }

/* ═══════════════════════════════════════════════════════════
   SCREEN 4 — VICTORY
═══════════════════════════════════════════════════════════ */
#screen-victory { padding: 16px; }
.victory-card { width: min(400px, 98vw); padding: 0 0 24px; text-align: center; }
.victory-body { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 24px 24px 0; position: relative; z-index: 1; }
.victory-emoji { display: flex; align-items: center; justify-content: center; animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1); }
.victory-title {
  font-family: var(--font-head);
  font-size: 2.5rem;
  color: var(--gold);
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(240,192,64,0.6), 0 4px 12px rgba(0,0,0,0.6);
  animation: glowPulse 1.5s ease infinite alternate;
}
@keyframes glowPulse {
  from { text-shadow: 0 0 20px rgba(240,192,64,0.4), 0 4px 12px rgba(0,0,0,0.6); }
  to   { text-shadow: 0 0 50px rgba(240,192,64,0.9), 0 4px 12px rgba(0,0,0,0.6); }
}
.victory-name { font-family: var(--font-body); font-size: 1.4rem; color: var(--white); letter-spacing: 2px; }
.victory-stats { display: flex; gap: 16px; }
.vstat { flex: 1; background: rgba(0,0,0,0.35); border-radius: 12px; padding: 12px; border: 1px solid rgba(78,52,18,0.4); }
.vstat-num { font-family: var(--font-head); font-size: 2rem; color: var(--gold); }
.vstat-num.red { color: #e84040; }
.vstat-num.blue { color: var(--sky); }
.vstat-label { font-family: var(--font-ui); font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.victory-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 0 20px; position: relative; z-index: 1; }
.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* ═══════════════════════════════════════════════════════════
   MODAIS
═══════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(5px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }
.modal-box {
  background: linear-gradient(160deg, #2e2018 0%, #1e1610 30%, #130f08 70%, #0e0b06 100%);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  width: min(400px, 92vw);
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(180,130,60,0.22),
    0 0 0 1px #080503,
    0 0 0 4px rgba(70,48,18,0.7),
    0 24px 64px rgba(0,0,0,0.92),
    0 0 30px rgba(150,75,15,0.1);
  border: 1.5px solid rgba(108,78,28,0.5);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box--wide {
  width: min(620px, 94vw);
}
.modal-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65 0.45' numOctaves='5' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.085 0 0 0 0 0.055 0 0 0 0 0.022 0 0 0 0.22 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 260px 260px;
  pointer-events: none;
  border-radius: inherit;
}
.modal-backdrop.show .modal-box { transform: scale(1); }
.modal-title { font-family: var(--font-head); font-size: 1.4rem; color: var(--white); letter-spacing: 2px; margin-bottom: 16px; text-align: center; position: relative; z-index: 1; }
.modal-body { font-family: var(--font-ui); font-size: 0.92rem; color: var(--muted); line-height: 1.6; position: relative; z-index: 1; }
.modal-buttons { display: flex; gap: 10px; position: relative; z-index: 1; }
.modal-buttons .btn { flex: 1; padding: 11px; font-size: 0.9rem; }

/* How to play */
.how-section { margin-bottom: 18px; position: relative; z-index: 1; }
.how-section--last { margin-bottom: 0; }
.how-section-title {
  font-family: var(--font-head);
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(100,70,25,0.3);
}
.how-section-title svg { fill: var(--gold); opacity: 0.85; flex-shrink: 0; }
.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 12px;
}
.how-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 0.83rem;
  color: var(--muted);
  padding: 4px 0;
  line-height: 1.35;
}
.how-item .badge {
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(100,70,25,0.5);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sky);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 32px;
  justify-content: center;
}
.how-item .badge svg { fill: var(--sky); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 700px) {
  .welcome-cards { flex-direction: column; align-items: center; overflow-y: auto; max-height: 100vh; padding: 16px; }
  .w-card { max-width: 360px; width: 100%; }
  #screen-welcome { align-items: flex-start; overflow-y: auto; }
  #screen-game { flex-direction: column; }
  .game-hud {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px;
    justify-content: space-between;
    gap: 8px;
  }
  .hud-mascot { display: none; }
  .hud-title { font-size: 1rem; padding: 0; }
  .hud-mode-label { display: none; }
  .hud-status { width: auto; flex: 1; margin: 0; font-size: 0.75rem; }
  .hud-player-card { width: calc(50% - 8px); margin: 0; }
  .hud-actions { flex-direction: row; width: 100%; margin: 0; padding-bottom: 0; }
  .game-canvas-area { flex: 1; padding: 12px; }
}
@media (max-height: 600px) {
  .hud-mascot { padding: 6px 16px 0; }
  .hud-mascot img { width: 90px; height: 90px; }
}

/* ── BOTÃO CÓDIGO ──────────────────────────────────────────── */
.btn-code {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; font-size: 0.82rem;
  background: linear-gradient(145deg, #2e2015, #1a1208);
  color: var(--white);
  border: 1.5px solid rgba(100,70,25,0.55);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 800;
  transition: all .2s;
  box-shadow: 0 4px 0 #0a0602, 0 6px 14px rgba(0,0,0,0.45), inset 0 1px 0 rgba(180,120,50,0.15);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.btn-code svg { fill: var(--gold); opacity: 0.85; }
.btn-code:hover { transform: translateY(-2px); filter: brightness(1.15); box-shadow: 0 6px 0 #0a0602, 0 10px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(180,120,50,0.2); }
.btn-code:active { transform: translateY(3px) !important; box-shadow: 0 1px 0 #0a0602; }

/* ── MODAL CÓDIGO ─────────────────────────────────────────── */
.modal-box--code { max-width: 680px; }
.code-desc { font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }
.code-desc a { color: #7ec8f0; text-decoration: none; }
.code-desc a:hover { text-decoration: underline; }
.code-block-wrap {
  background: #0a1520; border: 1px solid #1e3a5c; border-radius: 8px;
  padding: 14px; max-height: 360px; overflow-y: auto; overflow-x: auto;
}
.code-block {
  margin: 0; font-family: 'Courier New', monospace; font-size: 0.75rem;
  color: #a8d8f0; white-space: pre; line-height: 1.6;
}

/* ── BOTÃO CONECTAR USB (mbBar) ────────────────────────────── */
.btn-mb-connect {
  margin-left: auto; padding: 3px 10px;
  font-size: 0.65rem; font-family: var(--font-ui);
  background: linear-gradient(135deg, #1a4a2a 0%, #0e2a18 100%);
  color: #60d890; border: 1px solid #2a7a40; border-radius: 6px;
  cursor: pointer; white-space: nowrap; transition: all .2s;
}
.btn-mb-connect:hover { background: linear-gradient(135deg, #1e5a34 0%, #12341e 100%); color: #80f0a8; }
