/* ───────────────────────────────────────────
   Civ — Dark Monumental / Ancient Cartography
   Full Game UI Stylesheet
   ─────────────────────────────────────────── */

:root {
  --bg-deep:     #0e0d0b;
  --bg-surface:  #1a1815;
  --bg-card:     #15140f;
  --bg-card-alt: #1c1a14;
  --bg-hover:    #1e1c16;
  --bg-elevated: #211f18;
  --gold:        #c9a84c;
  --gold-bright: #e4c76b;
  --gold-dim:    #8a7435;
  --gold-ghost:  rgba(201,168,76,0.08);
  --gold-glow:   rgba(201,168,76,0.15);
  --text:        #d4cfc3;
  --text-dim:    #7e7969;
  --text-bright: #f0ece2;
  --error:       #c44d3e;
  --error-dim:   #8a3028;
  --success:     #5f9e5c;
  --success-dim: #3a6638;
  --info:        #5b8dd9;
  --warning:     #d4a84c;
  --radius:      4px;
  --radius-lg:   8px;
  --radius-xl:   12px;
  --font-display: 'Cinzel', Georgia, serif;
  --font-body:    'Crimson Pro', 'Georgia', serif;

  /* Terrain colors */
  --terrain-grassland: #2d4a2d;
  --terrain-grassland-light: #3a5c3a;
  --terrain-forest:    #1a3a1a;
  --terrain-forest-light: #245024;
  --terrain-mountain:  #4a4a4a;
  --terrain-mountain-light: #5a5a5a;
  --terrain-desert:    #6b5a3a;
  --terrain-desert-light: #7d6b48;
  --terrain-water:     #1a2a4a;
  --terrain-water-light: #243a5c;
  --terrain-plains:    #4a5a2a;
  --terrain-plains-light: #5a6b38;
  --terrain-fog:       #12110e;

  /* Spacing */
  --sidebar-width: 240px;
  --topbar-height: 52px;
  --bottombar-height: 48px;
}

/* ── Hidden attribute fix ────────────────── */
[hidden] { display: none !important; }

/* ── 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 {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Film-grain overlay ─────────────────── */

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' 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");
}

/* ── Decorative border frame ────────────── */

.border-frame {
  position: fixed;
  inset: 12px;
  border: 1px solid var(--gold-dim);
  pointer-events: none;
  z-index: 100;
  opacity: 0.4;
}
.border-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--gold);
  border-style: solid;
}
.border-tl { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.border-tr { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.border-bl { bottom: -1px; left: -1px; border-width: 0 0 2px 2px; }
.border-br { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

/* ── Shared button styles ───────────────── */

.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, var(--gold-dim) 0%, var(--gold) 50%, var(--gold-dim) 100%);
  background-size: 200% 200%;
  color: var(--bg-deep);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}
.btn-submit:hover:not(:disabled) {
  background-position: 100% 100%;
  box-shadow: 0 0 16px rgba(201,168,76,0.3);
  transform: translateY(-1px);
}
.btn-submit:active:not(:disabled) { transform: translateY(0); }
.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-submit.loading .btn-label { opacity: 0; }
.btn-submit.loading .btn-spinner { display: inline-block; }
.btn-spinner {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--bg-deep);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-secondary:hover {
  background: var(--gold-ghost);
  border-color: var(--gold);
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--gold-dim);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.2s;
}
.btn-text:hover { color: var(--gold); }
.btn-text svg { width: 14px; height: 14px; }

.form-switch {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}
.form-switch .btn-text {
  font-size: 0.78rem;
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: rgba(201,168,76,0.3);
  text-underline-offset: 2px;
}
.form-switch .btn-text:hover {
  text-decoration-color: var(--gold);
}

/* ── Form field styles ──────────────────── */

.field { margin-bottom: 1.2rem; }
.field label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.35rem;
}
.field input,
.field select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.1);
}
.field input::placeholder { color: var(--text-dim); font-style: italic; }
.field-hint {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
}
.field-error {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--error);
  min-height: 1.1em;
}

.password-wrap {
  position: relative;
}
.password-wrap input { padding-right: 2.5rem; }
.pw-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0.25rem;
  line-height: 0;
  transition: color 0.2s;
}
.pw-toggle:hover { color: var(--gold); }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle .eye-closed { display: none; }
.pw-toggle.active .eye-open { display: none; }
.pw-toggle.active .eye-closed { display: inline; }

.form-message { margin-top: 0.75rem; font-size: 0.82rem; text-align: center; min-height: 1.2em; }
.form-message.error { color: var(--error); }
.form-message.success { color: var(--success); }

.divider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.2rem 0;
}
.divider-line { flex: 1; height: 1px; background: rgba(201,168,76,0.12); }
.divider-text {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}


/* ════════════════════════════════════════════
   SIGN-UP VIEW
   ════════════════════════════════════════════ */

.page {
  display: flex;
  min-height: 100vh;
  position: relative;
}
.hero-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(201,168,76,0.06) 0%, transparent 60%),
    var(--bg-deep);
}
.hero-content { text-align: center; max-width: 360px; }
.sigil {
  width: 100px;
  height: 100px;
  margin: 0 auto 1.5rem;
  color: var(--gold);
  opacity: 0.7;
  animation: sigil-rotate 30s linear infinite;
}
@keyframes sigil-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.hero-title { margin-bottom: 1rem; }
.hero-title-sub {
  display: block;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.hero-title-main {
  display: block;
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(201,168,76,0.2);
}
.hero-blurb {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-dim);
  font-style: italic;
}

.form-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-surface);
  border-left: 1px solid rgba(201,168,76,0.08);
}
.signup-card {
  width: 100%;
  max-width: 340px;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: var(--radius-lg);
}
.card-heading {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 1.5rem;
  text-align: center;
  letter-spacing: 0.04em;
}

/* ════════════════════════════════════════════
   LOBBY VIEW
   ════════════════════════════════════════════ */

.lobby-view {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201,168,76,0.04) 0%, transparent 50%),
    var(--bg-deep);
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid rgba(201,168,76,0.1);
}
.lobby-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.lobby-sigil {
  width: 28px;
  height: 28px;
  color: var(--gold);
}
.lobby-brand-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.lobby-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.lobby-username {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--text);
  letter-spacing: 0.04em;
}

.lobby-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.lobby-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem;
  margin-bottom: 2rem;
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.lobby-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 80% 50%, rgba(201,168,76,0.06) 0%, transparent 60%);
  pointer-events: none;
}
.lobby-hero-text { position: relative; z-index: 1; }
.lobby-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}
.lobby-subtitle {
  font-size: 0.92rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.lobby-actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.btn-lobby-action {
  white-space: nowrap;
  min-width: 160px;
}
.btn-lobby-action svg { width: 16px; height: 16px; }

.lobby-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.lobby-panel {
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lobby-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(201,168,76,0.08);
  background: var(--bg-card-alt);
}
.lobby-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lobby-panel-title svg { width: 16px; height: 16px; }

.lobby-game-list {
  padding: 0.5rem;
  max-height: 360px;
  overflow-y: auto;
}

.lobby-game-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}
.lobby-game-card:hover {
  background: var(--bg-hover);
  border-color: rgba(201,168,76,0.1);
}
.lobby-game-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.15);
  flex-shrink: 0;
}
.lobby-game-card-info { flex: 1; min-width: 0; }
.lobby-game-card-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.02em;
}
.lobby-game-card-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.lobby-game-card-status {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  flex-shrink: 0;
}
.lobby-game-card-status.waiting {
  color: var(--gold);
  background: rgba(201,168,76,0.1);
}
.lobby-game-card-status.in-progress {
  color: var(--success);
  background: rgba(95,158,92,0.1);
}
.lobby-game-card-status.completed {
  color: var(--text-dim);
  background: rgba(126,121,105,0.1);
}

.lobby-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
}

/* ════════════════════════════════════════════
   SETUP VIEW
   ════════════════════════════════════════════ */

.setup-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(201,168,76,0.04) 0%, transparent 50%),
    var(--bg-deep);
}
.setup-container {
  width: 100%;
  max-width: 780px;
}
.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.btn-back { margin-right: auto; }
.setup-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.setup-sigil {
  width: 24px;
  height: 24px;
  color: var(--gold);
}
.setup-brand-text {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.setup-body {
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: var(--radius-lg);
  padding: 2rem;
}
.setup-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.setup-subtitle {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.setup-panel {
  padding: 1.2rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
}
.panel-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.panel-icon { width: 16px; height: 16px; }

.civ-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.civ-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.4rem;
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.civ-card:hover {
  border-color: var(--gold-dim);
  background: var(--bg-hover);
}
.civ-card.selected {
  border-color: var(--gold);
  background: rgba(201,168,76,0.08);
  box-shadow: 0 0 12px rgba(201,168,76,0.15);
}
.civ-card-icon { font-size: 1.3rem; line-height: 1; }
.civ-card-name {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
}

.civ-ability {
  padding: 0.75rem;
  background: rgba(201,168,76,0.04);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: var(--radius);
  margin-top: 1rem;
}
.civ-ability-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.2rem;
}
.civ-ability-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.btn-launch {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  padding: 0.85rem;
  font-size: 0.88rem;
}


/* ════════════════════════════════════════════
   GAME VIEW
   ════════════════════════════════════════════ */

.game-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-deep);
}

/* ── Phase Banner ─────────────────────────── */

.phase-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0,0,0,0.4);
  animation: phase-banner-fade 1.6s ease-out forwards;
}
@keyframes phase-banner-fade {
  0% { opacity: 0; }
  15% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.phase-banner-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  animation: phase-banner-slide 1.6s ease-out forwards;
}
@keyframes phase-banner-slide {
  0% { transform: translateY(20px) scale(0.95); opacity: 0; }
  15% { transform: translateY(0) scale(1); opacity: 1; }
  70% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-10px) scale(1.02); opacity: 0; }
}

.phase-banner-line {
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.phase-banner-content { text-align: center; }
.phase-banner-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.2rem;
}
.phase-banner-text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(201,168,76,0.4);
  text-transform: uppercase;
}

/* ── Top Bar ──────────────────────────────── */

.game-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid rgba(201,168,76,0.12);
  z-index: 10;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.topbar-brand { display: flex; align-items: center; }
.topbar-sigil { width: 22px; height: 22px; color: var(--gold); }
.topbar-info { display: flex; align-items: center; gap: 0.4rem; }
.topbar-turn {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.topbar-sep { color: var(--text-dim); font-size: 0.6rem; }
.topbar-phase {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-center { display: flex; align-items: center; }
.topbar-player { display: flex; align-items: center; gap: 0.4rem; }
.topbar-player-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
}
.topbar-player-name {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-bright);
}
.topbar-player-civ {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.topbar-right { display: flex; align-items: center; }
.topbar-resources {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.resource-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.2s;
  min-width: 48px;
}
.resource-item:hover { background: var(--bg-hover); }
.resource-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.resource-icon svg { width: 14px; height: 14px; }
.resource-trade svg { color: #6cb4ee; }
.resource-production svg { color: #d4884c; }
.resource-coins svg { color: var(--gold-bright); }
.resource-culture svg { color: #b87ae8; }
.resource-tech svg { color: #8ccf8c; }
.resource-value {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-bright);
}
.resource-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Game Content ─────────────────────────── */

.game-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebars ─────────────────────────────── */

.game-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: margin 0.3s ease;
}
.sidebar-left { border-right: 1px solid rgba(201,168,76,0.08); }
.sidebar-right { border-left: 1px solid rgba(201,168,76,0.08); }

.sidebar-section {
  padding: 0.6rem;
  border-bottom: 1px solid rgba(201,168,76,0.06);
}
.sidebar-section-grow {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-heading {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.5rem;
}

/* Player list */
.player-list { display: flex; flex-direction: column; gap: 0.3rem; }
.player-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.2s;
  border: 1px solid transparent;
}
.player-card.active {
  background: var(--gold-ghost);
  border-color: rgba(201,168,76,0.12);
}
.player-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.2);
}
.player-card-info { flex: 1; min-width: 0; }
.player-card-name {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-card-civ {
  font-size: 0.62rem;
  color: var(--text-dim);
}
.player-card-stats {
  display: flex;
  gap: 0.35rem;
  font-size: 0.6rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Game log */
.game-log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.72rem;
  line-height: 1.4;
  padding-right: 0.2rem;
}
.log-entry {
  padding: 0.2rem 0;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(201,168,76,0.03);
}
.log-turn {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--gold-dim);
  margin-right: 0.3rem;
}

/* Selection info */
.selection-info {
  font-size: 0.82rem;
}
.selection-empty {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.78rem;
}
.selection-terrain {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.15rem;
}
.selection-coords {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.selection-units, .selection-city { margin-top: 0.5rem; }
.selection-unit-item,
.selection-city-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
  margin-bottom: 0.3rem;
}
.selection-unit-item:hover,
.selection-city-item:hover { background: var(--bg-hover); }
.selection-unit-item.selected {
  background: var(--gold-ghost);
  border-color: rgba(201,168,76,0.2);
}
.unit-badge {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--bg-deep);
  flex-shrink: 0;
  font-family: var(--font-display);
}
.unit-info { flex: 1; min-width: 0; }
.unit-name {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
}
.unit-stats {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* Action buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.btn-action {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.btn-action:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.btn-action svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Map Viewport ─────────────────────────── */

.map-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-deep);
  cursor: default;
}

.map-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
  width: fit-content;
  transform-origin: top left;
  transition: transform 0.15s ease;
}

/* Tile rows — flex row for each row of tiles */
.map-tile-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Map Tiles (Board Game Style) ────────── */

.map-tile {
  border: 2px solid rgba(201,168,76,0.2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  background: var(--terrain-fog);
}

.map-tile.tile-revealed {
  display: grid;
  gap: 1px;
  background: rgba(0,0,0,0.35);
  border-color: rgba(201,168,76,0.25);
}

.map-tile.home-tile {
  border-width: 2px;
  box-shadow: 0 0 8px rgba(201,168,76,0.15);
}

.map-tile.tile-facedown {
  cursor: default;
  background:
    radial-gradient(circle at 50% 50%, #2a2518 0%, #1e1b14 40%, var(--terrain-fog) 80%);
  border-color: rgba(201,168,76,0.15);
}

.tile-facedown-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.tile-facedown-pattern {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  opacity: 0.55;
}
.tile-facedown-pattern svg {
  width: 80%;
  height: 80%;
}

/* ── Map Cells (inside tiles) ────────────── */

.map-cell {
  width: 64px;
  height: 64px;
  position: relative;
  cursor: pointer;
  transition: outline-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.map-cell:hover {
  outline: 2px solid rgba(201,168,76,0.5);
  z-index: 2;
  box-shadow: inset 0 0 8px rgba(201,168,76,0.1);
}

/* Terrain types */
.map-cell.t-grassland {
  background: var(--terrain-grassland);
  background-image:
    radial-gradient(circle at 25% 35%, var(--terrain-grassland-light) 0%, transparent 40%),
    radial-gradient(circle at 70% 70%, rgba(60,90,60,0.3) 0%, transparent 35%),
    repeating-linear-gradient(120deg, transparent 0%, transparent 95%, rgba(80,120,80,0.07) 95%, rgba(80,120,80,0.07) 100%);
}
.map-cell.t-forest {
  background: var(--terrain-forest);
  background-image:
    radial-gradient(circle at 30% 30%, var(--terrain-forest-light) 0%, transparent 45%),
    radial-gradient(circle at 65% 65%, rgba(20,60,20,0.5) 0%, transparent 30%),
    radial-gradient(circle at 50% 50%, rgba(15,35,15,0.3) 0%, transparent 70%);
}
.map-cell.t-mountain {
  background: var(--terrain-mountain);
  background-image:
    linear-gradient(135deg, var(--terrain-mountain-light) 0%, var(--terrain-mountain) 30%, #3a3a3a 60%, #4a4a4a 100%),
    radial-gradient(ellipse at 40% 30%, rgba(100,100,100,0.15) 0%, transparent 60%);
}
.map-cell.t-desert {
  background: var(--terrain-desert);
  background-image:
    radial-gradient(circle at 40% 40%, var(--terrain-desert-light) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(100,85,55,0.3) 0%, transparent 30%),
    repeating-linear-gradient(160deg, transparent 0%, transparent 92%, rgba(140,120,80,0.06) 92%, rgba(140,120,80,0.06) 100%);
}
.map-cell.t-water {
  background: var(--terrain-water);
  background-image:
    linear-gradient(180deg, var(--terrain-water-light) 0%, var(--terrain-water) 100%),
    radial-gradient(ellipse at 50% 40%, rgba(50,80,130,0.2) 0%, transparent 80%);
  animation: water-shimmer 4s ease-in-out infinite;
}
@keyframes water-shimmer {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 2px 1px; }
}
.map-cell.t-plains {
  background: var(--terrain-plains);
  background-image:
    radial-gradient(circle at 50% 50%, var(--terrain-plains-light) 0%, transparent 60%),
    repeating-linear-gradient(135deg, transparent 0%, transparent 93%, rgba(90,110,50,0.05) 93%, rgba(90,110,50,0.05) 100%);
}
/* t-fog no longer used on individual cells — face-down is tile-level */
.map-cell.t-fog {
  background: var(--terrain-fog);
}

/* Terrain icons */
.map-cell .terrain-icon {
  position: absolute;
  bottom: 3px;
  left: 3px;
  font-size: 0.7rem;
  opacity: 0.3;
  pointer-events: none;
  line-height: 1;
}

/* Coordinate labels (legacy, kept for compat) */
.map-coord-corner { display: none; }
.map-coord-col { display: none; }
.map-coord-row { display: none; }

/* Yield pips */
.cell-yields {
  position: absolute;
  bottom: 2px;
  right: 2px;
  display: flex;
  gap: 1px;
  pointer-events: none;
}
.yield-pip {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0.5;
}
.yield-pip.trade { background: #6cb4ee; }
.yield-pip.prod { background: #d4884c; }

/* Cell selection & targets */
.map-cell.selected {
  outline: 2px solid var(--gold) !important;
  box-shadow: inset 0 0 12px rgba(201,168,76,0.3);
  z-index: 3;
}
.map-cell.move-target {
  outline: 1px solid rgba(91,141,217,0.5) !important;
  box-shadow: inset 0 0 10px rgba(91,141,217,0.2);
}
.map-cell.move-target::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(91,141,217,0.12);
  pointer-events: none;
  animation: pulse-move 1.5s ease-in-out infinite;
}
@keyframes pulse-move {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.map-cell.attack-target {
  outline: 1px solid rgba(196,77,62,0.6) !important;
  box-shadow: inset 0 0 10px rgba(196,77,62,0.25);
}
.map-cell.attack-target::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(196,77,62,0.12);
  pointer-events: none;
  animation: pulse-attack 1s ease-in-out infinite;
}
@keyframes pulse-attack {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.map-tile.tile-facedown.discover-target {
  outline: 2px solid rgba(91,141,217,0.7);
  box-shadow: 0 0 0 2px rgba(91,141,217,0.15), inset 0 0 24px rgba(91,141,217,0.12);
}
.map-tile.tile-facedown.discover-target .tile-facedown-inner::after {
  content: 'DISCOVER';
  position: absolute;
  inset: auto 10px 10px 10px;
  padding: 0.3rem 0.45rem;
  border: 1px solid rgba(91,141,217,0.55);
  background: rgba(17, 26, 40, 0.72);
  color: rgba(189, 214, 255, 0.95);
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-align: center;
  border-radius: 999px;
  pointer-events: none;
}

/* Cell overlays */
.cell-village {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background: var(--gold-dim);
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  opacity: 0.85;
  box-shadow: 0 0 4px rgba(201,168,76,0.3);
}
.cell-village::after {
  content: '\2302';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.45rem;
  color: var(--bg-deep);
  font-weight: 700;
}
.cell-resource {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 0.75rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}

/* City display on map */
.cell-city { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.city-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 5px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--bg-deep);
  position: relative;
  z-index: 1;
  border: 2px solid rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.city-pop {
  position: relative;
  z-index: 1;
}
.city-marker.capital {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201,168,76,0.4), 0 2px 8px rgba(0,0,0,0.5);
}
.city-marker.capital::before {
  content: '\2605';
  position: absolute;
  top: -8px;
  right: -6px;
  font-size: 0.55rem;
  color: var(--gold);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}
.city-name-label {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-bright);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,1);
  letter-spacing: 0.04em;
  pointer-events: none;
  background: rgba(14,13,11,0.5);
  padding: 0 3px;
  border-radius: 2px;
}

/* Unit display on map */
.cell-units {
  position: absolute;
  top: 2px;
  left: 2px;
  display: flex;
  gap: 2px;
  z-index: 2;
}
.unit-marker {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bg-deep);
  border: 1.5px solid rgba(0,0,0,0.3);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  font-family: var(--font-display);
  transition: transform 0.15s, box-shadow 0.15s;
}
.unit-marker.unit-selected {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(201,168,76,0.5), 0 1px 4px rgba(0,0,0,0.4);
  transform: scale(1.15);
  z-index: 3;
}
.unit-marker.unit-more {
  background: var(--bg-surface) !important;
  color: var(--text-dim);
  font-size: 0.5rem;
  border-color: rgba(201,168,76,0.2);
}

/* ── Minimap ──────────────────────────────── */

.minimap-wrapper {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  background: var(--bg-card-alt);
  border-bottom: 1px solid rgba(201,168,76,0.1);
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--gold-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.minimap-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.15rem;
  transition: color 0.2s;
}
.minimap-close:hover { color: var(--text); }
#minimap-canvas {
  display: block;
  cursor: pointer;
}

/* ── Zoom Controls ────────────────────────── */

.zoom-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  z-index: 20;
}
.zoom-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}
.zoom-btn:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.zoom-btn svg { width: 14px; height: 14px; }
.zoom-level {
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--text-dim);
  padding: 0.15rem 0;
}

/* ── Map Hint ─────────────────────────────── */

.map-hint {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  color: var(--text-dim);
  background: rgba(14,13,11,0.85);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid rgba(201,168,76,0.08);
  z-index: 20;
  opacity: 0.7;
  pointer-events: none;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.map-hint span {
  font-family: var(--font-display);
  color: var(--gold-dim);
  font-weight: 600;
  font-size: 0.6rem;
}

/* ── Bottom Bar ───────────────────────────── */

.game-bottombar {
  height: var(--bottombar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  background: var(--bg-surface);
  border-top: 1px solid rgba(201,168,76,0.12);
  z-index: 10;
  flex-shrink: 0;
}
.bottombar-left,
.bottombar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.bottombar-center { display: flex; align-items: center; }

.btn-game {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-game:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.btn-game svg { width: 14px; height: 14px; }

.btn-end-phase {
  padding: 0.5rem 1.8rem;
  font-size: 0.75rem;
}


/* ════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
}
.modal {
  position: relative;
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: var(--radius-lg);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: modal-in 0.25s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-sm { width: 360px; }
.modal-md { width: 500px; }
.modal-lg { width: 640px; }
.modal-xl { width: 860px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(201,168,76,0.1);
  background: var(--bg-card-alt);
  flex-shrink: 0;
}
.modal-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.modal-close:hover {
  color: var(--text);
  border-color: rgba(201,168,76,0.1);
  background: var(--bg-hover);
}
.modal-close svg { width: 14px; height: 14px; }

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(201,168,76,0.1);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Tech Tree Modal ──────────────────────── */

.tech-trade-display {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: #6cb4ee;
  letter-spacing: 0.03em;
}

.tech-level { margin-bottom: 1.2rem; }
.tech-level:last-child { margin-bottom: 0; }
.tech-level-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.tech-card {
  padding: 0.6rem;
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
  background: var(--bg-deep);
  transition: all 0.2s;
}
.tech-card.available {
  border-color: rgba(91,141,217,0.3);
  cursor: pointer;
}
.tech-card.available:hover {
  border-color: var(--info);
  background: rgba(91,141,217,0.05);
  box-shadow: 0 0 10px rgba(91,141,217,0.1);
}
.tech-card.researched {
  border-color: rgba(95,158,92,0.3);
  background: rgba(95,158,92,0.05);
}
.tech-card.locked {
  opacity: 0.45;
}
.tech-card-name {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 0.15rem;
}
.tech-card-cost {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.tech-card-desc {
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.3;
  margin-bottom: 0.25rem;
}
.tech-card-status {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tech-card.researched .tech-card-status { color: var(--success); }
.tech-card.available .tech-card-status { color: var(--info); }
.tech-card.locked .tech-card-status { color: var(--text-dim); }

/* ── City Modal ───────────────────────────── */

.city-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.city-stat-card {
  text-align: center;
  padding: 0.6rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
}
.city-stat-value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gold);
}
.city-stat-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}

.city-section-title {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(201,168,76,0.08);
}

.city-buildings-section { margin-bottom: 1rem; }
.existing-building {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 3px;
}

.city-production-section { margin-bottom: 1rem; }
.build-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.4rem;
}
.build-option {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.6rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
}
.build-option:hover:not(:disabled) {
  border-color: var(--gold-dim);
  background: var(--bg-hover);
}
.build-option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.build-option-name {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-bright);
}
.build-option-cost {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}
.build-option-desc {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
  line-height: 1.3;
}

/* ── Combat Modal ─────────────────────────── */

.combat-display { text-align: center; padding: 0.5rem 0; }
.combat-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.combat-side { text-align: center; min-width: 120px; }
.combat-side-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--bg-deep);
  margin-bottom: 0.3rem;
}
.combat-side-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.combat-side-str {
  font-size: 0.68rem;
  color: var(--text-dim);
}
.combat-side-name {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.combat-vs-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.1em;
}
.combat-result {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.combat-result.victory { color: var(--success); }
.combat-result.defeat { color: var(--error); }
.combat-rolls {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Victory Modal ────────────────────────── */

.victory-modal {
  text-align: center;
  overflow: visible;
}
.victory-content { padding: 2rem 1.5rem; }
.victory-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.victory-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.06em;
  text-shadow: 0 0 30px rgba(201,168,76,0.3);
  margin-bottom: 0.3rem;
}
.victory-type {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.victory-player {
  font-size: 0.92rem;
  color: var(--text);
}

/* ── Game Menu Modal ──────────────────────── */

.menu-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.btn-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.btn-menu-item:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
}
.btn-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--gold-dim); }
.btn-menu-danger { color: var(--error); }
.btn-menu-danger svg { color: var(--error-dim); }
.menu-divider {
  height: 1px;
  background: rgba(201,168,76,0.08);
  margin: 0.3rem 0;
}

/* ── City List Modal ──────────────────────── */

.city-list-grid { display: flex; flex-direction: column; gap: 0.4rem; }
.city-list-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.city-list-card:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
}
.city-list-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.city-list-info { flex: 1; min-width: 0; }
.city-list-name {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-bright);
}
.city-list-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}
.city-list-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.62rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Load Game Modal ──────────────────────── */

.saved-game-list { display: flex; flex-direction: column; gap: 0.4rem; }
.saved-game-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.saved-game-card:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
}
.saved-game-info { }
.saved-game-name {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-bright);
}
.saved-game-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.saved-game-delete {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}
.saved-game-delete:hover {
  color: var(--error);
  border-color: rgba(196,77,62,0.2);
}

/* ── Tooltip ──────────────────────────────── */

.tooltip {
  position: fixed;
  z-index: 2000;
  padding: 0.5rem 0.65rem;
  background: rgba(20,18,15,0.96);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: var(--radius);
  font-size: 0.72rem;
  color: var(--text);
  pointer-events: none;
  max-width: 240px;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.tooltip-title {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.15rem;
}
.tooltip-coords {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.tooltip-yields {
  display: flex;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}
.tooltip-yields .yield-trade { color: #6cb4ee; }
.tooltip-yields .yield-prod { color: #d4884c; }
.tooltip-resource {
  font-size: 0.65rem;
  color: var(--gold-dim);
  margin-top: 0.1rem;
}
.tooltip-city {
  font-size: 0.65rem;
  color: var(--text);
}
.tooltip-units {
  font-size: 0.62rem;
  color: var(--text-dim);
}

/* ── Toast Notifications ──────────────────── */

.toast-container {
  position: fixed;
  bottom: 60px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 500;
  max-width: 340px;
  pointer-events: auto;
  animation: toast-in 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-info {
  background: rgba(91,141,217,0.15);
  border: 1px solid rgba(91,141,217,0.3);
  color: #a8c8f0;
}
.toast-success {
  background: rgba(95,158,92,0.15);
  border: 1px solid rgba(95,158,92,0.3);
  color: #a8dfa6;
}
.toast-error {
  background: rgba(196,77,62,0.15);
  border: 1px solid rgba(196,77,62,0.3);
  color: #e8a8a0;
}
.toast-warning {
  background: rgba(212,168,76,0.15);
  border: 1px solid rgba(212,168,76,0.3);
  color: var(--gold-bright);
}


/* ════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════ */

/* ── AI Turn Indicator ────────────────────── */

.btn-end-phase:disabled {
  animation: ai-thinking 1.5s ease-in-out infinite;
}
@keyframes ai-thinking {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.35; }
}

/* ── Game view scrollbar ─────────────────── */

.map-viewport::-webkit-scrollbar { width: 8px; height: 8px; }
.map-viewport::-webkit-scrollbar-track { background: var(--bg-deep); }
.map-viewport::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 4px; }
.map-viewport::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,0.35); }
.map-viewport::-webkit-scrollbar-corner { background: var(--bg-deep); }

@media (max-width: 900px) {
  .page { flex-direction: column; }
  .hero-col { padding: 1.5rem; }
  .form-col { border-left: none; border-top: 1px solid rgba(201,168,76,0.08); }
  .setup-grid { grid-template-columns: 1fr; }
  .lobby-panels { grid-template-columns: 1fr; }
  .lobby-hero { flex-direction: column; text-align: center; }
  .lobby-actions { justify-content: center; }
  .game-sidebar { width: 200px; }
  .city-overview { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .game-sidebar {
    position: absolute;
    z-index: 15;
    height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
    top: var(--topbar-height);
  }
  .sidebar-left { left: 0; }
  .sidebar-right { right: 0; }
  :root { --sidebar-width: 220px; }
}


/* ════════════════════════════════════════════
   PHASE PROGRESS INDICATOR
   ════════════════════════════════════════════ */

.phase-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0.35rem 1rem;
  background: var(--bg-card-alt);
  border-top: 1px solid rgba(201,168,76,0.06);
  flex-shrink: 0;
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.6rem;
  position: relative;
  cursor: default;
  transition: opacity 0.3s;
  opacity: 0.35;
}
.phase-step.active {
  opacity: 1;
}
.phase-step.completed {
  opacity: 0.65;
}

.phase-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-dim);
  background: transparent;
  transition: all 0.3s;
}
.phase-step.active .phase-step-dot {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 8px rgba(201,168,76,0.5);
}
.phase-step.completed .phase-step-dot {
  border-color: var(--success);
  background: var(--success);
}

.phase-step-label {
  font-family: var(--font-display);
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: color 0.3s;
  white-space: nowrap;
}
.phase-step.active .phase-step-label {
  color: var(--gold);
}
.phase-step.completed .phase-step-label {
  color: var(--success);
}

.phase-step-line {
  width: 32px;
  height: 1px;
  background: rgba(201,168,76,0.15);
  flex-shrink: 0;
  margin-bottom: 14px; /* align with dot center */
  transition: background 0.3s;
}
.phase-step-line.completed {
  background: var(--success);
}


/* ════════════════════════════════════════════
   RESOURCE GAIN POPUP
   ════════════════════════════════════════════ */

.resource-gain-popup {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: rgba(14,13,11,0.95);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: resource-gain-in 0.4s ease-out;
  pointer-events: none;
}
@keyframes resource-gain-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.resource-gain-popup.fading {
  animation: resource-gain-out 0.4s ease-in forwards;
}
@keyframes resource-gain-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

.resource-gain-items {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.resource-gain-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.resource-gain-item .gain-value { color: var(--text-bright); }
.resource-gain-item .gain-label { font-size: 0.62rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; }
.resource-gain-item.trade { color: #6cb4ee; }
.resource-gain-item.production { color: #d4884c; }
.resource-gain-item.coins { color: var(--gold-bright); }
.resource-gain-item.culture { color: #b87ae8; }


/* ════════════════════════════════════════════
   SIDEBAR COLLAPSE
   ════════════════════════════════════════════ */

.sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  right: -14px;
  transform: translateY(-50%);
  width: 28px;
  height: 48px;
  background: var(--bg-surface);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}
.sidebar-collapse-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--bg-hover);
}
.sidebar-collapse-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s;
}
.sidebar-collapse-right {
  left: -14px;
  right: auto;
  border-radius: var(--radius) 0 0 var(--radius);
}

.game-sidebar {
  position: relative;
}

.game-sidebar.collapsed {
  width: 0 !important;
  overflow: hidden;
  padding: 0;
  border: none;
}
.game-sidebar.collapsed .sidebar-section {
  display: none;
}
.game-sidebar.collapsed .sidebar-collapse-btn {
  right: -28px;
}
.game-sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}
.game-sidebar.collapsed.sidebar-right .sidebar-collapse-btn {
  left: -28px;
  right: auto;
}
.game-sidebar.collapsed.sidebar-right .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}


/* ════════════════════════════════════════════
   CITY OUTSKIRTS HIGHLIGHT
   ════════════════════════════════════════════ */

.map-cell.city-outskirt {
  outline: 1px dashed rgba(201,168,76,0.5) !important;
}
.map-cell.city-outskirt::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(201,168,76,0.06);
  pointer-events: none;
  z-index: 0;
}


/* ════════════════════════════════════════════
   PHASE GUIDANCE IN ACTIONS PANEL
   ════════════════════════════════════════════ */

.phase-guide {
  padding: 0.5rem;
  background: rgba(201,168,76,0.04);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.phase-guide-title {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gold-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}
.phase-guide-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
}


/* ════════════════════════════════════════════
   HELP MODAL
   ════════════════════════════════════════════ */

.help-body { padding: 0.5rem 1rem 1rem; }
.help-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}
.help-section {
  padding: 0.75rem;
  background: var(--bg-deep);
  border: 1px solid rgba(201,168,76,0.08);
  border-radius: var(--radius);
}
.help-section-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}

.help-phase-list { display: flex; flex-direction: column; gap: 0.3rem; }
.help-phase {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
  padding: 0.25rem 0;
}
.help-phase strong { color: var(--text-bright); }

.help-victory-list { display: flex; flex-direction: column; gap: 0.35rem; }
.help-victory {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.help-victory strong { color: var(--text-bright); }
.help-v-icon { font-size: 0.85rem; flex-shrink: 0; }

.help-shortcut-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.help-key-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0.15rem 0;
}
.help-key-row span {
  margin-left: auto;
  text-align: right;
}
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0.1rem 0.35rem;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--gold);
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 3px;
  line-height: 1.4;
}

.help-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.help-tips li {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
  padding-left: 0.8rem;
  position: relative;
}
.help-tips li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--gold-dim);
}


/* ════════════════════════════════════════════
   IMPROVED BOTTOM BAR LAYOUT
   ════════════════════════════════════════════ */

.game-bottombar {
  height: var(--bottombar-height);
}

@media (max-width: 900px) {
  .help-columns { grid-template-columns: 1fr; }
  .phase-step-label { font-size: 0.45rem; }
  .phase-step { padding: 0.15rem 0.35rem; }
  .phase-step-line { width: 16px; }
}
