/* =========================================================
   ВКЛАДКА «ИГРА» — АТМОСФЕРНАЯ АРЕНА КРЕСТИКИ-НОЛИКИ
========================================================= */
.game-arena {
  position: relative;
  width: 100%;
  min-height: 100%;
  border-radius: 18px;
  padding: 20px 16px 26px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.6s ease;
}

/* Осторожный живой цветовой перелив внутри игровой арены */
.game-arena::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.75;
  will-change: transform, opacity;
  animation: gameAuroraShift 14s ease-in-out infinite alternate;
}

@keyframes gameAuroraShift {
  0% {
    transform: translate3d(-4%, -3%, 0) scale(0.96);
    opacity: 0.55;
  }
  50% {
    transform: translate3d(3%, 4%, 0) scale(1.04);
    opacity: 0.85;
  }
  100% {
    transform: translate3d(-2%, 2%, 0) scale(1);
    opacity: 0.65;
  }
}

.game-arena.diff-easy {
  background: radial-gradient(ellipse 85% 75% at 50% 45%, rgba(16, 185, 129, 0.14) 0%, rgba(16, 12, 28, 0.74) 68%, rgba(10, 8, 18, 0.35) 100%);
}
.game-arena.diff-easy::before {
  background: radial-gradient(circle at 30% 35%, rgba(16, 185, 129, 0.22) 0%, rgba(56, 189, 248, 0.12) 45%, transparent 72%);
}

.game-arena.diff-hard {
  background: radial-gradient(ellipse 85% 75% at 50% 45%, rgba(139, 92, 246, 0.2) 0%, rgba(18, 11, 34, 0.78) 68%, rgba(10, 8, 18, 0.35) 100%);
}
.game-arena.diff-hard::before {
  background: radial-gradient(circle at 68% 32%, rgba(168, 85, 247, 0.26) 0%, rgba(99, 102, 241, 0.14) 45%, transparent 72%);
}

.game-arena.diff-nightmare {
  background: radial-gradient(ellipse 85% 75% at 50% 45%, rgba(225, 29, 72, 0.2) 0%, rgba(24, 10, 22, 0.82) 68%, rgba(10, 8, 18, 0.35) 100%);
}
.game-arena.diff-nightmare::before {
  background: radial-gradient(circle at 42% 65%, rgba(244, 63, 94, 0.25) 0%, rgba(147, 51, 234, 0.15) 45%, transparent 72%);
}

/* Дневная тема внутри игры */
body.light-theme .game-arena.diff-easy,
body.theme-morning .game-arena.diff-easy {
  background: radial-gradient(ellipse 85% 75% at 50% 45%, rgba(16, 185, 129, 0.16) 0%, rgba(220, 252, 231, 0.55) 52%, rgba(242, 237, 252, 0.88) 100%);
}

body.light-theme .game-arena.diff-hard,
body.theme-morning .game-arena.diff-hard {
  background: radial-gradient(ellipse 85% 75% at 50% 45%, rgba(124, 58, 237, 0.16) 0%, rgba(233, 224, 253, 0.6) 52%, rgba(242, 237, 252, 0.88) 100%);
}

body.light-theme .game-arena.diff-nightmare,
body.theme-morning .game-arena.diff-nightmare {
  background: radial-gradient(ellipse 85% 75% at 50% 45%, rgba(225, 29, 72, 0.16) 0%, rgba(255, 228, 230, 0.58) 52%, rgba(242, 237, 252, 0.88) 100%);
}

/* Осторожно переливающиеся и парящие фигуры (X или O) за игрой */
.game-bg-shapes {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-shape-item {
  position: absolute;
  font-weight: 800;
  user-select: none;
  opacity: 0.14;
  color: var(--violet-bright);
  will-change: transform, opacity;
  animation: floatGameShape 12s ease-in-out infinite alternate;
}

.game-arena.diff-easy .bg-shape-item { color: #10b981; }
.game-arena.diff-hard .bg-shape-item { color: #a78bfa; }
.game-arena.diff-nightmare .bg-shape-item { color: #f43f5e; }

.bg-shape-item.sh1 { left: 8%; top: 12%; font-size: 4.5rem; animation-delay: 0s; }
.bg-shape-item.sh2 { right: 10%; top: 16%; font-size: 3.4rem; animation-delay: 1.5s; }
.bg-shape-item.sh3 { left: 14%; bottom: 14%; font-size: 3.8rem; animation-delay: 2.8s; }
.bg-shape-item.sh4 { right: 12%; bottom: 12%; font-size: 5rem; animation-delay: 0.9s; }
.bg-shape-item.sh5 { left: 48%; top: 8%; font-size: 2.8rem; animation-delay: 2.1s; }
.bg-shape-item.sh6 { left: 46%; bottom: 8%; font-size: 3.1rem; animation-delay: 3.4s; }

@keyframes floatGameShape {
  0% { transform: translate3d(0, 12px, 0) rotate(-10deg) scale(0.94); opacity: 0.08; }
  50% { opacity: 0.2; }
  100% { transform: translate3d(0, -14px, 0) rotate(12deg) scale(1.06); opacity: 0.11; }
}
/* Стартовое меню настройки партии */
.game-menu-card,
.ttt-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 450px;
  padding: 24px 22px;
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  background: var(--card-surface);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.game-menu-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--logo-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-control-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.game-control-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
}

/* Универсальные ползунки настроек игры (Режим / Сложность / Фигура) */
.g-pill-switch {
  position: relative;
  display: grid;
  width: 100%;
  height: 40px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.g-pill-switch:active {
  cursor: grabbing;
}

.g-pill-switch.cols-2 { grid-template-columns: 1fr 1fr; }
.g-pill-switch.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.g-pill-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: linear-gradient(135deg, #7c52d4 0%, #5848c2 100%);
  box-shadow: 0 4px 14px rgba(124, 82, 212, 0.36);
  pointer-events: none;
  will-change: transform;
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
}

.g-pill-switch.cols-2 .g-pill-thumb { width: calc((100% - 8px) / 2); }
.g-pill-switch.cols-3 .g-pill-thumb { width: calc((100% - 8px) / 3); }

.g-pill-opt {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  line-height: 1;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  pointer-events: none;
  transition: color 0.22s ease;
}

.g-pill-opt.active {
  color: #ffffff;
}

/* Панель онлайн-комнаты приглашения друга */
.room-invite-box {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-code-pill {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px dashed var(--violet-bright);
  background: rgba(154, 132, 199, 0.1);
  color: var(--violet-bright);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.room-copy-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--glass-border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s ease;
}

.room-copy-btn:hover {
  border-color: var(--violet-bright);
}

.room-join-row {
  display: flex;
  gap: 8px;
}

.room-join-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--glass-border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  outline: none;
}

.room-join-input:focus {
  border-color: var(--violet-bright);
}

.game-start-btn {
  width: 100%;
  height: 44px;
  margin-top: 2px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #7c52d4 0%, #5848c2 100%);
  box-shadow: 0 8px 24px rgba(124, 82, 212, 0.34);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.game-start-btn:hover {
  transform: translate3d(0, -1.5px, 0);
  box-shadow: 0 12px 28px rgba(124, 82, 212, 0.44);
}

/* Шапка активной партии */
.ttt-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ttt-back-menu-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.ttt-back-menu-btn:hover {
  color: var(--text);
  border-color: var(--violet-bright);
}

.ttt-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 999px;
  color: var(--violet-bright);
  background: rgba(154, 132, 199, 0.14);
  border: 1px solid var(--glass-border);
}

.ttt-score-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ttt-score-box {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  text-align: center;
}

.ttt-score-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.ttt-score-val {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

/* Единая статичная рамка игрового поля 3x3 */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(294px, 76vw);
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  border: 2px solid var(--glass-border);
  background: var(--card-bg);
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.16);
}

.ttt-cell {
  position: relative;
  border: none;
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.ttt-cell:nth-child(3n) {
  border-right: none;
}

.ttt-cell:nth-child(n + 7) {
  border-bottom: none;
}

.ttt-cell.taken {
  cursor: default;
}

.ttt-glyph {
  display: inline-block;
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  will-change: transform, opacity;
}

.ttt-cell.mark-x .ttt-glyph {
  color: var(--violet-bright);
  text-shadow: 0 0 18px var(--glow-color);
}

.ttt-cell.mark-o .ttt-glyph {
  color: #38bdf8;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
}

body.light-theme .ttt-cell.mark-o .ttt-glyph,
body.theme-morning .ttt-cell.mark-o .ttt-glyph {
  color: #0284c7;
  text-shadow: none;
}

.ttt-cell.win-cell {
  background: rgba(154, 132, 199, 0.2);
}

.ttt-reset-btn {
  padding: 9px 22px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.ttt-reset-btn:hover {
  border-color: var(--violet-bright);
}
