:root {
  --bg: #030303;
  --panel: #111111;
  --panel-2: #171717;
  --ink: #f8f8f8;
  --muted: #9b9b9b;
  --line: #303030;
  --accent: #f2a51b;
  --danger: #e36b5c;
  --green: #0b2e08;
  --blue: #8ec7df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

button,
input,
select,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

button {
  cursor: pointer;
  background: var(--panel-2);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input,
select,
textarea {
  width: 100%;
  padding: 0 14px;
  background: #111614;
}

textarea {
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.35;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.app:has(.game:not(.hidden)) {
  width: min(1400px, calc(100vw - 16px));
}

.game {
  width: 100%;
  margin: 0 auto;
  padding-bottom: 48px;
}

.entry {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 1fr minmax(300px, 420px);
  gap: 48px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: clamp(64px, 14vw, 180px);
  line-height: 0.85;
  letter-spacing: 0;
}

.signal {
  display: block;
  width: 84px;
  height: 84px;
  margin-bottom: 28px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 18px rgba(210, 226, 93, 0.18), 0 0 42px rgba(210, 226, 93, 0.2);
}

.entry-panel,
.admin {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 30, 0.9);
}

.entry-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.entry-pack {
  display: grid;
  gap: 7px;
}

.entry-pack span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.room-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(210, 226, 93, 0.35);
  border-radius: 8px;
}

.admin-link:hover {
  background: rgba(210, 226, 93, 0.08);
}

.primary {
  color: #151812;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

.error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
}

.topbar > div {
  display: grid;
  gap: 4px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.host-actions {
  display: flex !important;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.host-actions.hidden {
  display: none !important;
}

.admin {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px;
}

.admin-shell {
  width: min(1280px, calc(100vw - 32px));
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-top h1 {
  margin: 0;
  font-size: 44px;
  letter-spacing: 0;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 140px 140px;
  gap: 10px;
  align-items: end;
}

.admin-toolbar label {
  display: grid;
  gap: 7px;
}

.admin-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.admin h2 {
  margin: 4px 0 0;
  font-size: 22px;
  letter-spacing: 0;
}

.setup-status {
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.setup-status.good {
  color: var(--accent);
  border-color: rgba(210, 226, 93, 0.45);
  background: rgba(210, 226, 93, 0.08);
}

.setup-status.bad {
  color: var(--danger);
  border-color: rgba(227, 107, 92, 0.45);
  background: rgba(227, 107, 92, 0.08);
}

.admin-grid,
.category-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin label,
.category-box {
  display: grid;
  gap: 7px;
}

.pack-field {
  min-width: 0;
}

.pack-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 8px;
}

.admin label span,
.category-box span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.wide {
  grid-column: 1 / -1;
}

.category-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(56, 65, 59, 0.8);
  border-radius: 8px;
  background: rgba(17, 22, 20, 0.62);
}

.category-box b {
  color: var(--accent);
}

.scenario-editor,
.bunker-editor {
  display: grid;
  gap: 12px;
}

.scenario-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scenario-head span,
.scenario-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.scenario-head button {
  min-width: 180px;
}

#scenarioList {
  display: grid;
  gap: 12px;
}

.scenario-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(56, 65, 59, 0.9);
  border-radius: 8px;
  background: rgba(17, 22, 20, 0.68);
}

.scenario-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 10px;
  align-items: end;
}

.scenario-card label {
  display: grid;
  gap: 7px;
}

.scenario-card textarea {
  min-height: 180px;
}

.bunker-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ability-editor {
  display: grid;
  gap: 12px;
}

#professionAbilityList {
  display: grid;
  gap: 10px;
}

.ability-picker {
  max-width: 420px;
}

.ability-picker label {
  display: grid;
  gap: 7px;
}

.ability-picker span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.ability-row {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(56, 65, 59, 0.9);
  border-radius: 8px;
  background: rgba(17, 22, 20, 0.68);
}

.ability-row h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-transform: none;
}

.ability-level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ability-level-grid label {
  display: grid;
  gap: 6px;
}

.ability-level-grid span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.ability-level-grid textarea {
  min-height: 74px;
  font-size: 13px;
}

.cataclysm-screen {
  min-height: 760px;
  display: grid;
  place-items: center;
  margin-bottom: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), #000 94%),
    radial-gradient(circle at 44% 22%, rgba(255, 219, 129, 0.92) 0 4%, rgba(229, 124, 36, 0.42) 5% 14%, transparent 26%),
    radial-gradient(circle at 22% 18%, rgba(142, 43, 23, 0.72), transparent 30%),
    linear-gradient(105deg, rgba(99, 45, 33, 0.92), rgba(23, 48, 57, 0.9));
  background-color: #080808;
  overflow: hidden;
  position: relative;
}

.cataclysm-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 36%, rgba(255, 255, 255, 0.13) 36.2% 36.8%, transparent 37%),
    repeating-linear-gradient(90deg, transparent 0 70px, rgba(255, 255, 255, 0.07) 72px 74px, transparent 76px 138px),
    linear-gradient(0deg, #080808 0 19%, transparent 19%),
    radial-gradient(ellipse at 50% 100%, rgba(208, 166, 88, 0.44), transparent 33%);
  opacity: 0.72;
}

.cataclysm-screen::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 34px;
  width: min(430px, 48vw);
  height: 210px;
  transform: translateX(-50%);
  border: 14px solid #202520;
  border-bottom-width: 34px;
  background:
    repeating-linear-gradient(90deg, #22313a 0 30px, #14232b 30px 34px),
    linear-gradient(#576063, #2b3334);
  box-shadow: 0 28px 80px #000;
  opacity: 0.94;
}

.cataclysm-content {
  position: relative;
  z-index: 1;
  width: min(880px, calc(100vw - 48px));
  margin-bottom: 86px;
  text-align: center;
  text-shadow: 0 2px 16px #000;
}

.cataclysm-content h2,
.candidate-screen h2,
.player-info-screen h2,
.results-screen h2,
.special-screen h2,
.event-screen h2 {
  margin: 0 0 28px;
  text-align: center;
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: 0;
}

.cataclysm-content p {
  margin: 0 auto 22px;
  max-width: 820px;
  line-height: 1.7;
  font-weight: 700;
}

.survival {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.world-survivors {
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  font-weight: 800;
}

#speakBtn {
  min-width: 170px;
  color: #fff;
  border-color: rgba(242, 165, 27, 0.7);
  background: rgba(0, 0, 0, 0.54);
  font-weight: 800;
}

.bunker-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 70px;
  min-height: 500px;
  padding: 72px 74px 46px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 0%, rgba(242, 165, 27, 0.12), transparent 22rem),
    #020202;
}

.bunker-copy h2 {
  margin: 0 0 48px;
  text-align: center;
  font-size: 36px;
}

.bunker-copy p {
  max-width: 640px;
  margin: 0 0 58px;
  line-height: 1.45;
  font-weight: 800;
}

.bunker-copy strong {
  display: block;
  font-size: 34px;
}

.bunker-copy strong::first-letter,
.candidate-screen h2 span,
.player-info-screen h2 span {
  color: var(--accent);
}

.bunker-stats {
  display: grid;
  gap: 28px;
}

.bunker-stats article {
  display: grid;
  gap: 12px;
  min-height: 92px;
  padding: 24px 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 8, 8, 0.78);
}

.bunker-stats span {
  color: var(--muted);
}

.bunker-stats strong {
  font-size: 18px;
}

.candidate-screen,
.player-info-screen,
.results-screen,
.special-screen,
.event-screen {
  padding: 48px 8px 28px;
  background: #000;
}

.table-scroll {
  overflow-x: auto;
  border-left: 1px solid var(--line);
}

.game-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #050505;
}

.game-table th,
.game-table td {
  min-height: 72px;
  padding: 18px 15px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.game-table th {
  color: #fff;
  background: #070707;
  font-size: 12px;
}

.game-table tr.out {
  opacity: 0.35;
}

.game-table tr.selected {
  outline: 2px solid rgba(242, 165, 27, 0.55);
  outline-offset: -2px;
}

.name-cell {
  width: 180px;
}

.name-cell,
.action-cell {
  white-space: normal;
}

.name-cell span:first-child {
  display: inline-block;
  min-width: 18px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 0 8px;
  border: 1px solid #555;
  border-radius: 50%;
  color: var(--accent);
  vertical-align: middle;
}

.avatar.dim {
  color: var(--muted);
}

.player-link {
  min-height: 0;
  padding: 0;
  border: 0;
  color: #fff;
  background: transparent;
  font-weight: 900;
}

.concealed {
  color: #4f4f4f;
}

.game-table td > span,
.info-row strong > span {
  display: block;
}

.card-ability {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 700;
}

.action-cell button {
  min-height: 34px;
  margin: 2px;
  padding: 0 10px;
  border-color: rgba(242, 165, 27, 0.42);
}

.speech-timer {
  width: fit-content;
  margin: 0 auto 18px;
  padding: 12px 18px;
  border: 1px solid rgba(242, 165, 27, 0.55);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(17, 22, 20, 0.88);
  font-weight: 900;
}

.player-info-screen {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 34px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 180px;
  padding: 0 44px;
}

.info-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 74px;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  border-bottom: 1px dashed var(--line);
}

.info-row span {
  color: var(--muted);
}

.info-row strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.info-row button {
  min-height: 30px;
  padding: 0 8px;
  color: var(--accent);
  border-color: rgba(242, 165, 27, 0.55);
  background: #050505;
  font-size: 12px;
}

.info-row i {
  color: #168814;
  font-size: 12px;
  font-style: normal;
  text-align: right;
}

.special-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  margin-top: 28px;
  padding: 18px 220px;
  background: var(--green);
}

.host-character-editor {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 18px 44px 28px;
  padding: 14px;
  border: 1px solid rgba(242, 165, 27, 0.34);
  border-radius: 8px;
  background: rgba(17, 22, 20, 0.8);
}

.host-character-editor label {
  display: grid;
  gap: 7px;
  grid-column: span 2;
}

.host-character-editor label:nth-of-type(3) {
  grid-column: span 2;
}

.host-character-editor span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.host-bunker-editor {
  display: grid;
  gap: 14px;
  margin: 14px 0 0;
  padding: 18px;
  border: 1px solid rgba(242, 165, 27, 0.34);
  border-radius: 8px;
  background: rgba(17, 22, 20, 0.86);
}

.host-bunker-editor h2 {
  margin: 0;
  font-size: 22px;
}

.host-bunker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.host-bunker-grid label {
  display: grid;
  gap: 7px;
}

.host-bunker-grid .wide {
  grid-column: 1 / -1;
}

.host-bunker-grid span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.host-bunker-grid textarea {
  min-height: 150px;
  resize: vertical;
}

.special-row {
  border-color: rgba(255, 255, 255, 0.12);
}

.vote-results {
  display: grid;
  justify-items: center;
  width: min(1120px, 100%);
  margin: 0 auto 28px;
}

.vote-line {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 74px;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.vote-line div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.vote-line progress {
  width: 100%;
  height: 7px;
  accent-color: var(--accent);
}

.vote-line em {
  font-style: normal;
  font-weight: 800;
}

.vote-line small {
  grid-column: 2 / 3;
  color: var(--muted);
}

.votes p,
.log p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 820px) {
  .entry,
  .admin-toolbar,
  .admin-grid,
  .category-editor,
  .scenario-card-head,
  .bunker-fields,
  .bunker-screen,
  .info-grid,
  .special-band {
    grid-template-columns: 1fr;
  }

  .bunker-screen {
    padding: 42px 22px;
    gap: 28px;
  }

  .info-grid,
  .special-band {
    padding: 0 18px;
    gap: 0;
  }

  .admin-head {
    display: grid;
  }

  .admin-top {
    align-items: stretch;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .host-actions {
    width: 100%;
  }

  .host-actions button {
    flex: 1;
  }

  .side {
    position: static;
  }
}

@media (max-width: 480px) {
  .app {
    width: min(100vw - 20px, 1180px);
    padding: 10px 0;
  }

  .room-row,
  .pack-row,
  .info-row {
    grid-template-columns: 1fr;
  }

  .cataclysm-screen {
    min-height: 620px;
  }
}
