/* ══════════════════════════════════════════════════════════════════════════
   TicTacToe page
   ══════════════════════════════════════════════════════════════════════════ */

.ttt-main {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.ttt-hero {
  text-align: center;
  margin-bottom: 32px;
}
.ttt-hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 10px;
}
.ttt-dot { color: var(--accent); }
.ttt-sub {
  color: var(--muted);
  font-size: 1rem;
}

.ttt-back-btn {
  font-size: .82rem;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: color .15s, border-color .15s, transform .15s;
}
.ttt-back-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.ttt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}

.ttt-field { margin-bottom: 20px; }
.ttt-field label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.ttt-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: .95rem;
  padding: 12px 14px;
  border-radius: 10px;
  transition: border-color .15s;
}
.ttt-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.ttt-pill-group {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}
.ttt-pill-group button {
  width: 100%;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: .85rem;
  font-weight: 600;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ttt-pill-group button:hover {
  color: var(--text);
  border-color: var(--accent);
}
.ttt-pill-group button[data-val="0"] {
  font-size: 1.35rem;
  line-height: 0.7;
  font-weight: 400;
}
.ttt-pill-group button.active {
  background: rgba(124,109,250,.14);
  border-color: var(--accent);
  color: var(--accent2);
}

.ttt-cta {
  width: 100%;
  min-height: 48px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .1s, background .15s, box-shadow .15s;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ttt-cta:hover {
  background: var(--accent2);
  box-shadow: 0 6px 20px rgba(124,109,250,.35);
}
.ttt-cta:active { transform: translateY(1px); }
.ttt-cta:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ttt-secondary {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: .88rem;
  font-weight: 500;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-top: 10px;
}
.ttt-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ── Info cards below setup ─────────────────────────────────────────────── */
.ttt-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}
.ttt-info-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.ttt-info-k {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 6px;
}
.ttt-info-v {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Waiting card ───────────────────────────────────────────────────────── */
.ttt-waiting-card {
  text-align: center;
  padding: 40px 28px;
}
.ttt-waiting-card h2 {
  font-size: 1.35rem;
  margin-bottom: 6px;
  font-weight: 600;
}
.ttt-waiting-card .ttt-muted {
  color: var(--muted);
  margin-bottom: 20px;
  font-size: .88rem;
}
.ttt-spinner {
  width: 36px; height: 36px;
  margin: 0 auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ttt-spin 1s linear infinite;
}
@keyframes ttt-spin { to { transform: rotate(360deg); } }

.ttt-share-row {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.ttt-share-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: .82rem;
}
.ttt-share-row button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: .85rem;
  transition: background .15s, border-color .15s;
}
.ttt-share-row button:hover { border-color: var(--accent); }

.ttt-waiting-meta {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.ttt-waiting-meta span strong { color: var(--text); font-weight: 600; }

/* ── Join screen ────────────────────────────────────────────────────────── */
.ttt-join-meta {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.ttt-join-meta span { display: flex; flex-direction: column; }
.ttt-join-meta .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; }
.ttt-join-meta .v { color: var(--text); font-weight: 600; margin-top: 2px; }
.ttt-join-err {
  color: var(--red);
  font-size: .85rem;
  text-align: center;
  margin-top: 10px;
  min-height: 20px;
}

/* ── Game screen ────────────────────────────────────────────────────────── */
.ttt-players {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.ttt-player {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.ttt-player-r { flex-direction: row-reverse; text-align: right; }
.ttt-player.ttt-turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,109,250,.15);
}
.ttt-p-mark {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
.ttt-p-mark svg { width: 24px; height: 24px; fill: none; stroke-linecap: round; stroke-width: 10; }
.ttt-mark-x { background: rgba(124,109,250,.12); }
.ttt-mark-x svg { stroke: var(--accent); }
.ttt-mark-o { background: rgba(52,211,153,.12); }
.ttt-mark-o svg { stroke: var(--green); }
.ttt-p-name {
  font-weight: 600;
  font-size: .95rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ttt-p-score {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 2px;
}
.ttt-p-score span { color: var(--text); font-weight: 600; }
.ttt-vs {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .78rem;
  color: var(--muted);
  letter-spacing: 1px;
}

.ttt-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: .88rem;
}
.ttt-status-bar #tttStatus { color: var(--text); font-weight: 500; }
.ttt-timer {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--muted);
  min-width: 54px;
  text-align: right;
}
.ttt-timer.ttt-low { color: var(--red); animation: ttt-pulse 1s ease infinite; }
@keyframes ttt-pulse { 50% { opacity: .45; } }

/* ── Board ──────────────────────────────────────────────────────────────── */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows:    repeat(3, 1fr);
  gap: 10px;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin: 0 auto;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.ttt-cell { min-width: 0; min-height: 0; }
.ttt-cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, transform .1s;
  user-select: none;
}
.ttt-cell:not(.ttt-filled):not(.ttt-disabled):hover {
  background: var(--bg);
  border-color: var(--accent);
}
.ttt-cell.ttt-disabled { cursor: not-allowed; }
.ttt-cell.ttt-filled { cursor: default; }
.ttt-cell svg {
  width: 58%;
  height: 58%;
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
}
.ttt-cell.ttt-x svg { stroke: var(--accent); }
.ttt-cell.ttt-o svg { stroke: var(--green); }
.ttt-cell svg .ttt-line { stroke-dasharray: 130; stroke-dashoffset: 130; animation: ttt-draw .28s ease-out forwards; }
.ttt-cell svg .ttt-line-2 { animation-delay: .18s; }
.ttt-cell svg .ttt-circ { stroke-dasharray: 220; stroke-dashoffset: 220; animation: ttt-draw .34s ease-out forwards; }
@keyframes ttt-draw { to { stroke-dashoffset: 0; } }
.ttt-cell.ttt-win {
  background: rgba(124,109,250,.18);
  border-color: var(--accent);
  animation: ttt-pop .35s ease;
}
@keyframes ttt-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.ttt-cell-anim {
  animation: ttt-cell-in .2s ease;
}
@keyframes ttt-cell-in {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: scale(1); }
}

.ttt-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 420px;
  margin: 20px auto 0;
}
.ttt-actions .ttt-secondary { min-height: 48px; }
.ttt-actions > * { min-width: 0; }
.ttt-actions .ttt-cta   { margin-top: 0; }
.ttt-actions .ttt-secondary { margin-top: 0; }

.ttt-bottom-info {
  max-width: 420px;
  margin: 16px auto 0;
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
  min-height: 20px;
}
.ttt-bottom-info.ttt-win-text  { color: var(--green); font-weight: 600; }
.ttt-bottom-info.ttt-lose-text { color: var(--red);   font-weight: 600; }
.ttt-bottom-info.ttt-draw-text { color: var(--accent2); font-weight: 600; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ttt-main { padding: 24px 16px 60px; }
  .ttt-card { padding: 20px; }
  .ttt-info { grid-template-columns: 1fr; }
  .ttt-players { grid-template-columns: 1fr 1fr; }
  .ttt-vs { display: none; }
  .ttt-p-name { max-width: 100px; }
  .ttt-pill-group button { font-size: .8rem; padding: 9px 4px; }
}
