:root {
  --bg-top: #f3efe5;
  --bg-bottom: #d8e5ea;
  --ink: #10262d;
  --muted: #4f646b;
  --card: rgba(255, 255, 255, 0.7);
  --card-border: rgba(255, 255, 255, 0.78);
  --accent: #0b8f79;
  --accent-strong: #07695a;
  --accent-soft: #caecdf;
  --gold: #bf9448;
  --x-color: #0c5460;
  --o-color: #9a6a20;
  --shadow-lg: 0 24px 65px rgba(18, 54, 61, 0.17);
  --shadow-md: 0 12px 26px rgba(17, 48, 53, 0.13);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, var(--bg-top), var(--bg-bottom));
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(12px);
  pointer-events: none;
  z-index: 0;
}

.bg-shape-a {
  width: 440px;
  height: 440px;
  background: radial-gradient(circle at 30% 30%, #fef4cf 0%, #e8dac9 58%, transparent 72%);
  top: -180px;
  left: -120px;
  animation: driftA 12s ease-in-out infinite alternate;
}

.bg-shape-b {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle at 70% 40%, #bde3d6 0%, #8cc4bb 50%, transparent 72%);
  right: -160px;
  bottom: -220px;
  animation: driftB 14s ease-in-out infinite alternate;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1120px, 92vw);
  margin: 42px auto;
}

.game-shell {
  border: 1px solid var(--card-border);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(9px);
  border-radius: var(--radius-xl);
  padding: 26px;
  animation: reveal 620ms ease both;
}

.hero h1 {
  font-family: "Bodoni Moda", serif;
  letter-spacing: 0.02em;
  margin: 8px 0 10px;
  font-size: clamp(2rem, 2.9vw, 2.9rem);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.73rem;
  color: var(--gold);
  font-weight: 800;
}

.subtext {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 580px;
}

.play-area {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 22px;
}

.board-panel {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.82), rgba(246, 251, 249, 0.68));
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.status {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--accent-strong);
}

.round {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 12px;
}

.cell {
  aspect-ratio: 1;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(165deg, #feffff, #e8f2ef);
  box-shadow: inset 0 -3px 0 rgba(9, 69, 63, 0.08), 0 7px 14px rgba(17, 44, 50, 0.12);
  font-family: "Bodoni Moda", serif;
  font-size: clamp(2rem, 4.2vw, 3.1rem);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease, background 170ms ease;
}

.cell:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
  box-shadow: inset 0 -3px 0 rgba(9, 69, 63, 0.08), 0 12px 20px rgba(17, 44, 50, 0.16);
}

.cell:disabled {
  cursor: default;
}

.cell.x {
  color: var(--x-color);
}

.cell.o {
  color: var(--o-color);
}

.cell.win {
  background: linear-gradient(160deg, #d7efe5, #f8f1df);
  animation: winnerPulse 850ms ease-in-out infinite alternate;
}

.control-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.card {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.86);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.85), rgba(244, 250, 248, 0.66));
  box-shadow: var(--shadow-md);
  padding: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 0.93rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #435a61;
}

.mode-switch {
  display: grid;
  gap: 8px;
}

.online-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.online-grid input {
  border: 1px solid #bdd8d0;
  border-radius: 10px;
  background: #fbfffd;
  color: #16353c;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.online-grid input:focus {
  outline: 2px solid #9acabe;
  outline-offset: 1px;
}

.mode-btn {
  border: 1px solid #bfd8d1;
  background: #f2f8f5;
  border-radius: 999px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #214147;
  cursor: pointer;
  transition: all 160ms ease;
}

.mode-btn:hover {
  border-color: #9cc8bc;
  transform: translateY(-1px);
}

.mode-btn.is-active {
  background: linear-gradient(130deg, var(--accent), #13a087);
  color: #f3fbf8;
  border-color: transparent;
  box-shadow: 0 10px 17px rgba(7, 96, 83, 0.26);
}

.meta-line {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #435b62;
}

.meta-line.connected {
  color: #0f7f61;
}

.meta-line.disconnected {
  color: #8e4027;
}

.pair-indicator {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #7a5e23;
}

.pair-indicator.ready {
  color: #0f7f61;
}

.pair-indicator.waiting {
  color: #7a5e23;
}

.room-meta {
  margin-top: 12px;
  border-top: 1px solid rgba(164, 193, 187, 0.5);
  padding-top: 10px;
}

.room-meta p {
  margin: 4px 0;
  font-size: 0.85rem;
  color: #38535a;
}

.room-meta strong {
  color: #11313a;
  letter-spacing: 0.06em;
}

.live-steps {
  margin: 0 0 10px;
  padding-left: 18px;
  color: #3d565d;
  font-size: 0.84rem;
  line-height: 1.3;
}

.live-feed {
  margin: 0;
  padding-left: 18px;
  color: #2f4c53;
  font-size: 0.82rem;
  line-height: 1.35;
  display: grid;
  gap: 3px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(84px, 1fr));
  gap: 10px;
}

.score-item {
  border: 1px solid rgba(173, 205, 198, 0.6);
  border-radius: 11px;
  background: linear-gradient(180deg, #fcfefd, #edf7f3);
  padding: 10px 8px;
  text-align: center;
}

.score-item .label {
  display: block;
  font-size: 0.74rem;
  color: #4a656c;
  font-weight: 700;
}

.score-item strong {
  display: block;
  margin-top: 5px;
  font-size: 1.55rem;
  line-height: 1;
  color: var(--ink);
}

.actions {
  display: grid;
  gap: 10px;
}

.action-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.action-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.action-btn:disabled,
.mode-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.action-primary {
  background: linear-gradient(130deg, #0a8f7d, #0f7d8f);
  color: #effaf8;
  box-shadow: 0 10px 20px rgba(7, 89, 96, 0.28);
}

.action-secondary {
  background: linear-gradient(130deg, #f5efde, #f0e2c7);
  color: #5e4a20;
}

@keyframes winnerPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.03);
  }
}

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

@keyframes driftA {
  from {
    transform: translateY(0) translateX(0);
  }
  to {
    transform: translateY(24px) translateX(14px);
  }
}

@keyframes driftB {
  from {
    transform: translateY(0) translateX(0);
  }
  to {
    transform: translateY(-18px) translateX(-10px);
  }
}

@media (max-width: 900px) {
  .play-area {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100%, 96vw);
    margin: 20px auto;
  }

  .game-shell {
    padding: 16px;
  }

  .board {
    gap: 10px;
  }

  .score-grid {
    grid-template-columns: repeat(3, minmax(70px, 1fr));
  }
}
