/**
 * main.css
 * Design system — shadcn-inspired dark zinc, gold primary, hairline borders.
 */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: oklch(0.145 0.012 264);
  --bg-surface: oklch(0.185 0.014 264);
  --bg-surface-elevated: oklch(0.22 0.014 264);
  --bg-surface-hover: oklch(0.255 0.014 264);
  --bg-input: oklch(0.16 0.012 264);
  --border-subtle: oklch(1 0 0 / 0.09);
  --border-focus: oklch(0.78 0.14 72);

  --gold-primary: oklch(0.78 0.145 72);
  --gold-hover: oklch(0.72 0.15 72);
  --gold-subtle: oklch(0.78 0.145 72 / 0.12);
  --gold-foreground: oklch(0.18 0.04 72);
  --crimson-accent: oklch(0.62 0.2 25);
  --emerald-accent: oklch(0.68 0.16 155);
  --cyan-accent: oklch(0.72 0.12 230);

  --text-primary: oklch(0.97 0.005 264);
  --text-secondary: oklch(0.72 0.02 264);
  --text-muted: oklch(0.70 0.02 264);

  --res-wood: #2d6a4f;
  --res-brick: #b91c1c;
  --res-wool: #15803d;
  --res-wheat: #ca8a04;
  --res-ore: #475569;
  --res-desert: #a16207;
  --comm-cloth: #7c3aed;
  --comm-coin: #ca8a04;
  --comm-paper: #0f766e;

  --font-heading: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.28);
  --shadow-md: 0 8px 24px oklch(0 0 0 / 0.32);
  --shadow-lg: 0 24px 48px oklch(0 0 0 / 0.45);
  --ring: 0 0 0 3px oklch(0.78 0.145 72 / 0.28);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, oklch(0.78 0.145 72 / 0.08), transparent 55%),
    radial-gradient(oklch(1 0 0 / 0.035) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em;
}

body::before {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app-header,
.view-screen {
  position: relative;
  z-index: 1;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: oklch(1 0 0 / 0.12);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: oklch(1 0 0 / 0.2);
}

.app-header {
  height: 56px;
  background: oklch(0.145 0.012 264 / 0.78);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
}

.brand-section:hover {
  opacity: 0.88;
}

.brand-section:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 3px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: oklch(0.78 0.145 72 / 0.12);
  border: 1px solid oklch(0.78 0.145 72 / 0.28);
  color: var(--gold-primary);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  transition: transform var(--transition-fast, 0.15s) ease;
}

.brand-section:hover .brand-logo-img {
  transform: scale(1.08);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: oklch(1 0 0 / 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  user-select: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px oklch(0 0 0 / 0.15);
  transition: opacity var(--transition-fast), border-color var(--transition-fast);
}

.match-timer-pill .ico {
  font-size: 14px;
  color: var(--gold-primary);
  opacity: 0.9;
  display: flex;
  align-items: center;
}

.match-timer-pill.is-hidden {
  display: none !important;
}

/* Buy Me a Coffee Header Pill */
.bmc-header-pill {
  background: linear-gradient(135deg, #FFDD00, #FBB03B) !important;
  color: #111 !important;
  font-weight: 700 !important;
  border: 1px solid rgba(0, 0, 0, 0.18) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 6px 14px !important;
  border-radius: 999px !important;
  text-decoration: none !important;
  box-shadow: 0 2px 10px rgba(255, 221, 0, 0.28);
  font-size: 13px !important;
  cursor: pointer;
  transition: all var(--transition-fast) !important;
}

.bmc-header-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255, 221, 0, 0.42);
  filter: brightness(1.05);
}

.bmc-header-pill .bmc-icon {
  font-size: 14px;
  line-height: 1;
}

@media (max-width: 768px) {
  .bmc-header-pill .bmc-label {
    display: none;
  }
  .bmc-header-pill {
    padding: 6px 10px !important;
  }
}

.btn-glass {
  background: oklch(1 0 0 / 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-glass:hover {
  background: oklch(1 0 0 / 0.08);
  border-color: oklch(1 0 0 / 0.16);
}

.btn-glass:active {
  transform: translateY(0.5px);
}

.btn-glass:focus-visible,
.btn-primary:focus-visible,
.btn-danger:focus-visible,
.lobby-tab-btn:focus-visible,
.btn-build-action:focus-visible,
.modal-close-btn:focus-visible,
.segmented-tab:focus-visible,
.sidebar-tab-btn:focus-visible,
.board-control-btn:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: 2px;
  box-shadow: none;
}

@media (pointer: coarse) {
  .btn-build-action,
  #btn-roll-dice,
  #btn-end-turn,
  .btn-glass.btn-primary {
    min-height: 44px;
  }
}

.btn-glass:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.btn-glass.btn-danger,
.btn-danger {
  background: oklch(0.48 0.22 25 / 0.85);
  border-color: oklch(0.62 0.22 25 / 0.9);
  color: #fff;
  font-weight: 600;
}

.btn-glass.btn-danger:hover,
.btn-danger:hover {
  background: oklch(0.55 0.24 25 / 0.95);
  border-color: oklch(0.7 0.22 25 / 1);
  box-shadow: 0 0 14px oklch(0.55 0.24 25 / 0.45);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.9;
}

.btn-icon.ico,
.btn-icon .ico {
  font-size: 16px;
}

.timer-icon.ico {
  font-size: 14px;
}

.ico-opp {
  font-size: 12px;
}

.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
  color: inherit;
}

.ico-svg {
  display: block;
  width: 1em;
  height: 1em;
}

.ico-error { color: #f87171; font-size: 16px; }
.ico-ok { color: var(--gold-primary); font-size: 16px; }

.brand-logo .ico { font-size: 22px; }

.btn-primary {
  background: var(--gold-primary);
  border: 1px solid oklch(0.85 0.12 72 / 0.35);
  color: var(--gold-foreground);
  font-weight: 650;
  box-shadow: 0 1px 0 oklch(1 0 0 / 0.18) inset, 0 8px 18px oklch(0.78 0.145 72 / 0.18);
  transition: all var(--transition-fast) ease;
}

.btn-primary:hover {
  background: var(--gold-hover);
  border-color: oklch(0.85 0.12 72 / 0.4);
  transform: translateY(-1.5px);
  box-shadow: 0 1px 0 oklch(1 0 0 / 0.25) inset, 0 10px 22px oklch(0.78 0.145 72 / 0.28);
}

.btn-primary:active {
  background: oklch(0.66 0.15 72);
  transform: translateY(0.5px) scale(0.985);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3) inset;
}

.btn-primary:disabled {
  opacity: 0.42;
  box-shadow: none;
  transform: none;
}

.btn-danger {
  background: oklch(0.42 0.14 25);
  border: 1px solid oklch(0.55 0.18 25 / 0.45);
  color: oklch(0.97 0.02 25);
  font-weight: 550;
}

.btn-danger:hover {
  background: oklch(0.48 0.16 25);
  border-color: oklch(0.58 0.18 25 / 0.55);
}

.btn-danger:active {
  transform: translateY(0.5px);
}

.view-screen {
  display: none;
  min-height: calc(100dvh - 56px);
}

.view-screen.active {
  display: flex;
}

#view-game.view-screen.active {
  flex-direction: column;
  height: calc(100dvh - 56px);
  min-height: 0;
  overflow: hidden;
}

#toast-container {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: oklch(0.18 0.014 264 / 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-left: 2px solid var(--gold-primary);
  color: var(--text-primary);
  padding: 11px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.toast-error {
  border-left-color: oklch(0.68 0.2 25);
}

.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-custom-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.toast.toast-card {
  border-left: 3px solid var(--gold-primary);
  background: linear-gradient(135deg, rgba(22, 30, 46, 0.98) 0%, rgba(12, 17, 30, 0.99) 100%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), 0 0 14px rgba(226, 185, 59, 0.25);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.toast.toast-dev-card {
  border-left-color: #fbbf24;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(251, 191, 36, 0.25);
}

.toast.toast-progress-science {
  border-left-color: #10b981;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(16, 185, 129, 0.25);
}

.toast.toast-progress-politics {
  border-left-color: #3b82f6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(59, 130, 246, 0.25);
}

.toast.toast-progress-trade {
  border-left-color: #f59e0b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(245, 158, 11, 0.25);
}

@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.rules-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.rules-guide-link {
  color: #f6ad55;
  text-decoration: underline;
  font-size: 0.9rem;
}
