:root {
  --bg: var(--tg-theme-bg-color, #000);
  --text: var(--tg-theme-text-color, #fff);
  --btn: var(--tg-theme-button-color, #0088cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --hint: var(--tg-theme-hint-color, #aaa);
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  height: 100%;
  box-sizing: border-box;
}

.screen.active {
  display: flex;
}

h1, h2 {
  margin: 0 0 20px;
  text-align: center;
}

button {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  padding: 14px 28px;
  font-size: 18px;
  border-radius: 12px;
  margin: 10px;
  cursor: pointer;
  min-width: 220px;
  transition: all 0.2s;
}

button:hover {
  opacity: 0.9;
}

#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 300px;
  max-width: 90vw;
  margin: 20px auto;
}

.cell {
  aspect-ratio: 1;
  background: rgba(255,255,255,0.08);
  border: 2px solid var(--btn);
  border-radius: 12px;
  font-size: 60px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.cell:hover {
  background: rgba(255,255,255,0.15);
}

.cell.x { color: #ff4757; }
.cell.o { color: #1e90ff; }
.cell.y { color: #ffeb3b; } /* для 3p режима */

#status {
  font-size: 22px;
  margin: 15px 0;
  text-align: center;
  min-height: 30px;
}

#players {
  font-size: 16px;
  opacity: 0.8;
  margin-bottom: 10px;
}

#waiting-count {
  font-size: 48px;
  margin: 30px 0;
  color: #00ff88;
}