*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { touch-action: manipulation; }
button { user-select: none; }
img { -webkit-touch-callout: none; user-select: none; }

@media (max-width: 767px) {
  input[type="text"], input[type="search"], textarea { font-size: 16px !important; min-width: 0; }
  button:not(.filter-btn) { min-height: 36px; }
}

:root {
  /* ---- Surfaces ---- */
  --bg:       #14110f;
  --surface:  #211b17;
  --surface2: #2a221b;
  --border:   #3b3025;
  --border2:  #6a5031;

  /* ---- Brand / accent ---- */
  --primary:  #5f9298;
  --primary2: #76a9ad;
  --accent:   #c89a4b;
  --accent2:  #a97935;
  --danger:   #a7463d;
  --danger2:  #80332e;
  --combat:   #c06b3d;
  --success:  #74986c;
  --selection:#d3b65e;
  --effect:   #9370b4;
  --effect-target: #51a6a1;
  --player:   #5f9298;
  --parchment:#e9ddc2;
  --ink:      #2a2118;
  --muted:    #8f826d;

  /* ---- Text ---- */
  --text:     #eee4cf;
  --text-mid: #c6b795;
  --text-dim: #91836c;

  /* ---- Shape / motion ---- */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --transition: 0.15s ease;
  --trans-interactive: background var(--transition), color var(--transition), border-color var(--transition);

  /* ---- Overlay backdrops ---- */
  --overlay-bg:      rgb(10 7 5 / 0.68);
  --overlay-bg-soft: rgb(10 7 5 / 0.56);
  --overlay-bg-deep: rgb(7 5 4 / 0.9);

  /* ---- Shadows ---- */
  --shadow-modal: 0 12px 40px rgb(0 0 0 / 0.5);
  --shadow-card:  0 4px 12px rgb(0 0 0 / 0.5);

  /* ---- Card colors (5 factions) ---- */
  --color-white:  #e8dfc8;
  --color-blue:   #5589a8;
  --color-black:  #746b78;
  --color-purple: #8d6aa8;
  --color-orange: #c7773d;
  --color-other:  #8a806f;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--accent) 10%, transparent) 0%, transparent 42%),
    radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--primary) 6%, transparent) 0%, transparent 38%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top))
           max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom))
           max(12px, env(safe-area-inset-left));
}

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

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 90%, var(--accent) 10%), var(--surface));
  border-bottom: 1px solid var(--border2);
  box-shadow: 0 2px 10px rgb(0 0 0 / .22);
}
header h1 { font-family: Georgia, 'Times New Roman', serif; font-size: 1rem; color: var(--accent); letter-spacing: .04em; }
header h1 a { color: inherit; text-decoration: none; }
header .spacer { flex: 1; }

/* ---- Breadcrumb ---- */
.breadcrumb-sep {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 0.8rem;
  user-select: none;
}
.breadcrumb-current {
  color: var(--text-mid);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-link {
  flex-shrink: 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition);
}
.breadcrumb-link:hover { color: var(--text); }

/* ---- Shared content primitives ---- */
.ui-eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.ui-eyebrow-accent { color: var(--accent); }
.ui-eyebrow-muted { color: var(--text-dim); }

.ui-lead {
  color: var(--text-dim);
  font-size: .92rem;
  line-height: 1.7;
}
.ui-lead-compact { font-size: .82rem; line-height: 1.6; }

.ui-panel {
  background: linear-gradient(155deg, color-mix(in srgb, var(--surface) 94%, var(--accent) 6%), var(--surface));
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgb(255 244 214 / .035), 0 8px 24px rgb(0 0 0 / .2);
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--border);
  border-radius: 99px;
  color: var(--text-dim);
  font-size: .74rem;
  white-space: nowrap;
}

.ui-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ui-actions .btn { text-align: center; }

@media (min-width: 600px) {
  .ui-actions { flex-direction: row; }
}

/* ---- Buttons ---- */
.btn {
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: var(--trans-interactive);
  font-weight: 650;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary       { background: var(--accent); color: var(--ink); }
.btn-primary:not(:disabled):hover { background: var(--accent2); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-mid);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-secondary { background: color-mix(in srgb, var(--primary) 30%, var(--surface2)); color: var(--text); }
.btn-secondary:not(:disabled):hover { background: color-mix(in srgb, var(--primary) 42%, var(--surface2)); }
.btn-danger { background: var(--danger2); color: #f5d9d3; }
.btn-danger:not(:disabled):hover { background: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-outline-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: #d98278;
}
.btn-outline-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* ---- Shared modal primitives ---- */
.confirm-overlay,
.solo-overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.active,
.solo-overlay.active { display: flex; }

.confirm-dialog,
.solo-dialog {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ---- Footer ---- */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  padding: 24px 12px;
  margin-top: 32px;
  border-top: 1px solid var(--border);
}
footer a {
  color: var(--text-dim);
  font-size: .8rem;
  text-decoration: none;
}
footer a:hover { color: var(--text-mid); }
footer a[aria-current="page"] {
  color: var(--text-mid);
  text-decoration: underline;
  text-underline-offset: 4px;
}
