:root {
  color-scheme: dark;
  --bg: #090b0c;
  --surface: #141819;
  --surface-2: #1a2021;
  --surface-3: #101314;
  --line: #293132;
  --line-soft: #202728;
  --text: #eef5f1;
  --muted: #9aa8a1;
  --muted-2: #74827c;
  --accent: #34d399;
  --accent-2: #2dd4bf;
  --danger: #fb7185;
  --warn: #fbbf24;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(45, 212, 191, .17), transparent 32rem),
    radial-gradient(circle at 90% 10%, rgba(251, 191, 36, .10), transparent 28rem),
    linear-gradient(135deg, #090b0c 0%, #101314 50%, #0b0d0d 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid rgba(52, 211, 153, .42);
  background: linear-gradient(145deg, rgba(52, 211, 153, .16), rgba(251, 191, 36, .08));
  color: var(--accent);
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
}

.brand p,
.panel-head p,
.hero p,
.hint,
#phaseText {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.55;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(52, 211, 153, .5);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04110d;
}

.btn.ghost {
  background: transparent;
}

.btn.full {
  width: 100%;
}

.badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.green {
  color: var(--accent);
  border-color: rgba(52, 211, 153, .36);
  background: rgba(52, 211, 153, .08);
}

.badge.red {
  color: var(--danger);
  border-color: rgba(251, 113, 133, .36);
  background: rgba(251, 113, 133, .08);
}

.badge.amber {
  color: var(--warn);
  border-color: rgba(251, 191, 36, .36);
  background: rgba(251, 191, 36, .08);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(20, 24, 25, .92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  min-height: 62px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head.compact {
  min-height: 56px;
}

.panel-head h2 {
  margin: 0;
}

.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: stretch;
}

.room-board {
  min-height: 560px;
}

.room-list {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.room-card,
.empty-rooms {
  min-height: 76px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #101314;
  padding: 14px;
}

.room-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.room-card strong,
.empty-rooms strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
}

.room-card span,
.empty-rooms span {
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.hero {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(52, 211, 153, .12), transparent 42%),
    linear-gradient(160deg, rgba(251, 191, 36, .09), transparent 55%),
    #111516;
  box-shadow: var(--shadow);
}

.hero-inner {
  min-height: 560px;
  position: relative;
  display: grid;
  align-items: end;
  padding: clamp(22px, 4vw, 44px);
}

.hero-copy {
  width: min(680px, 100%);
  position: relative;
  z-index: 2;
}

.hero h2 {
  margin: 16px 0 14px;
  font-size: clamp(34px, 5.5vw, 78px);
  line-height: .98;
  letter-spacing: 0;
}

.hero p {
  max-width: 620px;
  font-size: 17px;
}

.signal {
  position: absolute;
  inset: 0;
  opacity: .72;
  overflow: hidden;
}

.signal span {
  position: absolute;
  width: 2px;
  height: 45%;
  background: linear-gradient(to bottom, transparent, rgba(52, 211, 153, .55), transparent);
  transform: rotate(28deg);
}

.signal span:nth-child(1) { left: 58%; top: -3%; }
.signal span:nth-child(2) { left: 70%; top: 16%; height: 60%; background: linear-gradient(to bottom, transparent, rgba(251, 191, 36, .42), transparent); }
.signal span:nth-child(3) { left: 83%; top: -8%; height: 75%; }
.signal span:nth-child(4) { left: 45%; top: 32%; height: 38%; background: linear-gradient(to bottom, transparent, rgba(45, 212, 191, .38), transparent); }

.form-panel {
  padding: 18px;
}

.quick-rule,
.rule-stack {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auto-start {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #101314;
  padding: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.tab.active {
  background: rgba(52, 211, 153, .14);
  color: var(--accent);
}

label {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1213;
  color: var(--text);
  padding: 10px 12px;
  outline: 0;
}

textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(52, 211, 153, .68);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .12);
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

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

.lobby {
  max-width: 980px;
  margin: 0 auto;
}

.share-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 16px;
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.player {
  min-height: 58px;
  padding: 10px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #101314;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(45, 212, 191, .12);
  color: var(--accent-2);
  font-weight: 900;
}

.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.meta {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 12px;
}

.game {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.game > .panel,
.table,
.action {
  min-height: 620px;
}

.table {
  display: flex;
  flex-direction: column;
}

.timeline {
  flex: 1;
  max-height: calc(100vh - 180px);
  min-height: 540px;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.message {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #101314;
  padding: 12px;
}

.message.system {
  background: rgba(251, 191, 36, .07);
  border-color: rgba(251, 191, 36, .25);
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message p {
  margin: 0;
  line-height: 1.62;
  word-break: break-word;
}

.action {
  padding: 16px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.turn-card {
  border: 1px solid rgba(52, 211, 153, .32);
  border-radius: var(--radius);
  background: rgba(52, 211, 153, .07);
  padding: 14px;
}

.turn-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.turn-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 22px;
  word-break: break-word;
}

.turn-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title h3 {
  margin: 0;
}

.vote-board,
.event-log {
  display: grid;
  gap: 8px;
}

.vote-row {
  display: grid;
  gap: 6px;
}

.vote-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.meter {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #0b0d0e;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--warn));
}

.event-log {
  max-height: 220px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(52, 211, 153, .38);
  background: #101414;
  color: var(--text);
  box-shadow: var(--shadow);
}

.end {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 5, .72);
  backdrop-filter: blur(10px);
}

.vote-modal {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 5, 5, .72);
  backdrop-filter: blur(10px);
}

.vote-box {
  width: min(640px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #141819;
  box-shadow: var(--shadow);
  padding: 18px;
}

.vote-head {
  margin-bottom: 16px;
}

.vote-head h2 {
  margin: 10px 0 0;
  font-size: 24px;
}

.vote-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.vote-choice {
  aspect-ratio: 1;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101314;
  color: var(--text);
  display: grid;
  place-items: center;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.vote-choice:hover,
.vote-choice.selected {
  transform: translateY(-1px);
  border-color: rgba(52, 211, 153, .7);
  background: rgba(52, 211, 153, .12);
}

.vote-choice span {
  width: min(72px, 72%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(45, 212, 191, .14);
  color: var(--accent-2);
  font-size: clamp(22px, 7vw, 34px);
  font-weight: 950;
}

.end-box {
  width: min(660px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #141819;
  box-shadow: var(--shadow);
  padding: 24px;
}

.end-box h2 {
  margin: 12px 0 8px;
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1;
}

.end-box p {
  color: var(--muted);
  line-height: 1.6;
}

.reveal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

@media (max-width: 1120px) {
  .home,
  .game,
  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .game > .panel,
  .table,
  .action {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .mark {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 19px;
  }

  .brand p {
    font-size: 13px;
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions .btn,
  .top-actions .badge {
    flex: 1;
  }

  .hero,
  .hero-inner {
    min-height: 250px;
  }

  .hero-inner {
    padding: 20px;
  }

  .hero h2 {
    font-size: 30px;
    line-height: 1.02;
  }

  .hero p {
    font-size: 15px;
  }

  .share-box,
  .range-row,
  .field-grid,
  .room-card,
  .vote-choices,
  .reveal-grid {
    grid-template-columns: 1fr;
  }

  .vote-choice {
    aspect-ratio: auto;
    min-height: 76px;
  }

  .vote-choice span {
    width: 56px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .lobby-grid,
  .form-panel,
  .room-list,
  .share-box,
  .action,
  .timeline {
    padding: 12px;
  }

  .game {
    gap: 12px;
  }

  .table {
    order: 1;
  }

  .action {
    order: 2;
  }

  .game > aside:first-child {
    order: 3;
  }

  .timeline {
    min-height: 330px;
    max-height: 46vh;
  }

  textarea {
    min-height: 96px;
  }

  .turn-card strong {
    font-size: 19px;
  }

  .event-log {
    max-height: 150px;
  }
}
