@font-face {
  font-family: 'Cinzel Decorative';
  src: url('/fonts/cinzel-decorative-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('/fonts/cinzel.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: 'Chakra Petch';
  src: url('/fonts/chakra-petch-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('/fonts/ebgaramond.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('/fonts/ebgaramond-italic.woff2') format('woff2');
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --black: #0b0708;
  --ink: #140a0b;
  --blood-deep: #3a0507;
  --blood: #5c0a0e;
  --blood-mid: #7a0f14;
  --ember: #b3141b;
  --ember-bright: #e0262e;
  --bone: #e8dcc4;
  --bone-dim: #a8998a;
  --ash: #6d6260;
  --line: rgba(232, 220, 196, 0.12);
  --panel: linear-gradient(180deg, rgba(40, 8, 10, 0.88), rgba(16, 7, 8, 0.92));
  --radius: 14px;
  --display: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --heading: 'Cinzel', Georgia, 'Times New Roman', serif;
  --body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --digit: 'Chakra Petch', 'Consolas', 'Courier New', monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.45;
  color: var(--bone);
  background:
    radial-gradient(ellipse 90% 55% at 50% 0%, rgba(122, 15, 20, 0.55), transparent 70%),
    radial-gradient(ellipse 70% 40% at 50% 100%, rgba(92, 10, 14, 0.35), transparent 70%),
    var(--black);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

body::after {
  /* grain */
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .7 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

[hidden] { display: none !important; }

/* ---------- backdrop ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.moon {
  position: absolute;
  top: -40px;
  left: 50%;
  width: 260px;
  height: 260px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 36%, rgba(0, 0, 0, 0.18) 0 9%, transparent 10%),
    radial-gradient(circle at 64% 58%, rgba(0, 0, 0, 0.16) 0 6%, transparent 7%),
    radial-gradient(circle at 56% 28%, rgba(0, 0, 0, 0.12) 0 4%, transparent 5%),
    radial-gradient(circle at 40% 40%, #d23a36, #9a1418 55%, #5c0a0e 100%);
  box-shadow: 0 0 80px 30px rgba(179, 20, 27, 0.35), 0 0 220px 90px rgba(122, 15, 20, 0.25);
  opacity: 0.55;
}

.backdrop::after {
  /* horizon glow behind the village */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40vh;
  background: radial-gradient(ellipse 80% 65% at 50% 100%, rgba(150, 18, 24, 0.45), transparent 70%);
}

.village {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  height: 30vh;
  min-height: 170px;
}

/* ---------- header ---------- */

.site-header {
  position: relative;
  text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 34px) 64px 10px;
}

.title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.9rem, 8.4vw, 3.8rem);
  letter-spacing: 0.04em;
  line-height: 1.05;
  color: var(--bone);
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(224, 38, 46, 0.55), 0 0 42px rgba(179, 20, 27, 0.45);
}

.subtitle {
  margin: -2px 0 0;
  font-family: var(--body);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.35rem, 5.6vw, 1.7rem);
  line-height: 1.15;
  color: #f0c9a0;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(224, 38, 46, 0.45);
}

.scratches {
  display: block;
  width: 110px;
  margin: 8px auto 0;
  color: var(--ember);
  opacity: 0.8;
}

.icon-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(20, 10, 11, 0.7);
  color: var(--bone);
  cursor: pointer;
}
.icon-btn svg { width: 26px; height: 26px; }
.leave-btn { right: auto; left: 14px; width: 38px; height: 38px; top: calc(env(safe-area-inset-top, 0px) + 17px); color: var(--bone-dim); }
.leave-btn svg { width: 20px; height: 20px; }
.icon-btn:hover, .icon-btn:focus-visible { border-color: var(--ember); color: #fff; box-shadow: 0 0 14px rgba(179, 20, 27, 0.6); }

/* ---------- layout ---------- */

main {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px calc(40px + var(--safe-bottom));
}

.screen { animation: fade-in 0.25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  position: relative;
  margin: 14px 0;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(179, 20, 27, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.panel::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(232, 220, 196, 0.06);
  border-radius: calc(var(--radius) - 4px);
  pointer-events: none;
}
.panel.center { text-align: center; }
.panel-flush { padding: 6px 0; overflow: hidden; }

h2 {
  margin: 0 0 8px;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.05em;
  color: var(--bone);
}

.hint { color: var(--bone-dim); font-size: 0.98rem; margin: 6px 0; display: block; }
.empty { text-align: center; color: var(--ash); font-style: italic; margin: 12px 0 4px; }

/* ---------- forms ---------- */

.field { display: block; margin: 0 0 18px; border: 0; padding: 0; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-dim);
}

input[type='text'], input[type='number'] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.1rem;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(232, 220, 196, 0.18);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type='text']:focus, input[type='number']:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(179, 20, 27, 0.3);
}
input::placeholder { color: var(--ash); }

.photo-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border: 1px dashed rgba(232, 220, 196, 0.25);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.photo-picker:hover { border-color: var(--ember); }
.photo-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-picker:focus-within { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(179, 20, 27, 0.3); }
.photo-picker-text { color: var(--bone-dim); }

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  cursor: pointer;
}
.switch-field .hint { margin: 0; }
.switch {
  appearance: none;
  flex: none;
  width: 54px;
  height: 30px;
  margin: 0;
  border-radius: 15px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(232, 220, 196, 0.25);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bone-dim);
  transition: transform 0.2s, background 0.2s;
}
.switch:checked { background: var(--blood-mid); border-color: var(--ember); }
.switch:checked::after { transform: translateX(24px); background: var(--bone); }
.switch:focus-visible { box-shadow: 0 0 0 3px rgba(179, 20, 27, 0.4); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid rgba(232, 220, 196, 0.2);
  border-radius: 10px;
  overflow: hidden;
}
.segmented-2 { grid-template-columns: repeat(2, 1fr); }
.segmented label { position: relative; cursor: pointer; }
.segmented input:disabled + span { opacity: 0.35; text-decoration: line-through; cursor: not-allowed; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
  display: block;
  padding: 10px 4px;
  text-align: center;
  font-family: var(--heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--bone-dim);
  background: rgba(0, 0, 0, 0.45);
}
.segmented label + label span { border-left: 1px solid rgba(232, 220, 196, 0.15); }
.segmented input:checked + span { background: var(--blood-mid); color: var(--bone); }
.segmented input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--ember); }

.error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(179, 20, 27, 0.18);
  border: 1px solid rgba(224, 38, 46, 0.5);
  color: #ffb3b0;
  font-size: 1rem;
}

/* ---------- buttons ---------- */

.btn-row { display: flex; gap: 12px; margin-top: 18px; }
.btn-row > .btn { flex: 1; }
.btn-row.stack { flex-direction: column; align-items: stretch; }

.btn {
  min-height: 50px;
  padding: 12px 18px;
  font-family: var(--heading);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bone);
  background: linear-gradient(180deg, #24100f, #120809);
  border: 1px solid rgba(232, 220, 196, 0.22);
  border-radius: 10px;
  box-shadow: 0 4px 0 #000, 0 6px 16px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s, border-color 0.15s;
}
.btn:hover { border-color: rgba(232, 220, 196, 0.45); filter: brightness(1.12); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000, 0 2px 8px rgba(0, 0, 0, 0.5); }
.btn:focus-visible { outline: 2px solid var(--ember-bright); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); transform: none; }

.btn-primary {
  background: linear-gradient(180deg, #a3161c, #6a0c10 60%, #4a070a);
  border-color: rgba(255, 120, 110, 0.35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.btn-danger {
  background: linear-gradient(180deg, #1a0a0b, #0a0506);
  border-color: rgba(224, 38, 46, 0.55);
  color: #ff9d98;
}
.btn-xl { min-height: 60px; font-size: 1.15rem; }

.link-btn {
  align-self: center;
  margin-top: 6px;
  padding: 8px;
  font: inherit;
  font-size: 0.98rem;
  color: var(--bone-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  cursor: pointer;
}
.link-btn:hover { color: var(--bone); }

/* ---------- lobby ---------- */

.lobby-name { font-size: 1.6rem; overflow-wrap: anywhere; }

.code-boxes {
  display: flex;
  justify-content: center;
  gap: clamp(5px, 1.6vw, 10px);
  margin: 8px 0 10px;
}
.code-box,
.code-inputs input {
  font-family: var(--digit);
  font-weight: 700;
  color: #ffe3dc;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(224, 38, 46, 0.85), 0 2px 0 #000;
  background: linear-gradient(180deg, #2b0a0c, #0d0506);
  border: 1px solid rgba(224, 38, 46, 0.6);
  border-radius: 10px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8), inset 0 -1px 0 rgba(255, 255, 255, 0.05), 0 0 12px rgba(179, 20, 27, 0.25);
}
.code-box {
  display: grid;
  place-items: center;
  width: clamp(36px, 11vw, 48px);
  aspect-ratio: 3 / 4;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  line-height: 1;
}
.code-boxes-lg { gap: clamp(6px, 2vw, 12px); }
.code-boxes-lg .code-box {
  width: clamp(44px, 13vw, 66px);
  font-size: clamp(2.1rem, 9.5vw, 3rem);
}

.counter { margin: 4px 0 0; font-family: var(--heading); font-weight: 700; letter-spacing: 0.08em; color: var(--bone-dim); }
.settings-summary { margin: 10px 0 0; font-size: 0.92rem; color: var(--bone-dim); }
.settings-summary strong { color: var(--bone); font-weight: 600; }
.counter span:first-child { color: var(--ember-bright); font-size: 1.4em; }

.waiting { display: inline-flex; align-items: center; gap: 10px; margin: 8px 0; font-style: italic; color: var(--bone); }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ember-bright); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224, 38, 46, 0.7); } 70% { box-shadow: 0 0 0 12px rgba(224, 38, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(224, 38, 46, 0); } }

.code-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  max-width: 360px;
  margin: 18px auto 4px;
}
.code-inputs input {
  aspect-ratio: 3 / 4;
  padding: 0;
  font-size: clamp(1.6rem, 7.5vw, 2.2rem);
}
.code-inputs input:focus { border-color: var(--ember-bright); box-shadow: 0 0 0 3px rgba(224, 38, 46, 0.35), inset 0 2px 8px rgba(0, 0, 0, 0.8); }

/* ---------- tables ---------- */

.players { width: 100%; border-collapse: collapse; }
.players th {
  padding: 8px 10px;
  font-family: var(--heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ash);
  border-bottom: 1px solid rgba(179, 20, 27, 0.35);
}
.players td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.players tr:last-child td { border-bottom: 0; }
.col-photo { width: 64px; }
.col-status { width: 1%; white-space: nowrap; }
.col-votes { width: 1%; text-align: center !important; white-space: nowrap; }
.col-action { width: 1%; }
.th-short { display: none; }

.player-name { font-size: 1.15rem; font-weight: 600; overflow-wrap: break-word; }
.players td:nth-child(2) { min-width: 6.5em; }
.player-meta { display: block; font-size: 0.88rem; color: var(--bone-dim); font-style: italic; }
.player-meta.live-voters { color: #f1c9b8; font-style: normal; animation: fade-in 0.3s ease-out; }
.offline { display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--ash); vertical-align: middle; }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 35% 30%, var(--blood-mid), var(--blood-deep));
  border: 2px solid rgba(179, 20, 27, 0.6);
  box-shadow: 0 0 0 2px #000;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--bone);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar svg { width: 55%; height: 55%; color: var(--bone-dim); }
.avatar-lg { width: 76px; height: 76px; font-size: 1.6rem; }

.status { font-family: var(--heading); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em; }
.status-alive { color: #d9c9a8; }
.status-dead { color: var(--ember-bright); }
.status-mayor { display: inline-flex; align-items: center; gap: 5px; color: #f2c46d; text-shadow: 0 0 10px rgba(242, 196, 109, 0.35); }
.crown { width: 16px; height: 16px; flex: none; }

.status-select {
  appearance: none;
  padding: 8px 30px 8px 10px;
  font-family: var(--heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23e8dcc4' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 10px center / 11px;
  border: 1px solid rgba(232, 220, 196, 0.25);
  border-radius: 8px;
  cursor: pointer;
}
.status-select.is-dead { color: var(--ember-bright); border-color: rgba(224, 38, 46, 0.5); }
.status-select.is-mayor { color: #f2c46d; border-color: rgba(242, 196, 109, 0.55); }
.status-select:disabled { opacity: 0.55; cursor: not-allowed; }

.kick-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.1rem;
  color: var(--ash);
  background: none;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}
.kick-btn:hover, .kick-btn:focus-visible { color: var(--ember-bright); border-color: rgba(224, 38, 46, 0.5); }

tr.is-dead td { opacity: 0.45; }
tr.is-dead .avatar { filter: grayscale(1); }
tr.is-dead .player-name { text-decoration: line-through; text-decoration-color: var(--ember); text-decoration-thickness: 2px; }
tr.is-dead td.keep-bright { opacity: 1; }

tr.votable { cursor: pointer; transition: background 0.15s; }
tr.votable:hover, tr.votable:focus-visible { background: rgba(179, 20, 27, 0.2); outline: none; }
tr.votable:focus-visible { box-shadow: inset 3px 0 0 var(--ember-bright); }
tr.my-vote { background: rgba(179, 20, 27, 0.28); box-shadow: inset 4px 0 0 var(--ember-bright); }
tr.is-me .player-name::after { content: ' (jij)'; font-weight: 400; font-style: italic; color: var(--bone-dim); font-size: 0.9em; }
tr.top-vote { background: linear-gradient(90deg, rgba(179, 20, 27, 0.4), rgba(179, 20, 27, 0.08)); }

.vote-count {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 18px;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
}
.top-vote .vote-count { background: var(--ember); border-color: var(--ember-bright); color: #fff; box-shadow: 0 0 14px rgba(224, 38, 46, 0.6); }

.badge {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 10px;
  font-family: var(--heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ember);
  color: #fff;
}

/* ---------- vote banner ---------- */

.vote-banner {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  z-index: 5;
  margin: 10px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #8e1117, #4c080b);
  border: 1px solid rgba(255, 120, 110, 0.4);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.7), 0 0 30px rgba(179, 20, 27, 0.35);
  text-align: center;
}
.vote-banner.closed { background: linear-gradient(180deg, #2a0c0d, #120708); border-color: rgba(179, 20, 27, 0.5); }
.vote-banner-main { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.vote-title { font-family: var(--heading); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.08em; text-transform: uppercase; }
.countdown {
  min-width: 64px;
  padding: 2px 12px;
  border-radius: 20px;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.countdown.urgent { color: #fff; background: var(--ember-bright); animation: throb 1s infinite; }
@keyframes throb { 50% { transform: scale(1.08); } }
.vote-banner-sub { margin-top: 4px; font-size: 1rem; color: #f1e2cf; }

/* ---------- bottom bar ---------- */

.screen[data-screen='game'].has-bar { padding-bottom: calc(96px + var(--safe-bottom)); }

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 7, 8, 0.6), rgba(11, 7, 8, 0.97) 35%);
  border-top: 1px solid rgba(179, 20, 27, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.bottom-bar-inner { display: flex; gap: 10px; max-width: 608px; margin: 0 auto; }
.bottom-bar-inner .btn { flex: 1; }
.seconds { display: flex; align-items: center; gap: 6px; color: var(--bone-dim); font-family: var(--heading); font-size: 0.85rem; }
.seconds input { width: 74px; min-height: 50px; text-align: center; font-family: var(--heading); font-weight: 700; }

/* ---------- roles ---------- */

.btn-small { min-height: 40px; padding: 8px 14px; font-size: 0.8rem; box-shadow: 0 3px 0 #000; }

.roles-head { position: relative; text-align: center; margin: 6px 0 14px; }
.roles-head .btn-small { display: block; margin: 0 auto 14px; }
.roles-head h2 { font-size: 1.7rem; margin-bottom: 0; }

.role-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 560px) { .role-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.role-tile {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 12px;
  font: inherit;
  color: var(--bone);
  background: var(--panel);
  border: 1px solid rgba(179, 20, 27, 0.35);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.role-tile:hover, .role-tile:focus-visible {
  outline: none;
  border-color: var(--ember-bright);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55), 0 0 18px rgba(224, 38, 46, 0.35);
}
.role-tile:active { transform: scale(0.97); }
.role-tile-art { display: flex; align-items: center; justify-content: center; width: 100%; }
.role-tile-art img {
  display: block;
  width: 88%;
  height: auto;
  aspect-ratio: 1 / 1; /* square box for every card, tall medal included */
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.75));
  transition: transform 0.4s ease;
}
.role-tile:hover .role-tile-art img { transform: rotate(-8deg) scale(1.04); }
.role-tile-name {
  font-family: var(--heading);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-align: center;
}
.role-tile-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.role-tile-badges .role-badge { font-size: 0.62rem; padding: 2px 7px; }

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.2;
  color: #120708;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
.badge-mayor { background: #f2c46d; color: #1a0c05; letter-spacing: 0.02em; overflow-wrap: normal; text-transform: none; font-size: 0.72rem; }
.role-badge-once { background: #f2c230; }
.role-badge-loner { background: #6fa3f2; }

.role-dialog {
  width: min(94vw, 520px);
  max-height: 92dvh;
  padding: 0;
  color: var(--bone);
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(150, 18, 24, 0.45), transparent 70%),
    linear-gradient(180deg, #2a0b0d, #0d0506);
  border: 1px solid rgba(224, 38, 46, 0.5);
  border-radius: 18px;
  box-shadow: 0 20px 60px #000, 0 0 40px rgba(179, 20, 27, 0.3);
  overflow: hidden;
}
.role-dialog::backdrop { background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(3px); }
.role-dialog[open] { animation: role-in 0.2s ease-out; }
@keyframes role-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.role-dialog-inner { max-height: 92dvh; overflow-y: auto; padding: 22px 20px 16px; text-align: center; }
.role-close { top: 10px; right: 10px; z-index: 2; }
.role-art { display: flex; justify-content: center; margin: 4px 0 12px; }
.role-art img {
  display: block;
  width: min(56vw, 250px);
  height: min(56vw, 250px);
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.8));
}
.role-title { font-size: 1.6rem; margin: 0 0 8px; text-shadow: 0 2px 0 #000, 0 0 16px rgba(224, 38, 46, 0.5); }
.role-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 10px; }
.role-badges:empty { display: none; }
.role-text { margin: 0 0 16px; font-size: 1.12rem; line-height: 1.5; text-align: left; hyphens: auto; }
.role-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.role-pos { font-family: var(--heading); font-size: 0.85rem; color: var(--bone-dim); }

/* ---------- misc ---------- */

.conn-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 -16px 8px;
  padding: 8px 16px;
  text-align: center;
  font-size: 0.95rem;
  background: #2b0b0c;
  border-bottom: 1px solid var(--ember);
  color: #ffc9c5;
}

.modal {
  width: min(92vw, 400px);
  padding: 22px;
  color: var(--bone);
  background: linear-gradient(180deg, #2a0b0d, #0f0708);
  border: 1px solid rgba(224, 38, 46, 0.5);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px #000, 0 0 40px rgba(179, 20, 27, 0.3);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(2px); }
.modal-text { margin: 0; font-size: 1.25rem; text-align: center; }
.modal-text strong { font-family: var(--heading); color: #fff; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-bottom));
  z-index: 40;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1d0a0b;
  border: 1px solid var(--ember);
  box-shadow: 0 10px 30px #000;
  font-size: 1rem;
}

.ended-moon { width: 72px; height: 72px; margin: 4px auto 10px; display: block; filter: drop-shadow(0 0 18px rgba(179, 20, 27, 0.7)); }

@media (max-width: 420px) {
  body { font-size: 17px; }
  .panel { padding: 16px; }
  .players td, .players th { padding: 7px 6px; }
  .col-photo { width: 52px; }
  .avatar { width: 42px; height: 42px; font-size: 0.95rem; }
  .players th { letter-spacing: 0.06em; font-size: 0.66rem; }
  .player-name { font-size: 1.05rem; }
  .player-meta { font-size: 0.82rem; }
  .status { font-size: 0.72rem; letter-spacing: 0.02em; }
  .status-mayor { gap: 3px; }
  .crown { width: 13px; height: 13px; }
  .status-select { font-size: 0.74rem; padding: 7px 22px 7px 7px; background-position: right 7px center; background-size: 9px; }
  .kick-btn { width: 30px; height: 30px; }
  .badge { font-size: 0.6rem; padding: 1px 6px; }
  .th-long { display: none; }
  .th-short { display: inline; font-size: 0.9rem; }
  .vote-count { min-width: 30px; height: 30px; padding: 0 6px; font-size: 1rem; }
  .players td.col-votes { padding-right: 10px; }
  .avatar-lg { width: 70px; height: 70px; }
  .site-header { padding-left: 56px; padding-right: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
