/* Tabletop — Dark Neumorphic Theme */
:root {
  --bg-primary: #121214;
  --bg-secondary: #1a1a1e;
  --bg-card: #1e1e22;
  --bg-elevated: #252528;
  --text-primary: #f0f0f0;
  --text-secondary: #6b6b6b;
  --text-muted: #444448;
  --accent: #e6a020;
  --accent-pink: #e87c8a;
  --accent-green: #4caf50;
  --accent-red: #e74c3c;
  --shadow-dark: rgba(0, 0, 0, 0.6);
  --shadow-light: rgba(255, 255, 255, 0.04);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Neumorphic card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow:
    8px 8px 20px var(--shadow-dark),
    -4px -4px 12px var(--shadow-light);
}

.card-inset {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow:
    inset 4px 4px 10px var(--shadow-dark),
    inset -2px -2px 6px var(--shadow-light);
}

/* Typography */
h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow:
    4px 4px 12px var(--shadow-dark),
    -2px -2px 8px var(--shadow-light);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow:
    6px 6px 16px var(--shadow-dark),
    -3px -3px 10px var(--shadow-light);
}

.btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 4px var(--shadow-light);
}

.btn-accent {
  background: var(--accent);
  color: #1a1a1e;
}

.btn-accent:hover {
  background: #d4920e;
}

.btn-pink {
  background: var(--accent-pink);
  color: #1a1a1e;
}

.btn-pink:hover {
  background: #d46a78;
}

.btn-green {
  background: var(--accent-green);
  color: #1a1a1e;
}

.btn-green:hover {
  background: #43a047;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: var(--radius-xs);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-full {
  width: 100%;
}

/* Inputs */
.input {
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow:
    inset 3px 3px 8px var(--shadow-dark),
    inset -2px -2px 6px var(--shadow-light);
  outline: none;
  transition: all 0.2s ease;
}

.input:focus {
  box-shadow:
    inset 3px 3px 8px var(--shadow-dark),
    inset -2px -2px 6px var(--shadow-light),
    0 0 0 2px var(--accent);
}

.input::placeholder {
  color: var(--text-muted);
}

.input-code {
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

/* Checkbox stat selector */
.stat-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-xs);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 4px var(--shadow-light);
  user-select: none;
}

.stat-check.selected {
  background: var(--bg-elevated);
  box-shadow:
    3px 3px 8px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light);
}

.stat-check svg {
  width: 24px;
  height: 24px;
}

.stat-check span {
  font-size: 14px;
  font-weight: 500;
}

.stat-check input[type="checkbox"] {
  display: none;
}

/* Character grid */
.character-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 4px var(--shadow-light);
}

.character-card:hover {
  background: var(--bg-secondary);
}

.character-card.selected {
  background: var(--bg-elevated);
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light),
    0 0 0 2px var(--accent);
}

.character-card svg {
  width: 56px;
  height: 78px;
}

.character-card .char-name {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* Page layouts */
.page-container {
  width: 100%;
  max-width: 600px;
}

.page-container.wide {
  max-width: 900px;
}

.page-container.full {
  max-width: 1200px;
}

/* Index page — two panels */
.index-panels {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.panel-divider::before,
.panel-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--text-muted);
  opacity: 0.3;
}

/* Lobby */
.room-code-display {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 8px;
  text-align: center;
  color: var(--accent);
  margin-bottom: 8px;
}

.copy-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 24px;
  transition: color 0.2s;
}

.copy-link:hover {
  color: var(--accent);
}

/* Player list */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  background: var(--bg-primary);
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 4px var(--shadow-light);
}

.player-row svg {
  width: 36px;
  height: 50px;
  flex-shrink: 0;
}

.player-info {
  flex: 1;
}

.player-name {
  font-size: 15px;
  font-weight: 600;
}

.player-badge {
  font-size: 11px;
  color: var(--accent);
  margin-left: 6px;
}

.ready-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
  flex-shrink: 0;
}

.ready-dot.is-ready {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 4px;
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 4px var(--shadow-light);
}

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all 0.2s;
  border: none;
  background: transparent;
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow:
    3px 3px 8px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light);
}

/* Tab content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Stat editor */
.stat-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 4px var(--shadow-light);
}

.stat-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 100%;
  height: 100%;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  min-width: 80px;
}

/* Selectable stat cards */
.stat-selectable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.stat-selectable:hover {
  background: var(--bg-secondary);
}

.stat-selectable.selected {
  background: var(--bg-elevated);
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light),
    0 0 0 2px var(--accent);
}

.stat-value-display {
  margin-left: auto;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  min-width: 50px;
  text-align: right;
}

/* Calculator */
.calc {
  margin-top: 24px;
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 20px;
  box-shadow:
    8px 8px 20px var(--shadow-dark),
    -4px -4px 12px var(--shadow-light);
}

.calc-display {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  margin-bottom: 16px;
  box-shadow:
    inset 3px 3px 8px var(--shadow-dark),
    inset -2px -2px 6px var(--shadow-light);
  text-align: right;
}

.calc-selected-stat {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.calc-input {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  word-break: break-all;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.calc-key {
  height: 56px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow:
    3px 3px 8px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light);
}

.calc-key:hover {
  transform: translateY(-1px);
  box-shadow:
    5px 5px 12px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light);
}

.calc-key:active {
  transform: translateY(1px);
  box-shadow:
    inset 2px 2px 6px var(--shadow-dark),
    inset -1px -1px 3px var(--shadow-light);
}

.calc-key-op {
  background: var(--bg-card);
  color: var(--accent);
  font-size: 26px;
}

.calc-key-eq {
  background: var(--accent-pink);
  color: #1a1a1e;
  font-size: 26px;
}

.calc-key-eq:hover {
  background: #d46a78;
}

.calc-key-c {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.calc-key-back {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.calc-key-zero {
  grid-column: span 2;
}

/* Arena — semicircle layout */
.arena {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 20px 0 40px;
}

.arena-semicircle {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 420px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.arena-figure {
  position: absolute;
  bottom: 0;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform:
    rotate(var(--angle))
    translateY(-200px)
    rotate(calc(var(--angle) * -1));
  transform-origin: center bottom;
  margin-left: -45px; /* half of figure width */
}

.arena-stats-row {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.arena-stat {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 5px;
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow:
    3px 3px 8px var(--shadow-dark),
    -1px -1px 4px var(--shadow-light);
  white-space: nowrap;
}

.arena-stat svg {
  width: 16px;
  height: 16px;
}

.arena-stat span {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

.arena-nick {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  white-space: nowrap;
  text-align: center;
}

.arena-avatar svg {
  width: 70px;
  height: 98px;
}

/* Spectator — larger arena */
.arena-spectator {
  padding: 40px 0 60px;
}

.arena-semicircle-lg {
  max-width: 100%;
  height: 550px;
}

.arena-figure-lg {
  transform:
    rotate(var(--angle))
    translateY(-260px)
    rotate(calc(var(--angle) * -1));
  margin-left: -60px;
}

.arena-stat-lg {
  padding: 4px 8px;
  border-radius: 10px;
}

.arena-stat-lg svg {
  width: 18px;
  height: 18px;
}

.arena-stat-lg span {
  font-size: 15px;
}

.arena-nick-lg {
  font-size: 18px;
  margin-bottom: 8px;
}

.arena-avatar-lg svg {
  width: 110px;
  height: 154px;
}

/* Spectator page */
.spectator-header {
  text-align: center;
  margin-bottom: 16px;
}

.spectator-header h1 {
  font-size: 22px;
  color: var(--text-secondary);
}

.spectator-header .room-code {
  color: var(--accent);
  font-weight: 800;
}

/* Header bar (game page) */
.game-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow:
    4px 4px 12px var(--shadow-dark),
    -2px -2px 8px var(--shadow-light);
}

.game-header svg {
  width: 32px;
  height: 44px;
}

.game-header .header-info {
  flex: 1;
}

.game-header .header-nick {
  font-size: 16px;
  font-weight: 700;
}

.game-header .header-code {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  box-shadow:
    6px 6px 16px var(--shadow-dark),
    -3px -3px 10px var(--shadow-light);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  border-left: 4px solid var(--accent-red);
}

.toast.success {
  border-left: 4px solid var(--accent-green);
}

/* Lobby actions */
.lobby-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.lobby-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.lobby-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.lobby-link-row span {
  color: var(--text-muted);
  font-size: 12px;
}

/* Waiting text */
.waiting-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px;
}

/* Form group */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Logo */
.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo h1 {
  font-size: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 12px;
    align-items: flex-start;
    padding-top: 40px;
  }

  .card {
    padding: 20px;
  }

  .character-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .character-card svg {
    width: 40px;
    height: 56px;
  }

  .character-card .char-name {
    font-size: 9px;
  }

  .stat-selector {
    gap: 8px;
  }

  .room-code-display {
    font-size: 28px;
    letter-spacing: 6px;
  }

  h1 {
    font-size: 24px;
  }

  .spectator-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .players-grid {
    grid-template-columns: 1fr;
  }

  .lobby-actions {
    flex-direction: column;
  }
}
