:root {
  --bg: #000;
  --panel: #04100a;
  --neon: #22c55e;
  --neon-weak: rgba(34,197,94,0.12);
  --muted: #9be7b4;
  --glass: rgba(255,255,255,0.02);
  --card-radius: 14px;
  --accent-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *:before, *:after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--accent-font);
  background: radial-gradient(circle at center, #0f2027, #203a43, #2c5364);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 12px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: stretch;
}

.card {
  background: linear-gradient(180deg, rgba(2,6,3,0.9), rgba(2,8,4,0.75));
  border-radius: var(--card-radius);
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid rgba(34,197,94,0.08);
}

header.site {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(180deg, #062113, #0b3521);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(34,197,94,0.08);
}

.logo img { width: 80%; height: auto; max-width: 38px; }

h1 { 
  font-size: 1.25rem; 
  margin: 0; 
  color: var(--neon); 
  letter-spacing: 0.3px; 
  flex: 1 0 100%;
}

.subtitle { 
  color: var(--muted); 
  font-size: 0.8rem; 
  margin-top: 4px; 
  flex: 1 0 100%;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}

.score {
  background: linear-gradient(180deg, rgba(34,197,94,0.06), rgba(34,197,94,0.03));
  border-radius: 8px;
  padding: 8px 10px;
  flex: 1;
  min-width: 80px;
  text-align: center;
  color: var(--muted);
  border: 1px solid rgba(34,197,94,0.06);
}
.score .label { font-size: 0.7rem; color: #8ee0a6; }
.score .value { font-size: 1.15rem; color: var(--neon); font-weight: 700; margin-top: 4px; }

.turn-indicator {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(34,197,94,0.03), rgba(34,197,94,0.01));
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34,197,94,0.03);
  font-weight: 600;
  font-size: 0.9rem;
}

.board-wrap {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.board {
  width: 300px;
  height: 300px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.12));
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
}

.cell {
  border-radius: 8px;
  background: linear-gradient(180deg, #05120b, #072014);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--neon);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, box-shadow 0.1s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  touch-action: manipulation;
}
.cell:active { transform: scale(0.96); }
.cell.disabled { cursor: default; opacity: 0.85; pointer-events: none; }

.x { color: var(--neon); text-shadow: 0 4px 12px rgba(34,197,94,0.12); font-weight: 800; }
.o { color: #e6ffe9; text-shadow: 0 4px 8px rgba(0,0,0,0.4); font-weight: 700; }

.win {
  animation: pulse 0.8s infinite alternate;
  box-shadow: 0 8px 32px rgba(34,197,94,0.2);
}
@keyframes pulse {
  from { transform: scale(1); background: linear-gradient(180deg, #06331e, #08361f); }
  to { transform: scale(1.02); background: linear-gradient(180deg, #0b4f2a, #0e5c32); }
}

.controls {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  background: transparent;
  border: 1px solid rgba(34,197,94,0.14);
  color: var(--neon);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
}
.btn:hover { background: rgba(34,197,94,0.05); transform: translateY(-1px); }
.btn:active { transform: scale(0.98); }

.info-card {
  background: linear-gradient(180deg, rgba(3,6,3,0.85), rgba(2,6,3,0.7));
  border-radius: var(--card-radius);
  padding: 16px;
  color: var(--muted);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid rgba(34,197,94,0.04);
}
.info-card h3 { color: var(--neon); margin-bottom: 8px; font-size: 1.1rem; }
.info-card p { font-size: 0.9rem; line-height: 1.4; color: #9be7b4; }

.small {
  font-size: 0.78rem;
  color: #84d69e;
  margin-top: 12px;
}

footer.page-foot {
  margin-top: 16px;
  text-align: center;
  color: rgba(34,197,94,0.9);
  font-weight: 600;
  font-size: 0.85rem;
}

/* Mobile optimization */
@media (max-width: 768px) {
  body { padding: 8px; }
  .wrap { 
    grid-template-columns: 1fr; 
    gap: 16px; 
    padding: 0 4px;
  }
  header.site {
    flex-direction: column;
    text-align: center;
  }
  .logo { 
    width: 40px; 
    height: 40px; 
    margin: 0 auto 8px; 
  }
  .logo img { max-width: 32px; }
  h1 { font-size: 1.1rem; }
  .subtitle { font-size: 0.75rem; }
  .score-row { 
    gap: 8px; 
    justify-content: center;
  }
  .score { 
    padding: 6px 8px; 
    min-width: 70px; 
  }
  .score .label { font-size: 0.65rem; }
  .score .value { font-size: 1rem; }
  .turn-indicator { font-size: 0.85rem; padding: 6px 8px; }
  .board {
    width: min(90vw, 360px);
    height: min(90vw, 360px);
    gap: 8px;
    padding: 8px;
  }
  .cell { font-size: max(8vw, 32px); }
  .controls { gap: 6px; }
  .btn { 
    padding: 8px 10px; 
    font-size: 0.85rem; 
    min-width: 80px; 
    flex: 1; 
  }
  .info-card { padding: 12px; }
  .info-card h3 { font-size: 1rem; }
  .info-card p { font-size: 0.85rem; }
  .small { font-size: 0.75rem; }
}

@media (max-width: 480px) {
  body { padding: 4px; }
  .wrap { padding: 0 2px; }
  header.site { gap: 4px; }
  .logo { width: 36px; height: 36px; }
  .logo img { max-width: 28px; }
  h1 { font-size: 1rem; }
  .subtitle { font-size: 0.7rem; }
  .score { min-width: 60px; padding: 4px 6px; }
  .score .label { font-size: 0.6rem; }
  .score .value { font-size: 0.9rem; }
  .board { 
    width: min(95vw, 320px); 
    height: min(95vw, 320px); 
    gap: 6px; 
    padding: 6px; 
  }
  .cell { font-size: max(7.5vw, 28px); }
  .btn { padding: 6px 8px; font-size: 0.8rem; }
}

@media (max-height: 600px) {
  body { padding: 4px; }
  .wrap { gap: 12px; }
  .card, .info-card { padding: 8px; }
  .board { width: min(85vw, 280px); height: min(85vw, 280px); }
  header.site { margin-bottom: 8px; }
  .score-row { margin: 8px 0; }
}