:root {
  --bg: #14110d;
  --card: #1f1a14;
  --card-2: #29221a;
  --line: #3a3026;
  --text: #ece3d3;
  --muted: #a89a85;
  --gold: #e8b64c;
  --alliance: #3f7be0;
  --horde: #c8352b;
  --tank: #8fa8c8;
  --healer: #6fcf7a;
  --dps: #e07a5f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(ellipse at top, #2a2116 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--gold); margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; color: var(--text); font-family: inherit; }
a { color: var(--gold); }
p { margin: 0 0 10px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.site-header { border-bottom: 1px solid var(--line); background: rgba(20, 17, 13, .85); position: sticky; top: 0; z-index: 1; backdrop-filter: blur(6px); }
.header-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 18px 16px; }
.header-inner .countdown { justify-self: end; text-align: right; }
@media (max-width: 640px) {
  .header-inner { grid-template-columns: 1fr auto; }
  .header-inner .countdown { grid-column: 1 / -1; justify-self: start; text-align: left; }
}
.brand { font-family: Georgia, serif; font-size: 1.2rem; color: var(--gold); font-weight: bold; line-height: 1.2; }
.brand-sub { display: block; font-size: 1.05rem; font-weight: normal; color: var(--muted); }
.countdown { font-size: .9rem; color: var(--muted); }
.countdown strong { display: block; color: var(--gold); font-variant-numeric: tabular-nums; }
.site-footer { color: var(--muted); font-size: .875rem; padding: 24px 16px 40px; }
.sponsor { display: inline-block; opacity: .75; transition: opacity .2s; }
.sponsor:hover, .sponsor:focus-visible { opacity: 1; }
.sponsor img { display: block; height: auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.login-wrap { max-width: 420px; padding-top: 12vh; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; }
.note { color: #ffb4a8; margin-top: 12px; }

input, button { font: inherit; color: inherit; }
input[type=text], input[type=password] {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn { background: var(--gold); color: #1a1408; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: default; }
.link-btn { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 0; text-decoration: underline; font-size: .875rem; }
.link-btn.danger { color: #ff8f80; }

/* Valknappar */
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.choice {
  background: var(--card-2); border: 2px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.choice:hover { border-color: var(--muted); }
.choice[aria-pressed=true] { border-color: var(--c, var(--gold)); background: color-mix(in srgb, var(--c, var(--gold)) 22%, var(--card-2)); }
.choice:disabled { opacity: .35; cursor: default; }
.choice.big { padding: 12px 18px; font-size: 1.05rem; font-weight: 600; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 6px 0 14px; }
.class-grid .choice { justify-content: center; color: var(--c); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; cursor: pointer; }
.check input { accent-color: var(--gold); width: 18px; height: 18px; }
.label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.saved { font-size: .85rem; color: var(--healer); }

/* Fraktionsröstning */
.vote-row { display: grid; grid-template-columns: 90px 1fr 40px; gap: 10px; align-items: center; margin: 8px 0; }
.bar { height: 22px; background: var(--card-2); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--c); transition: width .3s; }
.voters { font-size: .875rem; color: var(--muted); margin: -2px 0 8px 100px; }
.leader { font-weight: 600; margin-top: 10px; }

/* Roller och grupper */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 16px; }
.stat { background: var(--card-2); border-radius: 8px; padding: 10px 12px; border-left: 4px solid var(--c); position: relative; }
.stat-mark { position: absolute; top: 8px; right: 12px; font-size: 1.3rem; font-weight: 700; line-height: 1; }
.stat-mark.ok { color: var(--healer); }
.stat-mark.bad { color: #ff6b5b; }
.stat-mark.flex { color: var(--gold); }
.stat b { font-size: 1.5rem; display: block; }
.stat.warn { box-shadow: inset 0 0 0 1px #ff8f80; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.group { background: var(--card-2); border-radius: 8px; padding: 10px 12px; }
.group ul { list-style: none; margin: 6px 0 0; padding: 0; }
.group li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.group li:last-child { border-bottom: 0; }
.role-tag { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--c); }
.flex-tag { font-size: .75rem; color: var(--gold); }
.problems { margin: 0 0 12px; padding-left: 20px; color: #ffcf8a; }

/* Tabell */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tr.me td { background: color-mix(in srgb, var(--gold) 8%, transparent); }
.faction-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.cls { color: var(--c); font-weight: 600; }

@media (max-width: 640px) {
  .header-inner .sponsor img { width: 120px; }
}
.row-actions { white-space: nowrap; }
.row-actions .link-btn + .link-btn { margin-left: 10px; }
.class-icon { width: 1.15em; height: 1.15em; border-radius: 3px; vertical-align: -0.2em; margin-right: 5px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); }
.class-grid .class-icon { width: 22px; height: 22px; margin-right: 0; }
.sponsor-line { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
@media (max-width: 640px) {
  .sponsor-line { font-size: .75rem; gap: 6px; }
}
@media (max-width: 640px) {
  .header-inner .sponsor-line { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
}

/* Spelarlistan */
.roster td { vertical-align: middle; padding: 10px 8px; }
.roster tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .025); }
.roster tbody tr:hover td { background: rgba(255, 255, 255, .05); }
.roster tbody tr.me td { background: color-mix(in srgb, var(--gold) 10%, transparent); }
.roster td:first-child { border-left: 3px solid transparent; }
.roster tr.me td:first-child { border-left-color: var(--gold); }
.primary-cls .cls { font-size: 1.05rem; white-space: nowrap; }
.primary-cls .class-icon { width: 26px; height: 26px; vertical-align: middle; }
.secondary-cls .cls { font-weight: 500; font-size: .9rem; opacity: .85; white-space: nowrap; }
.faction-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: color-mix(in srgb, var(--c) 25%, transparent); border: 1px solid var(--c); white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.role-badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; white-space: nowrap;
  color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); opacity: .75; }
.role-badge.main { opacity: 1; font-weight: 700; color: #14110d; background: var(--c); border-color: var(--c); }
.fill-icons { display: flex; flex-wrap: wrap; gap: 4px; }
.fill-icon { margin: 0; width: 22px; height: 22px; opacity: .8; }
.roster .row-actions { text-align: right; }
.roster .row-actions .link-btn { opacity: .7; }
.roster tr:hover .row-actions .link-btn { opacity: 1; }
.role-icon { width: 1.2em; height: 1.2em; vertical-align: -0.25em; }
.role-badge .role-icon { width: 1.1em; height: 1.1em; }
.role-only { display: inline-flex; opacity: .45; }
.role-only .role-icon { width: 20px; height: 20px; vertical-align: middle; }
.role-only.main { opacity: 1; }
.role-only.main .role-icon { width: 26px; height: 26px; }
.badges:has(.role-only) { align-items: center; gap: 6px; }
.roster th:first-child, .roster td:first-child { width: 200px; min-width: 200px; max-width: 200px; white-space: normal; overflow-wrap: anywhere; }
#editor { scroll-margin-top: 110px; }
