/* ============================================================
   Kingdom Chess — design system
   Medieval heraldry. Dark parchment + gold. No cyber.
   ============================================================ */
:root {
  --ink: #1a1410;
  --ink-2: #221a12;
  --ink-3: #2b2115;
  --parchment: #e8dcc0;
  --parchment-dim: #b8a986;
  --parchment-faint: #8a7a5c;
  --gold: #c9a227;
  --gold-bright: #f0cf5e;
  --gold-dark: #8a6d14;
  --blood: #8c2f2f;
  --blood-bright: #b34444;
  --forest: #3e6b4f;
  --steel: #5b6770;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --f-aldric: #c9a227;
  --f-veyra: #5b7d9e;
  --f-thorne: #6a4f8f;
  --f-ironmarch: #8c5b3c;
  --f-syndicate: #4f8f6a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(201,162,39,.12), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(140,47,47,.14), transparent 60%),
    var(--ink);
  color: var(--parchment);
  font-family: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  letter-spacing: .02em;
}
a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: var(--gold); }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #2b2115, #221a12);
  color: var(--parchment);
  padding: .65rem 1.3rem;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(201,162,39,.25); background: linear-gradient(180deg, #33281a, #2b2115); }
button:active { transform: translateY(0); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-gold { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #1a1410; font-weight: 700; border-color: var(--gold-bright); }
.btn-gold:hover { background: linear-gradient(180deg, #ffdf7a, var(--gold-bright)); }
.btn-danger { border-color: var(--blood); color: #f0c4c4; background: linear-gradient(180deg, #3a1c1c, #2a1414); }
.btn-danger:hover { box-shadow: 0 4px 14px rgba(140,47,47,.4); }
.btn-ghost { border-color: var(--steel); background: transparent; color: var(--parchment-dim); }
.btn-ghost:hover { color: var(--parchment); border-color: var(--parchment-dim); }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1.1rem; }

/* ---------- Cards & panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
  border: 1px solid rgba(201,162,39,.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  position: relative;
}
.panel::before {
  content: "";
  position: absolute; inset: 4px;
  border: 1px solid rgba(201,162,39,.15);
  border-radius: 7px;
  pointer-events: none;
}
.panel-title {
  font-family: "Cinzel", Georgia, serif;
  color: var(--gold-bright);
  font-size: 1.15rem;
  margin-bottom: .8rem;
  display: flex; align-items: center; gap: .5rem;
}
.crest-img { width: 2.6rem; height: 2.6rem; border-radius: 50%; }

/* ---------- Layout ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 1.2rem 4rem; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 0;
  border-bottom: 1px solid rgba(201,162,39,.25);
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}
.topbar .logo { display: flex; align-items: center; gap: .6rem; font-family: "Cinzel", Georgia, serif; font-size: 1.2rem; color: var(--gold-bright); }
.topbar .logo img { width: 2.2rem; height: 2.2rem; border-radius: 50%; }
.topbar nav { display: flex; gap: .4rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a { padding: .4rem .85rem; border-radius: 8px; color: var(--parchment-dim); font-size: .95rem; }
.topbar nav a:hover { color: var(--parchment); background: rgba(201,162,39,.1); }
.topbar nav a.active { color: var(--gold-bright); background: rgba(201,162,39,.15); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(201,162,39,.4);
  box-shadow: var(--shadow);
  margin-bottom: 2.4rem;
  min-height: 460px;
  display: flex; align-items: center;
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,16,10,.92) 0%, rgba(20,16,10,.55) 45%, transparent 75%); }
.hero-content { position: relative; padding: 3rem 2.5rem; max-width: 620px; z-index: 1; }
.hero-kicker { text-transform: uppercase; letter-spacing: .25em; font-size: .78rem; color: var(--gold); margin-bottom: .8rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.1; margin-bottom: 1rem; }
.hero h1 em { color: var(--gold-bright); font-style: normal; }
.hero p { color: var(--parchment-dim); font-size: 1.1rem; margin-bottom: 1.6rem; }
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; }

/* ---------- Sections ---------- */
.section { margin-bottom: 2.8rem; }
.section-head { text-align: center; margin-bottom: 1.6rem; }
.section-head h2 { font-size: 1.9rem; color: var(--gold-bright); }
.section-head p { color: var(--parchment-dim); max-width: 640px; margin: .4rem auto 0; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.step-num {
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.6rem; color: var(--gold);
  border: 2px solid var(--gold); border-radius: 50%;
  width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center;
  margin-bottom: .8rem;
}

/* ---------- Faction cards ---------- */
.factions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; }
.faction-card {
  text-align: center; padding: 1.3rem 1rem;
  cursor: pointer; transition: transform .15s ease, border-color .15s ease;
}
.faction-card:hover { transform: translateY(-4px); }
.faction-card.selected { border-color: var(--gold-bright); box-shadow: 0 0 0 2px rgba(240,207,94,.35), var(--shadow); }
.faction-card img { width: 5.5rem; height: 5.5rem; border-radius: 50%; margin-bottom: .7rem; }
.faction-card h3 { font-size: 1rem; margin-bottom: .3rem; }
.faction-card .playstyle { font-size: .8rem; color: var(--parchment-dim); min-height: 2.4em; }
.faction-card .king { font-size: .75rem; color: var(--gold); font-style: italic; margin-top: .3rem; }

/* ---------- World map ---------- */
.world-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 1.2rem; align-items: start; }
.map-panel { overflow: hidden; }
.world-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 16), 1fr);
  gap: 2px;
  aspect-ratio: 1;
  width: 100%;
  user-select: none;
}
.tile {
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.3);
  transition: transform .08s ease, box-shadow .08s ease;
  min-height: 8px;
}
.tile:hover { transform: scale(1.12); z-index: 2; box-shadow: 0 0 0 2px rgba(240,207,94,.7); }
.tile.selected { box-shadow: 0 0 0 3px var(--gold-bright); }
.tile .piece-mark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(var(--tile) * .5); }
.terrain-grass { background: #3e6b4f; }
.terrain-forest { background: #2c4a35; }
.terrain-mountain { background: #5b5548; }
.terrain-river { background: #35586b; }
.terrain-ruins { background: #6b5a4a; }
.owner-aldric { box-shadow: inset 0 0 0 3px rgba(201,162,39,.75); }
.owner-veyra { box-shadow: inset 0 0 0 3px rgba(91,125,158,.75); }
.owner-thorne { box-shadow: inset 0 0 0 3px rgba(106,79,143,.75); }
.owner-ironmarch { box-shadow: inset 0 0 0 3px rgba(140,91,60,.75); }
.owner-syndicate { box-shadow: inset 0 0 0 3px rgba(79,143,106,.75); }
.owner-player { box-shadow: inset 0 0 0 3px var(--gold-bright), 0 0 10px rgba(240,207,94,.5); }
.tile .flag-dot { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; }

/* ---------- HUD ---------- */
.hud {
  display: grid; grid-template-columns: 1fr auto; gap: 1rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.hud-left { display: flex; align-items: center; gap: 1rem; }
.hud-player { display: flex; align-items: center; gap: .7rem; }
.hud-player img { width: 3rem; height: 3rem; border-radius: 50%; }
.hud-player .pname { font-family: "Cinzel", Georgia, serif; color: var(--gold-bright); }
.hud-stats { display: flex; gap: 1.4rem; }
.hud-stat .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .15em; color: var(--parchment-faint); }
.hud-stat .value { font-size: 1.25rem; font-weight: 700; color: var(--parchment); }
.hud-stat .value.gold { color: var(--gold-bright); }
.hud-stat .value.blood { color: var(--blood-bright); }
.zone-chip {
  display: inline-flex; align-items: center; gap: .5rem;
  border: 1px solid var(--steel); border-radius: 20px;
  padding: .35rem .9rem; font-size: .85rem; color: var(--parchment-dim);
  background: rgba(91,103,112,.15);
}

/* ---------- Battle ---------- */
.battle-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 1.2rem; align-items: start; }
.board-panel { overflow: hidden; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  border: 3px solid var(--gold-dark);
  border-radius: 6px;
  overflow: hidden;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq.light { background: #d8c9a3; }
.sq.dark { background: #7a6a4a; }
.sq.selected { box-shadow: inset 0 0 0 4px var(--gold-bright); }
.sq.legal { background: radial-gradient(circle at center, rgba(240,207,94,.55) 0%, transparent 65%); }
.sq.attack { background: radial-gradient(circle at center, rgba(179,68,68,.75) 0%, transparent 70%); }
.sq.last-from { box-shadow: inset 0 0 0 2px rgba(240,207,94,.7); }
.sq.last-to { box-shadow: inset 0 0 0 2px rgba(240,207,94,.9); }
.sq .piece { width: 86%; height: 86%; }
.piece svg { width: 100%; height: 100%; }
.sq .check { position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(140,47,47,.75), transparent 70%); border-radius: 50%; }

/* ---------- Feed / edicts ---------- */
.feed { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; padding-right: .3rem; }
.feed-item {
  border-left: 3px solid var(--gold);
  background: rgba(201,162,39,.06);
  padding: .55rem .8rem;
  border-radius: 0 8px 8px 0;
  font-size: .9rem;
}
.feed-item.edict { border-left-color: var(--forest); background: rgba(62,107,79,.12); }
.feed-item.treason { border-left-color: var(--blood); background: rgba(140,47,47,.14); }
.feed-item .when { font-size: .72rem; color: var(--parchment-faint); }
.feed-item .who { color: var(--gold-bright); font-weight: 600; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { text-align: left; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--parchment-faint); padding: .55rem .6rem; border-bottom: 1px solid rgba(201,162,39,.3); }
td { padding: .6rem; border-bottom: 1px solid rgba(201,162,39,.12); }
tr:hover td { background: rgba(201,162,39,.05); }
.rank-1 td { color: var(--gold-bright); font-weight: 700; }

/* ---------- Modals ---------- */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(10,8,5,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 1rem;
}
.modal {
  background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
  border: 1px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  max-width: 560px; width: 100%;
  padding: 2rem;
  position: relative;
}
.modal h2 { font-size: 1.5rem; color: var(--gold-bright); margin-bottom: 1rem; }
.modal-close { position: absolute; top: .8rem; right: .9rem; background: transparent; border: none; color: var(--parchment-dim); font-size: 1.4rem; }
.modal-close:hover { color: var(--parchment); }
.modal .king-row { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }
.modal .king-row img { width: 4.5rem; height: 4.5rem; border-radius: 50%; }

/* ---------- Forms ---------- */
input[type="text"], select {
  width: 100%;
  background: var(--ink);
  border: 1px solid rgba(201,162,39,.4);
  color: var(--parchment);
  padding: .7rem .9rem;
  border-radius: var(--radius);
  font-family: inherit; font-size: 1rem;
}
input[type="text"]:focus, select:focus { outline: none; border-color: var(--gold-bright); }
label { display: block; font-size: .85rem; color: var(--parchment-dim); margin-bottom: .4rem; }
.field { margin-bottom: 1rem; }

/* ---------- Misc ---------- */
.muted { color: var(--parchment-dim); }
.small { font-size: .85rem; }
.faint { color: var(--parchment-faint); }
.center { text-align: center; }
.mt { margin-top: 1.2rem; }
.mb { margin-bottom: 1.2rem; }
.row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 12px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  border: 1px solid var(--gold); color: var(--gold-bright);
}
.badge.traitor { border-color: var(--blood); color: var(--blood-bright); }
.badge.ally { border-color: var(--forest); color: #7db392; }
.badge.war { border-color: var(--blood); color: var(--blood-bright); }
.banner {
  border: 1px solid var(--gold); border-radius: 10px;
  background: linear-gradient(90deg, rgba(201,162,39,.15), rgba(201,162,39,.04));
  padding: 1rem 1.2rem; margin-bottom: 1.2rem;
  display: flex; align-items: center; gap: 1rem;
}
.banner.blood { border-color: var(--blood); background: linear-gradient(90deg, rgba(140,47,47,.2), rgba(140,47,47,.05)); }
.timer { font-family: "Cinzel", Georgia, serif; color: var(--gold-bright); font-size: 1.2rem; letter-spacing: .05em; }
.crown-pulse { animation: crownPulse 2.4s ease-in-out infinite; display: inline-block; }
@keyframes crownPulse { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(240,207,94,0)); } 50% { transform: scale(1.08); filter: drop-shadow(0 0 10px rgba(240,207,94,.7)); } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .world-wrap, .battle-wrap { grid-template-columns: 1fr; }
  .factions { grid-template-columns: repeat(3, 1fr); }
  .steps { grid-template-columns: 1fr; }
  .hud { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .factions { grid-template-columns: repeat(2, 1fr); }
  .topbar nav { margin-left: 0; width: 100%; justify-content: flex-start; }
  .hero-content { padding: 2rem 1.2rem; }
  .hud-stats { flex-wrap: wrap; gap: .8rem 1.2rem; }
  .shell { padding: 0 .8rem 3rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .crown-pulse { animation: none; }
  * { transition: none !important; }
}
