:root {
  --bg: #111;
  --text: #ddd;
  --dim: #888;
  --line: #2a2a2a;
  --field: #1b1b1b;
  --accent: #f2f2f2;
  --red: #e06060;
  --green: #6cc07c;
  --blue: #6aa6e0;
  --purple: #b08ce6;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
a { color: var(--accent); }

/* ── top bar ── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .25em; color: var(--accent); font-size: 16px; }
.tabs { display: flex; gap: 16px; }
.tabs button { background: none; border: 0; padding: 4px 0; color: var(--dim); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.btn {
  background: var(--field); border: 1px solid #333; border-radius: 3px;
  padding: 5px 11px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #555; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 700; }
.btn.ghost { background: none; }
.btn.danger { color: var(--red); }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-bottom: 24px; }
.toolbar .sep { width: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 12px; }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }
.field.check { flex-direction: row; align-items: center; color: var(--text); }
.field input, .field select, .field textarea {
  background: var(--field); border: 1px solid #333; border-radius: 3px; padding: 5px 7px; color: var(--text);
}
.field.inline input { width: 56px; }
.field textarea { resize: vertical; min-height: 56px; }

/* ── cast ── */
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 34px 20px; }
.district { text-align: center; }
.district h3 { margin: 0 0 10px; font-weight: 400; }
.district h3 input { background: none; border: 0; border-bottom: 1px dashed transparent; color: var(--text); font: inherit; font-size: 14px; text-align: center; width: 260px; padding: 2px; }
.district h3 input:hover, .district h3 input:focus { border-bottom-color: #444; outline: none; }
.district-members { display: flex; flex-wrap: wrap; gap: 26px; justify-content: center; }
.tcard { width: 150px; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.tcard .pfp { width: 90px; height: 90px; align-self: center; cursor: pointer; object-fit: cover; background: #000; outline: 1px solid #333; }
.tcard .pfp:hover, .tcard.drag .pfp { outline: 2px solid var(--accent); }
.tcard input[type=text], .tcard select {
  width: 100%; background: none; border: 0; border-bottom: 1px solid #333; padding: 3px 2px; font-size: 12px; text-align: center; text-align-last: center;
}
.tcard select option { background: var(--field); }
.tcard input.name { font-size: 13px; color: var(--text); }
.tcard input:focus, .tcard select:focus { outline: none; border-bottom-color: var(--accent); }
.tcard .row { display: flex; gap: 6px; justify-content: center; }
.tcard .row > select { flex: 1; min-width: 0; }
.tcard .row .pron { flex: 0 0 44%; }
.tcard .linkbtn { background: none; border: 0; color: var(--dim); font-size: 11px; cursor: pointer; padding: 0; }
.tcard .linkbtn:hover { color: var(--accent); }
.tune-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 560px) { .tune-grid { grid-template-columns: 1fr; } }
.tune { display: grid; grid-template-columns: 90px 1fr 22px; gap: 6px 8px; align-items: center; color: var(--dim); }
.tune input[type=range] { width: 100%; accent-color: #bbb; }
.tune b { color: var(--text); text-align: right; font-weight: 400; }
.tune .hd { grid-column: 1 / -1; color: var(--text); display: flex; justify-content: space-between; }
.tune .pts { color: var(--dim); }

/* ── custom events list ── */
.evt-list { display: flex; flex-direction: column; }
.evt-row { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.evt-row.off { opacity: .4; }
.evt-row .txt { flex: 1; min-width: 0; }
.evt-row .txt .m { color: var(--dim); font-size: 11px; margin-top: 3px; }
.tagpill { margin-right: 8px; }
.tagpill.lethal { color: var(--red); }
.tagpill.arena { color: var(--accent); }
.empty { color: var(--dim); padding: 30px; text-align: center; }

.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; max-width: 860px; margin: 0 auto; }

/* ── sim layout ── */
#sim { display: grid; grid-template-columns: 1fr 300px; gap: 30px; align-items: start; }
@media (max-width: 1000px) { #sim { grid-template-columns: 1fr; } }
.phase-head { text-align: center; margin: 6px 0 18px; }
.phase-head h1 { margin: 0; font-size: 24px; font-weight: 400; }
.phase-head .meta { color: var(--dim); margin-top: 4px; }
.sim-side { position: sticky; top: 62px; display: flex; flex-direction: column; gap: 18px; max-height: calc(100vh - 80px); }
.panel { padding: 0; }
.sim-side .panel:last-child { overflow: auto; min-height: 0; }

/* events */
.feed { display: flex; flex-direction: column; }
.ev { padding: 16px 0; border-bottom: 1px solid var(--line); text-align: center; animation: fade .3s ease both; }
.ev:last-child { border-bottom: 0; }
.ev.announce { color: var(--accent); font-style: italic; }
@keyframes fade { from { opacity: 0; } }
.ev-actors { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 8px; }
.actor { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 92px; }
.actor .av { width: 72px; height: 72px; object-fit: cover; cursor: pointer; background: #000; }
.actor.dead .av { filter: grayscale(1) brightness(.5); }
.actor .an { display: none; }
.actor .chips { display: flex; flex-direction: column; align-items: center; font-size: 10.5px; line-height: 1.35; }
.chip.bad { color: var(--red); }
.chip.good { color: var(--green); }
.chip.item { color: var(--blue); }
.chip.lost { color: var(--dim); }
.chip.ally { color: var(--purple); }
.chip.dead { color: var(--red); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.hide-stats .chip:not(.dead) { display: none; }
.ev-text { margin: 0 auto; max-width: 680px; line-height: 1.6; }
.tn { color: var(--accent); cursor: pointer; }
.tn:hover { text-decoration: underline; }

/* fallen */
.fallen-grid { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.fallen { width: 140px; text-align: center; animation: fade .3s ease both; }
.fallen img { width: 90px; height: 90px; object-fit: cover; filter: grayscale(1); }
.fallen .nm { margin-top: 6px; }
.fallen .d { color: var(--dim); font-size: 11px; }
.fallen .c { font-size: 11.5px; margin-top: 3px; color: var(--dim); }
.cannon { color: var(--dim); text-align: center; margin-bottom: 20px; }

/* winner */
.winner { text-align: center; padding: 10px 0 24px; }
.winner img { width: 150px; height: 150px; object-fit: cover; }
.winner h2 { margin: 10px 0 2px; font-size: 22px; font-weight: 400; color: var(--accent); }
.winner .sub { color: var(--dim); }
.end-actions { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.awards { display: flex; flex-wrap: wrap; gap: 30px; justify-content: center; margin-bottom: 24px; text-align: center; }
.award { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.award img { width: 48px; height: 48px; object-fit: cover; }
.award .k { font-size: 11px; color: var(--dim); }
table.places { width: 100%; border-collapse: collapse; }
.places th, .places td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.places th { font-weight: 400; color: var(--dim); }
.places img { width: 26px; height: 26px; object-fit: cover; vertical-align: middle; margin-right: 8px; }

/* map */
.map { position: relative; width: 100%; aspect-ratio: 1; }
.zone {
  position: absolute; width: 31%; height: 31%; transform: translate(-50%, -50%);
  border-radius: 50%; border: 1px solid #333;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px;
}
.zone .zn { font-size: 10px; color: var(--dim); }
.zone .dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 86%; }
.zone .dots img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; cursor: pointer; }
.zone .more { font-size: 10px; color: var(--dim); }
.zone.cornucopia { border-color: #6b5626; }
.zone.cornucopia .zn { color: var(--accent); }
.zone.closed { border-style: dashed; border-color: #6b2c2c; opacity: .5; }
.zone.closed .zn { color: var(--red); }
.zone.burned { border-color: #8a4a1e; }

/* roster */
.roster-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; color: var(--dim); }
.roster-head select { background: var(--field); border: 1px solid #333; border-radius: 3px; padding: 2px 4px; font-size: 11px; }
.roster { display: flex; flex-direction: column; }
.rt { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 4px 2px; cursor: pointer; }
.rt:hover { background: #1a1a1a; }
.rt img { width: 30px; height: 30px; object-fit: cover; }
.rt.dead { opacity: .35; }
.rt.dead img { filter: grayscale(1); }
.rt .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 5px; align-items: center; }
.rt .ally-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.rt .sub { font-size: 10.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 3px; margin-top: 3px; }
.bar { height: 3px; background: #2a2a2a; overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar.hp i { background: var(--red); }
.bar.food i { background: var(--green); }
.bar.water i { background: var(--blue); }
.bar.energy i { background: #999; }
.bar.stat i { background: #777; }
.rt .k { font-size: 11px; color: var(--dim); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .75); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal-box { background: var(--bg); border: 1px solid #333; width: 100%; max-width: 720px; padding: 20px; position: relative; }
.modal-box h2 { margin: 0 0 14px; font-weight: 400; }
.modal-close { position: absolute; right: 12px; top: 8px; background: none; border: 0; font-size: 22px; color: var(--dim); cursor: pointer; }
.td-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.td-head img { width: 90px; height: 90px; object-fit: cover; }
.td-head .sub { color: var(--dim); }
.td-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
@media (max-width: 640px) { .td-grid { grid-template-columns: 1fr; } }
.td-sec h4 { margin: 0 0 6px; font-weight: 400; color: var(--accent); }
.meter { display: grid; grid-template-columns: 80px 1fr 30px; gap: 8px; align-items: center; margin-bottom: 4px; }
.meter .bar { height: 5px; }
.meter b { text-align: right; font-weight: 400; }
.td-sec .chip { margin-right: 8px; }
.rel { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.rel img { width: 20px; height: 20px; object-fit: cover; }
.rel .v { margin-left: auto; }
.hist { max-height: 260px; overflow: auto; display: flex; flex-direction: column; }
.hist div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.hist small { color: var(--dim); display: block; font-size: 10.5px; }

/* editor */
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.ed-effects { display: grid; gap: 14px; margin: 14px 0; }
.ed-actor { border-top: 1px solid var(--line); padding-top: 10px; }
.ed-actor h5 { margin: 0 0 6px; color: var(--accent); font-weight: 400; font-size: 13px; }
.ed-actor .ed-grid { margin: 0; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.ed-actor .field.wide { grid-column: span 2; }
.phase-checks { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text); }
.phase-checks label { display: flex; gap: 4px; align-items: center; }
.hint { color: var(--dim); font-size: 11px; }
.preview { padding: 10px 0; text-align: center; }
.impact.low { color: var(--green); } .impact.mid { color: var(--accent); } .impact.high { color: var(--red); }
.ed-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; align-items: center; }
.ed-foot .impact { margin-right: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; border: 1px solid #444; padding: 8px 14px; z-index: 60; }

.tcard .btns { margin-top: 2px; }
.tcard .mini { flex: 1; background: var(--field); border: 1px solid #333; border-radius: 3px; padding: 3px 0; font-size: 11px; cursor: pointer; }
.tcard .mini:hover { border-color: #666; }
.tn { font-weight: 700; color: #fff; }
.btn.primary { background: #eee; border-color: #eee; color: #111; }
.btn.primary:hover { background: #fff; }
.tabs button.on { border-bottom-color: #ddd; }
.zone.cornucopia { border-color: #555; }
.ev.announce { color: #bbb; }

/* ── Main menu & modes ── */
.menu { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px; }
.menu-brand { font-weight: 700; letter-spacing: .4em; color: var(--accent); font-size: 28px; padding-left: .4em; }
.menu-pick { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.menu-pick button { background: none; border: 1px solid #333; color: var(--text); padding: 0 40px; width: 320px; height: 190px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.menu-pick button img { max-width: 100%; max-height: 110px; display: block; }
.menu-pick button:hover { border-color: var(--accent); color: var(--accent); }
.menu-pick button[data-mode=squid]:hover { border-color: #e0567f; color: #e0567f; }
.brand { cursor: pointer; }
.brand span { color: var(--dim); font-weight: 400; letter-spacing: .05em; font-size: 13px; margin-left: 8px; }
body:not(.mode-squid) .sq-only { display: none !important; }
body.mode-squid .hg-only { display: none !important; }
body.mode-squid { --accent: #f2f2f2; }
body.mode-squid .brand span { color: #e0567f; }

/* roles */
.tcard .role { color: var(--dim); }
.tcard.guard .pfp { outline: 2px solid #e0567f; }
.tcard.frontman .pfp { outline: 2px solid #f2f2f2; }
.tcard.guard .role, .tcard.frontman .role { color: #e0567f; }

/* squid settings */
.field.wide { grid-column: 1 / -1; }
.sq-games { display: flex; flex-direction: column; max-width: 360px; margin-top: 4px; }
.sq-game { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 13px; }
.sq-game.off span { color: var(--dim); text-decoration: line-through; }
.sq-game span { flex: 1; }
.sq-game .mini { background: var(--field); border: 1px solid #333; border-radius: 3px; color: var(--text); padding: 1px 7px; font-size: 11px; cursor: pointer; }
.sq-game .mini:disabled { opacity: .3; cursor: default; }
.sq-game.locked { color: var(--dim); }

/* prize pot */
.pot { text-align: center; padding: 14px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.pot .pig { width: 46px; height: 46px; margin: 0 auto 8px; border-radius: 50% 50% 46% 46%; border: 1px solid #555; background: linear-gradient(to top, #c9a83a var(--fill, 0%), transparent var(--fill, 0%)); }
#potAmount { font-size: 18px; color: var(--accent); letter-spacing: .03em; }
.num { color: var(--dim); font-size: 11px; margin-left: 4px; }
.ev.staff .ev-text, .ev.tip .ev-text { color: var(--dim); }

.brand { display: flex; align-items: center; }
.brand span img { height: 22px; display: block; }
.settings.sq-only { margin-bottom: 22px; }
.brand span img { height: 26px; }

/* Aervial Games logo */
.menu-brand { margin: 0; padding: 0; letter-spacing: 0; }
.menu-brand img { height: 130px; display: block; }
.brand .brand-logo { height: 22px; display: block; }
.brand span { margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--line); }
