.tool-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.ttt-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  position: relative;
  font-family: 'Inter', sans-serif;
}

.ttt-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 1rem;
}

.ttt-mode-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--ink);
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  justify-content: center;
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  flex: 1;
  text-align: center;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
}

.mode-tab:hover:not(.active) {
  color: var(--snow);
  background: rgba(255,255,255,0.05);
}

.screen {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.screen.active {
  display: flex;
}

/* Home Screen */
.ttt-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--snow);
  margin-bottom: 0.25rem;
}

.ttt-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.btn-play-action {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.85rem 2.5rem;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 8px;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(79, 142, 247, 0.3);
}

.btn-play-action:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-play-action:active {
  transform: translateY(0);
}

#player-info {
  margin-top: 1rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Waiting Screen */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 1rem auto 1.5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

#waiting-text {
  font-size: 0.85rem;
  color: var(--snow);
  letter-spacing: 1px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  margin-bottom: 1rem;
}

#btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 1px;
  transition: all 0.2s;
}

#btn-cancel:hover {
  border-color: var(--snow);
  color: var(--snow);
}

/* Game Screen */
#game-status {
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  color: var(--snow);
  margin-bottom: 0.5rem;
  min-height: 24px;
}

#game-status.your-turn { color: var(--accent); }
#game-status.their-turn { color: var(--muted); }

#symbol-badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 1rem;
  background: var(--ink);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Timer */
#timer-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.25rem;
  overflow: hidden;
  width: 100%;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 1s linear;
  border-radius: 2px;
}

#timer-bar.warning { background: #ef4444; }

/* Board */
#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 1.25rem;
  width: 100%;
  max-width: 280px;
}

.cell {
  background: var(--ink);
  border: 1px solid var(--border);
  aspect-ratio: 1;
  font-size: 2.2rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  color: var(--snow);
}

.cell:hover:not(.taken) {
  background: rgba(79, 142, 247, 0.1);
  border-color: var(--accent);
}

.cell.taken { cursor: default; }
.cell.win { background: rgba(79, 142, 247, 0.2); border-color: var(--accent); color: var(--accent); }

#score {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 1.5px;
  font-family: 'JetBrains Mono', monospace;
}

/* End Screen */
#result-text {
  font-size: 1.5rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

#result-text.win { color: var(--accent); }
#result-text.lose { color: #ef4444; }
#result-text.draw { color: #f59e0b; }

#result-reason {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 1.5rem;
  font-family: 'Inter', sans-serif;
}

#btn-new-game {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.75rem 1.75rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  letter-spacing: 1.5px;
  transition: background 0.2s;
}

#btn-new-game:hover {
  background: rgba(79, 142, 247, 0.15);
}

/* Debug panel */
#debug {
  margin-top: 1rem;
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: left;
  max-height: 80px;
  overflow-y: auto;
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
}
#debug div { margin-bottom: 2px; }
#debug .info { color: var(--muted); }
#debug .ok { color: #10b981; }
#debug .err { color: #ef4444; }
#debug .warn { color: #f59e0b; }
