/* =============================================
   SUPER TRILIZA / ULTIMATE TTT — style.css
   Extends /style.css — uses its CSS variables:
   --bg, --bg2, --glass, --glass-h, --border, --border2,
   --x, --x-glow, --o, --o-glow, --acc, --acc2,
   --text, --muted, --dim, --r, --rs, --t
   ============================================= */

/* ── Header ───────────────────────────────────────────────────────────────── */
.st-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  background: rgba(6, 6, 26, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.btn-back-st {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--glass);
  transition: color var(--t), border-color var(--t), background var(--t);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-back-st:hover {
  color: var(--text);
  border-color: var(--border2);
  background: var(--glass-h);
}

.st-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.1rem, 4.5vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  flex: 1;
  background: linear-gradient(135deg, #ffffff 0%, #c084fc 45%, #4cc9f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

/* Lang mini toggle — reuse kremala's pattern already defined globally */
/* .lang-mini + .lang-mini-btn defined in kremala/style.css — duplicated here for isolation */
.st-header .lang-mini {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.st-header .lang-mini-btn {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 5px 8px;
  opacity: 0.45;
  transition: opacity var(--t), transform var(--t), border-color var(--t);
  line-height: 1;
}
.st-header .lang-mini-btn:hover { opacity: 0.8; transform: scale(1.12); }
.st-header .lang-mini-btn.active {
  opacity: 1;
  transform: scale(1.08);
  border-color: var(--border2);
}

/* ── Main container ───────────────────────────────────────────────────────── */
.st-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 12px 60px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ── Mode bar ─────────────────────────────────────────────────────────────── */
.st-mode-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.st-mode-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dim);
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 9px 20px;
  cursor: pointer;
  transition: all var(--t);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.st-mode-btn:hover {
  color: var(--text);
  border-color: var(--border2);
  background: var(--glass-h);
}
.st-mode-btn.active {
  color: #fff;
  background: rgba(124, 58, 237, 0.22);
  border-color: var(--acc);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.3);
}

/* ── Status ───────────────────────────────────────────────────────────────── */
.st-status {
  font-family: 'Syne', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-align: center;
  transition: color var(--t);
  min-height: 1.6em;
}
.st-status.player-x { color: var(--x); text-shadow: 0 0 12px var(--x-glow); }
.st-status.player-o { color: var(--o); text-shadow: 0 0 12px var(--o-glow); }

/* ── Meta board ───────────────────────────────────────────────────────────── */
.meta-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 8px;
  border: 1px solid var(--border2);
}

/* ── Sub-board ────────────────────────────────────────────────────────────── */
.sub-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  position: relative;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  padding: 3px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color var(--t), box-shadow var(--t), opacity var(--t), background var(--t);
}

/* Active sub-board — must play here */
.sub-board.active-board {
  border-color: #a855f7;
  background: rgba(124, 58, 237, 0.10);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.35), 0 0 20px rgba(124, 58, 237, 0.25);
  animation: boardPulse 1.8s ease-in-out infinite;
}
@keyframes boardPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.35), 0 0 20px rgba(124, 58, 237, 0.25); }
  50%       { box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.55), 0 0 32px rgba(124, 58, 237, 0.45); }
}

/* Won sub-board */
.sub-board.won-board {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.015);
}
.sub-board.won-board .st-cell {
  opacity: 0.18;
  pointer-events: none;
}

/* Inactive sub-board (not the target) */
.sub-board.inactive-board {
  opacity: 0.42;
}
.sub-board.inactive-board .st-cell:hover {
  background: transparent !important;
  border-color: transparent !important;
  transform: none !important;
}

/* ── Cells ────────────────────────────────────────────────────────────────── */
.st-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.7rem, 2.5vw, 1.05rem);
  font-weight: 800;
  color: transparent;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  transition: background var(--t), border-color var(--t), transform 0.1s ease, color var(--t);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding: 0;
  line-height: 1;
}

/* Active board — cells can be hovered */
.sub-board.active-board .st-cell:not(:disabled):not(.x):not(.o):hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}
.sub-board.active-board .st-cell:not(:disabled):not(.x):not(.o):active {
  transform: scale(0.95);
}

/* X cells */
.st-cell.x {
  color: var(--x);
  text-shadow: 0 0 8px var(--x-glow);
  cursor: default;
  animation: cellPlace 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* O cells */
.st-cell.o {
  color: var(--o);
  text-shadow: 0 0 8px var(--o-glow);
  cursor: default;
  animation: cellPlace 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cellPlace {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Sub-board winner overlay ─────────────────────────────────────────────── */
.sub-board-winner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 800;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 5;
}
.sub-board-winner.show {
  opacity: 1;
  animation: winnerReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes winnerReveal {
  from { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1)   rotate(0deg);   opacity: 1; }
}
.sub-board-winner.x {
  color: var(--x);
  text-shadow: 0 0 20px var(--x-glow), 0 0 40px var(--x-glow);
  background: rgba(255, 77, 109, 0.08);
}
.sub-board-winner.o {
  color: var(--o);
  text-shadow: 0 0 20px var(--o-glow), 0 0 40px var(--o-glow);
  background: rgba(76, 201, 240, 0.08);
}
.sub-board-winner.draw {
  color: var(--muted);
  font-size: clamp(1.2rem, 4vw, 2rem);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Legend ───────────────────────────────────────────────────────────────── */
.st-legend {
  display: flex;
  gap: 20px;
  align-items: center;
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.legend-x {
  color: var(--x);
  text-shadow: 0 0 8px var(--x-glow);
}
.legend-o {
  color: var(--o);
  text-shadow: 0 0 8px var(--o-glow);
}

/* ── Actions ──────────────────────────────────────────────────────────────── */
.st-actions {
  display: flex;
  justify-content: center;
}

.btn-st-new {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--acc2);
  background: transparent;
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: var(--rs);
  padding: 12px 32px;
  cursor: pointer;
  transition: all var(--t);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-st-new:hover {
  background: rgba(124, 58, 237, 0.12);
  border-color: var(--acc2);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.2);
}
.btn-st-new:active {
  transform: translateY(0);
}

/* ── SEO section ──────────────────────────────────────────────────────────── */
.st-seo {
  width: 100%;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.st-seo h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: 0.02em;
  line-height: 1.3;
}
.st-seo p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  font-weight: 400;
}

/* ── Result overlay ───────────────────────────────────────────────────────── */
.st-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.st-overlay.show {
  opacity: 1;
}

.st-result-card {
  background: rgba(10, 10, 36, 0.97);
  border: 1px solid var(--border2);
  border-radius: 28px;
  padding: 44px 36px;
  max-width: 340px;
  width: calc(100% - 28px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: resultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes resultPop {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1);   }
}

.st-result-emoji {
  font-size: 3.8rem;
  line-height: 1;
  animation: emojiBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}
@keyframes emojiBounce {
  from { transform: scale(0) rotate(-15deg); }
  to   { transform: scale(1) rotate(0deg);   }
}

.st-result-card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

/* btn-primary defined in /style.css — referenced here for card context */
.st-result-card .btn-primary {
  margin-top: 6px;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--acc) 0%, var(--acc2) 100%);
  border: none;
  border-radius: var(--rs);
  padding: 13px 32px;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t), box-shadow var(--t);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.38);
  letter-spacing: 0.02em;
}
.st-result-card .btn-primary:hover {
  opacity: 0.88;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.5);
}
.st-result-card .btn-primary:active {
  transform: translateY(0);
  opacity: 1;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .st-main {
    gap: 14px;
    padding: 14px 8px 52px;
  }
  .meta-board {
    gap: 5px;
    padding: 5px;
  }
  .sub-board {
    gap: 1px;
    padding: 2px;
    border-radius: 6px;
  }
  .st-cell {
    font-size: 0.8rem;
    border-radius: 3px;
  }
  .sub-board-winner {
    font-size: clamp(1.4rem, 5vw, 2.4rem);
  }
  .st-result-card {
    padding: 34px 22px;
    border-radius: 22px;
  }
  .st-result-card h2 {
    font-size: 1.55rem;
  }
  .st-result-emoji {
    font-size: 3rem;
  }
}

@media (max-width: 400px) {
  .meta-board {
    gap: 4px;
    padding: 4px;
  }
  .sub-board {
    gap: 1px;
    padding: 2px;
  }
  .st-cell {
    font-size: 0.72rem;
  }
  .st-mode-btn {
    font-size: 0.8rem;
    padding: 7px 14px;
  }
  .sub-board-winner {
    font-size: 1.3rem;
  }
}

@media (max-width: 360px) {
  .meta-board {
    gap: 3px;
    padding: 3px;
  }
  .sub-board {
    gap: 1px;
    padding: 1px;
    border-width: 1px;
  }
  .st-cell {
    font-size: 0.65rem;
    border-radius: 2px;
  }
  .sub-board-winner {
    font-size: 1.1rem;
  }
  .st-status {
    font-size: 0.95rem;
  }
}
