/* Catan8 – monolith UI */
:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --text: #eee;
  --text-muted: #aaa;
  --border: #0f3460;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.site-header h1 a {
  color: var(--text);
  text-decoration: none;
}

.site-header h1 a:hover {
  color: var(--accent);
}

#user-bar {
  font-size: 0.9rem;
  color: var(--text-muted);
}

#user-bar .logout {
  margin-left: 0.5rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

#main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.screen {
  animation: fade 0.2s ease;
}

.screen.hidden {
  display: none !important;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.auth-form input,
.auth-form button,
form input[type="text"],
form input[type="email"],
form input[type="password"],
form select,
form button {
  display: block;
  width: 100%;
  max-width: 280px;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

form label {
  display: block;
  margin-bottom: 0.75rem;
}

form label input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
}

button,
.btn-primary {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 600;
}

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

.auth-toggle {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-toggle a {
  color: var(--accent);
}

.error {
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

#games-list {
  margin-top: 1rem;
}

.game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.game-row .meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.game-row button {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  max-width: none;
}

/* Game screen: persistent header + board + sidebar */
.game-card {
  max-width: 1100px;
}

.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.game-header .game-title {
  margin: 0;
  font-size: 1.25rem;
}

.game-status-line {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.game-status-line strong {
  color: var(--text);
}

.game-back-link {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.game-back-link:hover {
  text-decoration: underline;
}

#game-content {
  min-height: 200px;
}

.game-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
}

.game-board-area {
  flex: 6 1 0;
  min-width: 0;
}

.game-board-area .board-wrap {
  margin: 0;
}

.game-sidebar {
  flex: 4 1 0;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.game-sidebar-section {
  background: rgba(15, 52, 96, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.game-sidebar-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.game-sidebar-section .dice-roll,
.game-sidebar-section .phase-hint,
.game-sidebar-section .dev-cards {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.game-resources table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.game-resources th,
.game-resources td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.game-resources th {
  color: var(--text-muted);
  font-weight: 600;
}

.game-resources td:first-child {
  text-align: left;
}

.game-resources td:nth-child(2) {
  text-align: right;
}

.game-resources .dev-cards {
  margin-top: 0.75rem;
}

.game-resources .dev-card-list {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.game-winner {
  color: var(--accent);
}

.game-vp .vp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.game-vp .vp-table th,
.game-vp .vp-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.game-vp .vp-table td:nth-child(2) {
  text-align: right;
}

.game-vp .vp-badges {
  font-size: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.25rem;
}

.badge-road {
  background: var(--border);
  color: var(--text);
}

.badge-army {
  background: #4a148c;
  color: #fff;
}

.robber-victims {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-steal-victim {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
}

.btn-steal-victim:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.game-sidebar-section .game-actions {
  margin: 0;
}

.game-controls {
  min-height: 320px;
}

.game-controls .game-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.game-controls .game-actions button,
.game-controls .game-actions .btn-primary {
  width: 100%;
}

/* Lobby view (no board) */
.game-lobby-info {
  background: rgba(15, 52, 96, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  max-width: 420px;
}

.game-lobby-info h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
}

.game-players-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.game-players-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.game-players-list li:last-child {
  border-bottom: none;
}

.game-no-players {
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 1rem 0;
}

.game-waiting-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0 0;
}

#back-to-lobby {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* Game board */
.board-wrap {
  margin: 1rem 0;
  background: #0f3460;
  border-radius: 8px;
  padding: 8px;
}

.game-board .hex {
  stroke: #2a4a6f;
  stroke-width: 1;
  pointer-events: none;
}

.game-board .hex.clickable {
  pointer-events: all;
  cursor: pointer;
}

.game-board .hex-hero-overlay {
  pointer-events: all;
  cursor: pointer;
  fill: transparent;
  stroke: none;
}

.game-board .hex-wood { fill: #1b5e20; }   /* dark green */
.game-board .hex-wheat { fill: #ffd54f; }  /* yellow */
.game-board .hex-sheep { fill: #9ccc65; }  /* light green */
.game-board .hex-brick { fill: #c62828; }  /* red */
.game-board .hex-ore { fill: #78909c; }    /* grey */
.game-board .hex-desert { fill: #8d6e63; }

.game-board .hex.has-robber {
  stroke: #e94560;
  stroke-width: 3;
}

.game-board .hex-resource {
  font-size: 10px;
  font-weight: bold;
  fill: #fff;
  stroke: #1a1a2e;
  stroke-width: 1px;
  paint-order: stroke fill;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.game-board .hex-number {
  font-size: 16px;
  font-weight: bold;
  fill: #fff;
  stroke: #1a1a2e;
  stroke-width: 1.5px;
  paint-order: stroke fill;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.game-type-badge {
  display: inline-block;
  background: #0f3460;
  color: #ffd54f;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.my-resources {
  margin: 0.5rem 0;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0.5rem 0;
}

.game-actions button,
.game-actions .btn-primary {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.action-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.trade-bank summary {
  cursor: pointer;
}

.trade-bank-form {
  margin-top: 8px;
}

.trade-bank-form select {
  margin: 0 4px;
  padding: 4px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.game-board .node.has-city {
  stroke: #fff;
}

.game-board .node.player-0.has-city { fill: #b71c1c; }
.game-board .node.player-1.has-city { fill: #0d47a1; }
.game-board .node.player-2.has-city { fill: #1b5e20; }
.game-board .node.player-3.has-city { fill: #e65100; }
.game-board .node.player-4.has-city { fill: #4a148c; }
.game-board .node.player-5.has-city { fill: #006064; }
.game-board .node.player-6.has-city { fill: #b71c1c; }
.game-board .node.player-7.has-city { fill: #3e2723; }

.game-board .edge.has-road {
  stroke: #888;
}

.game-board .edge.player-0.has-road { stroke: #e94560; }
.game-board .edge.player-1.has-road { stroke: #2196f3; }
.game-board .edge.player-2.has-road { stroke: #4caf50; }
.game-board .edge.player-3.has-road { stroke: #ff9800; }
.game-board .edge.player-4.has-road { stroke: #9c27b0; }
.game-board .edge.player-5.has-road { stroke: #00bcd4; }
.game-board .edge.player-6.has-road { stroke: #f44336; }
.game-board .edge.player-7.has-road { stroke: #795548; }

.game-board .edge {
  stroke: #333;
  stroke-width: 4;
  stroke-linecap: round;
}

.game-board .edge.has-road {
  stroke: #888;
}

.game-board .edge.clickable {
  stroke: #e94560;
  cursor: pointer;
}

.game-board .edge.clickable:hover {
  stroke: #ff6b6b;
  stroke-width: 6;
}

.game-board .node {
  fill: #1a1a2e;
  stroke: #444;
  stroke-width: 2;
}

.game-board .node.has-settlement {
  stroke: #fff;
}

.game-board .node.player-0.has-settlement { fill: #e94560; }
.game-board .node.player-1.has-settlement { fill: #2196f3; }
.game-board .node.player-2.has-settlement { fill: #4caf50; }
.game-board .node.player-3.has-settlement { fill: #ff9800; }
.game-board .node.player-4.has-settlement { fill: #9c27b0; }
.game-board .node.player-5.has-settlement { fill: #00bcd4; }
.game-board .node.player-6.has-settlement { fill: #f44336; }
.game-board .node.player-7.has-settlement { fill: #795548; }

.game-board .node.clickable {
  fill: #2a4a6f;
  cursor: pointer;
}

.game-board .node.clickable:hover {
  fill: #e94560;
  stroke: #fff;
}

/* Cities & Knights */
.game-board .hex.has-merchant {
  stroke: #ffd700;
  stroke-width: 3;
}

.game-board .knight-marker {
  fill: #333;
  stroke: #888;
  stroke-width: 1;
  pointer-events: all;
  cursor: pointer;
}

.game-board .knight-marker.knight-active {
  fill: #4caf50;
  stroke: #2e7d32;
}

.game-board .knight-marker.player-0 { stroke: #e94560; }
.game-board .knight-marker.player-1 { stroke: #2196f3; }
.game-board .knight-marker.player-2 { stroke: #4caf50; }
.game-board .knight-marker.player-3 { stroke: #ff9800; }
.game-board .knight-marker.player-4 { stroke: #9c27b0; }

.game-board .knight-level-text {
  font-size: 10px;
  font-weight: bold;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.ck-track, .ck-event-die {
  font-size: 0.9rem;
  margin: 0.25rem 0;
  color: var(--text-muted);
}

.badge-metropolis {
  background: #ff9800;
  color: #1a1a2e;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.knight-row {
  font-size: 0.85rem;
  margin: 0.35rem 0;
}

.btn-build-knight.active {
  background: #2e7d32;
}

.game-board .hex.clickable-merchant {
  cursor: pointer;
  stroke: #ffd700;
  stroke-width: 2;
}
