/* ============================================================
   ACQUIRE - Board Game
   Retro/Nostalgic Theme Stylesheet
   Inspired by classic 1960s-70s board game aesthetics
   ============================================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=IBM+Plex+Mono:wght@300;400;500;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Surface colors */
  --felt-dark: #1a3a1a;
  --felt-medium: #163016;
  --felt-light: #1e4a1e;
  --cream: #f5f0e0;
  --cream-dark: #e8dfc8;
  --cream-light: #faf7ef;
  --paper: #f0e6d0;

  /* Accent colors */
  --gold: #DAA520;
  --gold-light: #f0c040;
  --gold-dark: #b8860b;
  --gold-glow: rgba(218, 165, 32, 0.35);

  /* Text colors */
  --text-light: #f0e6d0;
  --text-dark: #2a1f0e;
  --text-muted: #a09880;

  /* Chain colors (must match CHAIN_DEFS order in constants.js) */
  --chain-0: #DAA520;  /* Tower - gold */
  --chain-1: #CD5C5C;  /* Luxor - red */
  --chain-2: #4682B4;  /* American - blue */
  --chain-3: #2E8B57;  /* Festival - green */
  --chain-4: #8B6914;  /* Worldwide - brown */
  --chain-5: #008B8B;  /* Continental - teal */
  --chain-6: #7B2D8B;  /* Imperial - purple */

  /* Layout */
  --board-cell-size: 64px;
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  /* Fonts */
  --font-display: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s ease;
}


/* ============================================================
   1. RESET & BASE
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--felt-dark);
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(30, 74, 30, 0.5) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(30, 74, 30, 0.3) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='6' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='6' height='6' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  min-height: 100vh;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}

button {
  font-family: var(--font-mono);
  cursor: pointer;
  border: none;
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}


/* ============================================================
   2. SETUP SCREEN
   ============================================================ */

#setup-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  background-color: var(--felt-dark);
  background-image:
    radial-gradient(ellipse at center, rgba(30, 80, 30, 0.6) 0%, transparent 70%),
    url("data:image/svg+xml,%3Csvg width='6' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='6' height='6' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  padding: 2rem;
  text-align: center;
  animation: fadeIn 0.6s ease;
}

#setup-screen .title {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 20px rgba(218, 165, 32, 0.4),
    0 2px 0 var(--gold-dark),
    0 4px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  line-height: 1;
}

#setup-screen .subtitle {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 3rem;
  letter-spacing: 0.05em;
}

#setup-screen .setup-group {
  margin-bottom: 2rem;
  width: 100%;
  max-width: 560px;
}

#setup-screen .setup-group label,
#setup-screen .setup-label {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--cream);
  margin-bottom: 0.75rem;
  letter-spacing: 0.04em;
}

#setup-screen .selector-group {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

#setup-screen .selector-group .selector-option {
  position: relative;
  flex-shrink: 0;
}

#setup-screen .selector-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

#setup-screen .selector-group .selector-btn,
#setup-screen .selector-group label.selector-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 0.6rem 1.2rem;
  background: rgba(245, 240, 224, 0.08);
  border: 2px solid rgba(245, 240, 224, 0.2);
  border-radius: var(--radius-md);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition:
    background var(--transition-base),
    border-color var(--transition-base),
    color var(--transition-base),
    transform var(--transition-fast);
}

#setup-screen .selector-group .selector-btn:hover,
#setup-screen .selector-group label.selector-btn:hover {
  background: rgba(245, 240, 224, 0.15);
  border-color: var(--gold);
  color: var(--gold-light);
  transform: translateY(-1px);
}

#setup-screen .selector-group input[type="radio"]:checked + .selector-btn,
#setup-screen .selector-group .selector-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--text-dark);
  font-weight: 700;
  box-shadow: 0 0 12px var(--gold-glow);
}

#setup-screen .player-name-input {
  width: 100%;
  max-width: 280px;
  padding: 0.6rem 1rem;
  background: rgba(245, 240, 224, 0.08);
  border: 2px solid rgba(245, 240, 224, 0.2);
  border-radius: var(--radius-md);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-align: center;
  transition: border-color var(--transition-base);
}

#setup-screen .player-name-input:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 8px var(--gold-glow);
}

#setup-screen .start-btn {
  margin-top: 1.5rem;
  padding: 1rem 3.5rem;
  background: linear-gradient(180deg, var(--gold-light), var(--gold), var(--gold-dark));
  color: var(--text-dark);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.4),
    0 0 20px var(--gold-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base);
}

#setup-screen .start-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 6px 25px rgba(0, 0, 0, 0.5),
    0 0 35px var(--gold-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#setup-screen .start-btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.4),
    0 0 10px var(--gold-glow);
}


/* ============================================================
   3. GAME HEADER
   ============================================================ */

#game-header {
  background: var(--felt-medium);
  padding: 0.75rem 1.5rem;
  border-bottom: 2px solid var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#game-header h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 var(--gold-dark),
    0 0 10px rgba(218, 165, 32, 0.25);
}

#game-header .turn-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

#game-header .turn-info strong {
  color: var(--gold-light);
}


/* ============================================================
   4. GAME LAYOUT
   ============================================================ */

#game-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto auto;
  grid-template-areas:
    "board side"
    "controls log";
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 1600px;
  margin: 0 auto;
}

#board-area {
  grid-area: board;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#side-panel {
  grid-area: side;
}

#controls-area {
  grid-area: controls;
}

#game-layout > #message-log {
  grid-area: log;
}


/* ============================================================
   5. GAME BOARD
   ============================================================ */

#game-board {
  display: grid;
  grid-template-columns: 32px repeat(12, var(--board-cell-size));
  grid-template-rows: 28px repeat(9, var(--board-cell-size));
  gap: 2px;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(218, 165, 32, 0.3);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.4),
    0 2px 12px rgba(0, 0, 0, 0.3);
}

.board-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  user-select: none;
}

.board-header.col-header {
  font-size: 0.85rem;
}

.board-header.row-header {
  font-size: 0.8rem;
}

.board-header.corner {
  /* empty corner cell */
}

.board-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--board-cell-size);
  height: var(--board-cell-size);
  background: var(--cream);
  border: 1px solid #998b70;
  border-radius: var(--radius-sm);
  cursor: default;
  transition:
    background var(--transition-base),
    border-color var(--transition-base),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  overflow: hidden;
}

.cell-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: #8a7e6a;
  letter-spacing: -0.02em;
  user-select: none;
  line-height: 1;
}

/* Placed but no chain */
.board-cell.placed {
  background: #8a8a82;
  border-color: #6a6a62;
}

.board-cell.placed .cell-label {
  color: #c8c8c0;
}

/* Clickable / playable cells */
.board-cell.clickable {
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(218, 165, 32, 0.3);
}

.board-cell.clickable:hover {
  transform: scale(1.08);
  border-color: var(--gold);
  box-shadow:
    inset 0 0 0 2px var(--gold),
    0 0 8px var(--gold-glow);
  z-index: 5;
  filter: brightness(1.05);
}

.board-cell.clickable:active {
  transform: scale(0.96);
}

/* Chain-colored cells */
.board-cell.chain-0 { background: var(--chain-0); border-color: #b8860b; }
.board-cell.chain-1 { background: var(--chain-1); border-color: #a04040; }
.board-cell.chain-2 { background: var(--chain-2); border-color: #36648b; }
.board-cell.chain-3 { background: var(--chain-3); border-color: #236b46; }
.board-cell.chain-4 { background: var(--chain-4); border-color: #6b5510; }
.board-cell.chain-5 { background: var(--chain-5); border-color: #006b6b; }
.board-cell.chain-6 { background: var(--chain-6); border-color: #5e1f6b; }

.board-cell[class*="chain-"] .cell-label {
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Highlight board cell when hovering matching tile in rack */
.board-cell.tile-hover-highlight {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
  box-shadow: 0 0 12px var(--gold-glow);
  filter: brightness(1.15);
  z-index: 5;
  transition: outline 0.15s, box-shadow 0.15s, filter 0.15s;
}

/* Highlight for recently placed tile */
.board-cell.just-placed {
  animation: tilePlaced 0.4s ease;
}

@keyframes tilePlaced {
  0%   { transform: scale(0.7); opacity: 0.5; }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}


/* ============================================================
   6. SIDE PANEL
   ============================================================ */

#side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}


/* ============================================================
   7. PLAYER PANELS
   ============================================================ */

.player-card {
  background: rgba(245, 240, 224, 0.07);
  border: 1px solid rgba(245, 240, 224, 0.12);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    background var(--transition-base);
}

.player-card + .player-card {
  /* spacing handled by parent gap */
}

.player-card.current {
  border-color: var(--gold);
  box-shadow:
    0 0 12px var(--gold-glow),
    inset 0 0 15px rgba(218, 165, 32, 0.06);
  background: rgba(245, 240, 224, 0.1);
  animation: currentPulse 2.5s ease-in-out infinite;
}

@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 12px var(--gold-glow), inset 0 0 15px rgba(218, 165, 32, 0.06); }
  50%      { box-shadow: 0 0 20px rgba(218, 165, 32, 0.5), inset 0 0 20px rgba(218, 165, 32, 0.1); }
}

.player-card.human {
  border-left: 3px solid var(--gold-dark);
}

.player-card .player-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--cream);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-card .player-name .human-badge {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--gold);
  background: rgba(218, 165, 32, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.player-card .player-cash {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

.player-card .player-stocks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.stock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.stock-badge.chain-0 { background: var(--chain-0); }
.stock-badge.chain-1 { background: var(--chain-1); }
.stock-badge.chain-2 { background: var(--chain-2); }
.stock-badge.chain-3 { background: var(--chain-3); }
.stock-badge.chain-4 { background: var(--chain-4); }
.stock-badge.chain-5 { background: var(--chain-5); }
.stock-badge.chain-6 { background: var(--chain-6); }


/* ============================================================
   8. CHAIN INFO
   ============================================================ */

#chain-info {
  background: rgba(245, 240, 224, 0.07);
  border: 1px solid rgba(245, 240, 224, 0.12);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

#chain-info h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chain-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.2rem;
  border-bottom: 1px solid rgba(245, 240, 224, 0.06);
  font-size: 0.75rem;
  transition: opacity var(--transition-base);
}

.chain-row:last-child {
  border-bottom: none;
}

.chain-row.inactive {
  opacity: 0.4;
}

.chain-swatch {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.chain-swatch.chain-0 { background: var(--chain-0); }
.chain-swatch.chain-1 { background: var(--chain-1); }
.chain-swatch.chain-2 { background: var(--chain-2); }
.chain-swatch.chain-3 { background: var(--chain-3); }
.chain-swatch.chain-4 { background: var(--chain-4); }
.chain-swatch.chain-5 { background: var(--chain-5); }
.chain-swatch.chain-6 { background: var(--chain-6); }

.chain-name {
  flex: 1;
  font-weight: 600;
  color: var(--cream);
  min-width: 70px;
}

.chain-stat {
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

.chain-stat.price {
  color: var(--gold-light);
  font-weight: 600;
}

.chain-stat.size {
  color: var(--cream);
}


/* ============================================================
   9. CONTROLS AREA
   ============================================================ */

#controls-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}


/* ============================================================
   10. TILE RACK
   ============================================================ */

#tile-rack {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#tile-rack h3,
.rack-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 0.35rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: 100%;
}

.tile-button {
  width: 62px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--cream-light), var(--cream), var(--cream-dark));
  border: 2px solid #b0a890;
  border-radius: var(--radius-md);
  color: var(--text-dark);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition:
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  user-select: none;
}

.tile-button:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.3),
    0 0 8px var(--gold-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.tile-button:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 2px 3px rgba(0, 0, 0, 0.1);
}

.tile-button.unplayable {
  background: linear-gradient(180deg, #999, #888, #777);
  border-color: #666;
  color: #555;
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.tile-button.unplayable:hover {
  transform: none;
  border-color: #666;
  box-shadow: none;
}


/* ============================================================
   11. ACTION BUTTONS
   ============================================================ */

#action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#action-buttons button,
.action-btn {
  padding: 0.5rem 1.2rem;
  background: linear-gradient(180deg, #2d5a2d, #1e4a1e, #163016);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-md);
  color: var(--gold-light);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background var(--transition-base),
    border-color var(--transition-base),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#action-buttons button:hover,
.action-btn:hover {
  background: linear-gradient(180deg, #3a6a3a, #2d5a2d, #1e4a1e);
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 0 6px var(--gold-glow);
}

#action-buttons button:active,
.action-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#action-buttons button:disabled,
.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#action-buttons button.primary,
.action-btn.primary {
  background: linear-gradient(180deg, var(--gold-light), var(--gold), var(--gold-dark));
  color: var(--text-dark);
  border-color: var(--gold-dark);
  font-weight: 700;
}

#action-buttons button.primary:hover,
.action-btn.primary:hover {
  background: linear-gradient(180deg, #f5cc50, var(--gold-light), var(--gold));
}


/* ============================================================
   12. MESSAGE LOG
   ============================================================ */

#message-log {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(245, 240, 224, 0.1);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.72rem;
  line-height: 1.45;
}

#message-log h3,
.log-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 0.35rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.25rem 0.3rem;
  border-radius: var(--radius-sm);
  z-index: 1;
}

.log-entry {
  padding: 0.2rem 0.35rem;
  border-bottom: 1px solid rgba(245, 240, 224, 0.05);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-info {
  color: rgba(240, 230, 208, 0.85);
}

.log-action {
  color: var(--gold-light);
}

.log-bonus {
  color: #66bb6a;
}

.log-merger {
  color: #ff8a65;
}

.log-ai {
  color: #81d4fa;
}

.log-error {
  color: #ef5350;
}

.log-timestamp {
  color: rgba(240, 230, 208, 0.3);
  font-size: 0.6rem;
  margin-right: 0.3rem;
}

/* Custom scrollbar */
#message-log::-webkit-scrollbar {
  width: 6px;
}

#message-log::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

#message-log::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 3px;
}

#message-log::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}


/* ============================================================
   13. DIALOG OVERLAY
   ============================================================ */

#dialog-overlay,
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlayFadeIn 0.25s ease;
  backdrop-filter: blur(2px);
}

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

#dialog-overlay[hidden],
.dialog-overlay[hidden] {
  display: none;
}


/* ============================================================
   14. DIALOG CONTENT
   ============================================================ */

.dialog {
  background: linear-gradient(180deg, var(--cream-light), var(--cream), var(--cream-dark));
  color: var(--text-dark);
  max-width: 500px;
  width: 90%;
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow:
    0 15px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(218, 165, 32, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: dialogSlideIn 0.3s ease;
}

@keyframes dialogSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: #2a1f0e;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
  letter-spacing: 0.03em;
}

.dialog p {
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  color: #4a3f2e;
}

.dialog button {
  padding: 0.5rem 1.2rem;
  background: linear-gradient(180deg, #3a6a3a, #2d5a2d);
  border: 1px solid #1e4a1e;
  border-radius: var(--radius-md);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--transition-base),
    transform var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.dialog button:hover {
  background: linear-gradient(180deg, #4a7a4a, #3a6a3a);
  transform: translateY(-1px);
}

.dialog button:active {
  transform: translateY(1px);
}

.dialog button.primary {
  background: linear-gradient(180deg, var(--gold-light), var(--gold), var(--gold-dark));
  color: var(--text-dark);
  border-color: var(--gold-dark);
  font-weight: 700;
}

.dialog button.primary:hover {
  background: linear-gradient(180deg, #f5cc50, var(--gold-light), var(--gold));
}

/* Chain selection options */
.chain-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.chain-option {
  padding: 0.6rem 1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition:
    filter var(--transition-fast),
    transform var(--transition-fast),
    border-color var(--transition-fast);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chain-option:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.4);
}

.chain-option:active {
  transform: translateY(1px);
  filter: brightness(0.95);
}

.chain-option.chain-0 { background: var(--chain-0); }
.chain-option.chain-1 { background: var(--chain-1); }
.chain-option.chain-2 { background: var(--chain-2); }
.chain-option.chain-3 { background: var(--chain-3); }
.chain-option.chain-4 { background: var(--chain-4); }
.chain-option.chain-5 { background: var(--chain-5); }
.chain-option.chain-6 { background: var(--chain-6); }

/* Stock purchase controls */
.stock-purchases {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.stock-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  background: rgba(42, 31, 14, 0.06);
  border-radius: var(--radius-md);
}

.stock-row .chain-swatch {
  width: 20px;
  height: 20px;
}

.stock-row .chain-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-dark);
  min-width: 80px;
}

.stock-row .stock-price {
  font-size: 0.75rem;
  color: #6a5a3a;
  min-width: 50px;
}

.stock-counter {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
}

.stock-counter button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(180deg, #e8dfc8, #d5cbb0);
  border: 1px solid #b0a890;
  color: var(--text-dark);
  box-shadow: none;
}

.stock-counter button:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.stock-counter button:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.stock-counter button:hover {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: var(--text-dark);
  transform: none;
}

.stock-counter .count {
  width: 32px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-top: 1px solid #b0a890;
  border-bottom: 1px solid #b0a890;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}

/* Merger dispose-stock controls */
.dispose-section {
  margin: 1rem 0;
}

.dispose-section h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.dispose-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.8rem;
}


/* ============================================================
   15. GAME OVER DIALOG
   ============================================================ */

.dialog.game-over {
  max-width: 600px;
}

.dialog.game-over h2 {
  text-align: center;
  font-size: 1.8rem;
  color: var(--gold-dark);
  border-bottom-color: var(--gold-dark);
}

.scores-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.8rem;
}

.scores-table th {
  font-family: var(--font-display);
  font-weight: 700;
  color: #6a5a3a;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scores-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-dark);
}

.scores-table tr.winner {
  background: rgba(218, 165, 32, 0.15);
}

.scores-table tr.winner td {
  font-weight: 700;
  color: var(--gold-dark);
}

.scores-table tr.winner td:first-child::before {
  content: "\2605 ";
  color: var(--gold);
}

.scores-table .score-cash {
  font-weight: 600;
  text-align: right;
}

.scores-table .score-stocks {
  text-align: center;
}

.scores-table .score-total {
  font-weight: 700;
  text-align: right;
  color: var(--gold-dark);
}


/* ============================================================
   16. RESPONSIVE DESIGN
   ============================================================ */

@media (max-width: 1200px) {
  :root {
    --board-cell-size: 52px;
  }

  #game-layout {
    grid-template-columns: 1fr 280px;
    gap: 1rem;
    padding: 1rem;
  }

  #setup-screen .title {
    font-size: 3.5rem;
  }
}

@media (max-width: 900px) {
  :root {
    --board-cell-size: 42px;
  }

  /* Single column: board → tiles → side panel → log */
  #game-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "board"
      "controls"
      "side"
      "log";
    gap: 0.75rem;
    padding: 0.75rem;
  }

  #game-board {
    justify-self: center;
  }

  #side-panel {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .player-card {
    flex: 1;
    min-width: 200px;
  }

  #chain-info {
    flex: 1;
    min-width: 250px;
  }

  #game-header h1 {
    font-size: 1.3rem;
  }

  #setup-screen .title {
    font-size: 2.8rem;
  }

  #setup-screen .subtitle {
    font-size: 1rem;
  }

  .dialog {
    padding: 1.25rem;
    margin: 0.5rem;
  }
}

@media (max-width: 600px) {
  :root {
    --board-cell-size: 28px;
  }

  body {
    font-size: 0.78rem;
  }

  #game-board {
    grid-template-columns: 22px repeat(12, var(--board-cell-size));
    grid-template-rows: 20px repeat(9, var(--board-cell-size));
    gap: 1px;
    padding: 2px;
  }

  .board-header {
    font-size: 0.5rem;
  }

  .cell-label {
    font-size: 0.45rem;
  }

  .tile-button {
    width: 48px;
    height: 40px;
    font-size: 0.65rem;
  }

  #setup-screen .title {
    font-size: 2rem;
  }

  #setup-screen .start-btn {
    padding: 0.75rem 2.5rem;
    font-size: 1.1rem;
  }

  .dialog {
    max-width: 95%;
  }

  .dialog.game-over {
    max-width: 95%;
  }

  .scores-table {
    font-size: 0.7rem;
  }
}


/* ============================================================
   17. TRANSITIONS & ANIMATIONS
   ============================================================ */

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade-in utility */
.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-up {
  animation: slideUp 0.3s ease;
}

/* Smooth transitions for interactive elements */
a,
button,
input,
.board-cell,
.tile-button,
.player-card,
.chain-option,
.selector-btn {
  transition-property: color, background-color, border-color, box-shadow, transform, opacity;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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

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

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

.font-display {
  font-family: var(--font-display);
}

.font-mono {
  font-family: var(--font-mono);
}
