:root {
  --bg: #0b0f14;
  --surface: #141a21;
  --surface-2: #1c242e;
  --border: #2a3441;
  --text: #e6edf3;
  --text-dim: #9aa7b2;
  --accent: #22c55e;
  --accent-dim: #16a34a;
  --warning: #facc15;
  --danger: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.container-wide {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.auth-title {
  font-size: 1.4rem;
  margin: 0 0 4px;
  text-align: center;
}

.auth-subtitle {
  color: var(--text-dim);
  text-align: center;
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.field input,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 1rem;
  width: 100%;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #04210f;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #2a0a0a;
}

.btn-block {
  width: 100%;
}

/* Alerts */
.alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--accent);
  color: #86efac;
}

/* Header / nav */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.app-header-title a {
  color: var(--text);
  text-decoration: none;
}

.app-nav {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 0 16px 10px;
  max-width: 760px;
  margin: 0 auto;
}

.app-nav a {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}

.app-nav a.active {
  color: var(--accent);
  border-color: var(--accent);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.user-pill form {
  margin: 0;
}

.user-pill button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 24px 0 10px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

tr.me {
  background: rgba(34, 197, 94, 0.08);
}

.text-center {
  text-align: center;
}

.text-dim {
  color: var(--text-dim);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ===== Tablero ===== */
.board-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.board-wrap {
  width: min(92vw, 480px);
  aspect-ratio: 1 / 1;
}

.player-bar {
  width: min(92vw, 480px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.player-bar .player-name {
  font-weight: 600;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 12px;
}

.clock.active {
  border-color: var(--accent);
  color: var(--accent);
}

.clock.low {
  border-color: var(--danger);
  color: #fca5a5;
}

.move-list {
  width: min(92vw, 480px);
  max-height: 160px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.move-list .move.current {
  background: var(--accent);
  color: #04210f;
  border-radius: 4px;
  padding: 0 4px;
}

.board-actions {
  width: min(92vw, 480px);
  display: flex;
  gap: 8px;
}

.board-actions .btn {
  flex: 1;
}

.game-banner {
  width: min(92vw, 480px);
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600;
}

.replay-controls {
  width: min(92vw, 480px);
  display: flex;
  gap: 8px;
  justify-content: center;
}

.replay-controls button {
  flex: 1;
}

.engine-status {
  color: var(--text-dim);
  font-size: 0.85rem;
}
