:root {
  --bg: #14110f;
  --bg-2: #1c1815;
  --panel: #241e1a;
  --panel-2: #2d2520;
  --line: #3b322b;
  --ink: #f4ead5;
  --muted: #a89b85;
  --gold: #d4a64a;
  --gold-2: #f0cd7c;
  --loyal: #2f5d9e;
  --loyal-2: #5b8ad1;
  --dagger: #9e2330;
  --dagger-2: #d6505a;
  --crack: #14110f;
  --radius: 14px;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #2a211b 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .display { font-family: var(--display); letter-spacing: .04em; margin: 0; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2);
  padding: 14px 20px; border-radius: 12px; font-weight: 600; cursor: pointer;
  transition: transform .08s ease, background .2s, border-color .2s, opacity .2s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241a08; border-color: transparent; }
.btn.danger { background: var(--dagger); border-color: transparent; }
.btn.loyal { background: var(--loyal); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 14px; }

input.field {
  width: 100%; padding: 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--ink); font-size: 20px; outline: none;
}
input.field:focus { border-color: var(--gold); }
input.code { text-transform: uppercase; letter-spacing: .3em; font-family: var(--display); text-align: center; font-size: 28px; }

/* ---------------------------------------------------------------- cards */

.card { width: 120px; aspect-ratio: 5 / 7; perspective: 900px; flex: none; }
.card .card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .8s cubic-bezier(.3, .7, .2, 1.1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card .face {
  position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45), inset 0 0 0 2px rgba(255, 255, 255, .06);
  overflow: hidden;
}
.card .front { transform: rotateY(180deg); }
.card .back {
  background:
    repeating-linear-gradient(45deg, rgba(212, 166, 74, .07) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #3a2e25, #1d1713);
  color: var(--gold); border: 2px solid #5a4630;
}
.card .back svg { width: 42%; opacity: .9; }
.card .back .hint { font-family: var(--display); font-size: 13px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }

.decree svg { width: 50%; }
.decree .label { font-family: var(--display); font-weight: 700; text-align: center; font-size: .95em; line-height: 1.15; letter-spacing: .08em; text-transform: uppercase; }
.decree.loyal { background: linear-gradient(170deg, #4a7cc2, var(--loyal) 55%, #1d3c69); color: #eaf1ff; border: 3px solid #9bbbe8; }
.decree.dagger { background: linear-gradient(170deg, #c23d48, var(--dagger) 55%, #5e1119); color: #ffe9e9; border: 3px solid #ec9aa0; }
.decree.blank { background: var(--panel-2); }

.card.vote { width: 92px; }
.vote-back svg { width: 40%; }
.vote-face { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: .1em; }
.vote-face.aye { background: linear-gradient(170deg, var(--gold-2), var(--gold)); color: #2a1e08; border: 3px solid #fff1c8; }
.vote-face.nay { background: linear-gradient(170deg, #3a3a3a, #121212); color: #f4ead5; border: 3px solid #666; }
.vote-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.vote-name { font-weight: 600; font-size: 15px; max-width: 110px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card.role { width: min(68vw, 260px); }
.role-face { gap: 6%; padding: 10%; text-align: center; }
.role-face svg { width: 52%; }
.role-face .role-title { font-family: var(--display); font-size: 28px; font-weight: 700; }
.role-face .role-party { font-size: 13px; text-transform: uppercase; letter-spacing: .18em; opacity: .85; }
.role-face.loyal { background: linear-gradient(170deg, #4a7cc2, var(--loyal) 55%, #1d3c69); border: 3px solid #9bbbe8; }
.role-face.dagger { background: linear-gradient(170deg, #c23d48, var(--dagger) 55%, #5e1119); border: 3px solid #ec9aa0; }
.role-face.usurper { --crack: #c23d48; background: radial-gradient(circle at 50% 35%, #3b1015, #0d0809 70%); color: var(--gold-2); border: 3px solid var(--dagger-2); }

/* ---------------------------------------------------------------- stamps / overlays */

.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: rgba(10, 8, 7, .86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in .35s ease both; padding: 24px;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.6) rotate(-8deg); } 70% { transform: scale(1.08) rotate(-4deg); } 100% { opacity: 1; transform: scale(1) rotate(-4deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.stamp {
  font-family: var(--display); font-weight: 700; font-size: clamp(36px, 6vw, 80px); letter-spacing: .12em;
  padding: 6px 28px; border: 6px solid currentColor; border-radius: 10px; animation: pop-in .5s ease both;
}
.stamp.good { color: var(--gold-2); }
.stamp.bad { color: var(--dagger-2); }
.rise { animation: rise .5s ease both; }
