:root {
  color-scheme: dark;
  --bg: #05070d;
  --bg-soft: #0a0f1a;
  --panel: rgba(10, 16, 28, 0.84);
  --panel-strong: rgba(15, 24, 40, 0.96);
  --panel-edge: rgba(120, 158, 255, 0.14);
  --text: #f4f7ff;
  --muted: #94a3c7;
  --line: rgba(118, 147, 212, 0.22);
  --brand: #ff4466;
  --brand-2: #7c8cff;
  --brand-3: #16c2d5;
  --gold: #ffd166;
  --success: #4ed39a;
  --danger: #ff6b7d;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

.connection-status { color: var(--success); font-size: 0.9rem; }
.connection-error { color: var(--gold); }

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans KR", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(124, 140, 255, 0.14), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(255, 68, 102, 0.14), transparent 24%),
    linear-gradient(180deg, #060913 0%, #04060b 100%);
  overflow-x: hidden;
}

body[data-phase="night"],
body[data-phase="nightResult"] {
  background:
    radial-gradient(circle at top, rgba(255, 68, 102, 0.16), transparent 30%),
    radial-gradient(circle at 75% 18%, rgba(124, 140, 255, 0.12), transparent 26%),
    linear-gradient(180deg, #04060d 0%, #020308 100%);
}

body[data-phase="day"],
body[data-phase="vote"],
body[data-phase="voteResult"] {
  background:
    radial-gradient(circle at top, rgba(255, 209, 102, 0.08), transparent 28%),
    radial-gradient(circle at 78% 18%, rgba(22, 194, 213, 0.1), transparent 24%),
    linear-gradient(180deg, #070b14 0%, #04060b 100%);
}

body[data-phase="ended"] {
  background:
    radial-gradient(circle at top, rgba(255, 68, 102, 0.18), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(255, 209, 102, 0.12), transparent 25%),
    linear-gradient(180deg, #070812 0%, #03040a 100%);
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

.page-shell {
  position: relative;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

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

.backdrop-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(14px);
  opacity: 0.36;
}

.orb-1 {
  top: 80px;
  left: -120px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(255, 68, 102, 0.34), transparent 68%);
}

.orb-2 {
  right: -80px;
  bottom: 60px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(22, 194, 213, 0.22), transparent 70%);
}

.backdrop-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 140, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 140, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 80%);
}

.hero,
.app-shell {
  position: relative;
  z-index: 1;
}

.hero {
  margin-bottom: 28px;
  padding: 18px 0 8px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 700;
}

.hero h1,
.panel h2,
.panel h3 {
  margin: 0;
  font-family: "Black Ops One", system-ui, sans-serif;
  letter-spacing: 0.03em;
}

.hero h1 {
  max-width: 11ch;
  font-size: clamp(2.8rem, 5vw, 5.5rem);
  line-height: 0.92;
  text-shadow: 0 0 18px rgba(124, 140, 255, 0.22);
}

.hero-copy {
  max-width: 58ch;
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 26%),
    var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 26px;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(124, 140, 255, 0.08), transparent 40%, rgba(255, 68, 102, 0.08));
  pointer-events: none;
}

.panel-accent {
  border-color: rgba(255, 68, 102, 0.3);
}

.panel-room {
  grid-column: 1 / -1;
}

#boot-fallback {
  width: 100%;
}

.fatal-panel {
  grid-column: 1 / -1;
  border-color: rgba(255, 68, 102, 0.4);
}

.panel-header,
.player-section-header,
.room-topline,
.host-card,
.room-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.summary-label,
.section-note,
.summary-hint,
.muted {
  color: var(--muted);
}

.field input {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(7, 12, 20, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.field input::placeholder {
  color: rgba(148, 163, 199, 0.62);
}

.field input:focus {
  outline: none;
  border-color: rgba(124, 140, 255, 0.68);
  box-shadow: 0 0 0 4px rgba(124, 140, 255, 0.12);
  transform: translateY(-1px);
}

.settings-select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(7, 12, 20, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.settings-toggle {
  justify-content: flex-start;
}

.button {
  position: relative;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 160ms ease, opacity 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-primary {
  color: #fff7fa;
  background: linear-gradient(135deg, var(--brand), #c52856);
  box-shadow: 0 12px 30px rgba(255, 68, 102, 0.24);
}

.button-secondary {
  color: var(--text);
  background: linear-gradient(135deg, rgba(124, 140, 255, 0.24), rgba(22, 194, 213, 0.2));
  border-color: rgba(124, 140, 255, 0.22);
}

.button-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--line);
}

.button-danger {
  color: #ffe8ec;
  background: linear-gradient(135deg, rgba(255, 68, 102, 0.92), rgba(164, 24, 55, 0.96));
  box-shadow: 0 10px 24px rgba(255, 68, 102, 0.2);
}

.button-inline {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
  border-radius: 12px;
}

.header-action-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.testing-reset-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  min-height: 48px;
  padding: 0 18px;
  box-shadow: 0 14px 32px rgba(255, 68, 102, 0.28);
}

.room-summary {
  margin: 24px 0 28px;
  flex-wrap: wrap;
}

.summary-card {
  flex: 1 1 240px;
  padding: 18px;
  display: grid;
  gap: 7px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.summary-card strong {
  font-size: 1.45rem;
}

.player-section {
  display: grid;
  gap: 18px;
}

.player-list,
.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.player-list {
  display: grid;
  gap: 12px;
}

.player-item,
.result-list-item,
.vote-option {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

.player-item-alive {
  box-shadow: inset 0 0 0 1px rgba(78, 211, 154, 0.06);
}

.player-item-dead {
  opacity: 0.64;
  background:
    linear-gradient(135deg, rgba(255, 68, 102, 0.08), transparent 60%),
    var(--panel-strong);
}

.player-item strong {
  display: block;
  margin-bottom: 4px;
}

.player-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.badge-host {
  color: #fff2bf;
  background: rgba(255, 209, 102, 0.16);
}

.badge-me {
  color: #d9fff4;
  background: rgba(78, 211, 154, 0.16);
}

.host-controls {
  margin-top: 24px;
}

.host-card {
  align-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(124, 140, 255, 0.14), rgba(255, 68, 102, 0.08)),
    var(--panel-strong);
  border: 1px solid rgba(124, 140, 255, 0.18);
  border-radius: 24px;
}

.role-copy {
  display: grid;
  gap: 8px;
}

.role-description,
.role-confirmed,
.result-summary {
  margin: 0;
  line-height: 1.7;
}

.role-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: min(100%, 320px);
}

.discussion-card,
.vote-card,
.result-card,
.night-card {
  align-items: flex-start;
}

.discussion-card .role-action,
.result-card .role-action,
.night-card .role-action {
  align-items: stretch;
  justify-content: stretch;
}

.discussion-timer {
  margin: 2px 0 0;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  color: #ffffff;
  text-shadow:
    0 0 14px rgba(124, 140, 255, 0.3),
    0 0 30px rgba(255, 68, 102, 0.22);
}

.discussion-hint {
  margin: 8px 0 0;
  color: #e3e9ff;
  font-weight: 700;
}

.vote-action {
  display: grid;
  gap: 14px;
  width: min(100%, 340px);
}

.waiting-settings-card {
  align-items: flex-start;
}

.waiting-settings-actions {
  width: min(100%, 420px);
}

.role-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  width: min(100%, 420px);
}

.role-pick-card {
  min-height: 132px;
  padding: 16px 12px;
  border-radius: 18px;
  border: 1px solid rgba(124, 140, 255, 0.26);
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(124, 140, 255, 0.18), rgba(255, 68, 102, 0.14)),
    rgba(7, 12, 20, 0.96);
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.role-pick-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(255, 209, 102, 0.44);
}

.role-pick-card:disabled,
.role-pick-card-claimed {
  cursor: not-allowed;
  opacity: 0.52;
}

.role-reveal-shell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 62vh;
  padding: 24px;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.68)),
    radial-gradient(circle at top, rgba(124, 140, 255, 0.16), transparent 34%),
    rgba(3, 5, 10, 0.92);
}

.role-reveal-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.03), transparent 55%);
  pointer-events: none;
}

.role-reveal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 860px);
  padding: 32px 28px;
  border-radius: 28px;
  border: 1px solid rgba(124, 140, 255, 0.2);
  background:
    linear-gradient(135deg, rgba(124, 140, 255, 0.12), rgba(255, 68, 102, 0.08)),
    rgba(8, 12, 20, 0.92);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

.role-reveal-copy {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.role-reveal-copy h3 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.role-reveal-action {
  display: grid;
  gap: 20px;
  justify-items: center;
  margin-top: 24px;
}

.role-card-grid-overlay {
  width: min(100%, 720px);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.role-pick-card-face-down {
  min-height: 190px;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 20px 14px;
  background:
    linear-gradient(160deg, rgba(124, 140, 255, 0.24), rgba(255, 68, 102, 0.16)),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0.04) 10px,
      rgba(0, 0, 0, 0.02) 10px,
      rgba(0, 0, 0, 0.02) 20px
    ),
    rgba(7, 12, 20, 0.96);
}

.role-pick-card-mark {
  font-size: 0.74rem;
  letter-spacing: 0.24em;
  color: var(--gold);
}

.role-flip-scene {
  perspective: 1200px;
}

.role-flip-card {
  position: relative;
  width: min(280px, 70vw);
  height: 380px;
  transform-style: preserve-3d;
  transition: transform 720ms cubic-bezier(0.22, 1, 0.36, 1);
}

.role-flip-card.is-revealed {
  transform: rotateY(180deg);
}

.role-flip-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(124, 140, 255, 0.24);
  backface-visibility: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.role-flip-front {
  background:
    linear-gradient(160deg, rgba(124, 140, 255, 0.22), rgba(255, 68, 102, 0.14)),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0.04) 10px,
      rgba(0, 0, 0, 0.02) 10px,
      rgba(0, 0, 0, 0.02) 20px
    ),
    rgba(7, 12, 20, 0.96);
}

.role-flip-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at top, rgba(255, 209, 102, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 68, 102, 0.12), rgba(124, 140, 255, 0.12)),
    rgba(7, 12, 20, 0.98);
}

.role-flip-role {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.06em;
}

.role-flip-team {
  color: var(--gold);
  font-weight: 700;
}

.role-action,
.vote-action {
  grid-auto-rows: min-content;
}

.role-action .button,
.vote-action .button {
  width: 100%;
}

.role-action > .role-confirmed,
.vote-action > .role-confirmed {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(5, 10, 18, 0.74);
}

.result-card .role-action,
.night-card .vote-action {
  gap: 12px;
}

.vote-form {
  display: grid;
  gap: 12px;
  width: 100%;
}

.vote-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.vote-option:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 140, 255, 0.38);
}

.vote-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.result-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.result-list-item {
  padding: 12px 14px;
}

.result-summary {
  margin-top: 10px;
  font-weight: 700;
}

.result-summary-warning {
  color: var(--danger);
}

.stage-content {
  display: grid;
  gap: 20px;
}

.team-box,
.investigation-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(5, 10, 18, 0.74);
}

.winner-banner {
  margin-bottom: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.winner-banner-citizen {
  background: linear-gradient(135deg, rgba(22, 194, 213, 0.18), rgba(124, 140, 255, 0.12));
}

.winner-banner-mafia {
  background: linear-gradient(135deg, rgba(255, 68, 102, 0.18), rgba(124, 140, 255, 0.12));
}

.winner-title {
  margin: 0;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: 0.04em;
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.final-player-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(5, 10, 18, 0.78);
}

.final-player-card-alive {
  box-shadow: inset 0 0 0 1px rgba(78, 211, 154, 0.08);
}

.final-player-card-dead {
  opacity: 0.76;
  background:
    linear-gradient(135deg, rgba(255, 68, 102, 0.08), transparent 62%),
    rgba(5, 10, 18, 0.78);
}

.final-player-name {
  font-size: 1rem;
}

.final-player-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.final-player-team {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.final-player-team.is-citizen {
  color: #dcfaff;
  background: rgba(22, 194, 213, 0.16);
}

.final-player-team.is-mafia {
  color: #ffe1e6;
  background: rgba(255, 68, 102, 0.16);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  min-width: min(520px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  padding: 14px 18px;
  color: #fff;
  background: rgba(8, 12, 20, 0.94);
  border: 1px solid rgba(124, 140, 255, 0.22);
  border-radius: 18px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.32);
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100% - 20px, 760px);
    padding-top: 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
  }

  .room-topline,
  .player-section-header,
  .host-card {
    flex-direction: column;
    align-items: stretch;
  }

  .button,
  .button-ghost {
    width: 100%;
  }

  .vote-action {
    width: 100%;
  }

  .player-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .player-badges {
    justify-content: flex-start;
  }
}
