@font-face {
  font-family: "SeoulNamsan";
  src: url("/fonts/SeoulNamsanM.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SeoulNamsan";
  src: url("/fonts/SeoulNamsanB.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SeoulHangang";
  src: url("/fonts/SeoulHangangM.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SeoulAlrim";
  src: url("/fonts/SeoulAlrimTTF-Bold.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #07090c;
  --panel: #10151a;
  --panel-soft: #151c22;
  --panel-hover: #1a2329;
  --text: #f7fbfb;
  --muted: #9aadb1;
  --muted-strong: #c8d6d8;
  --line: rgba(207, 226, 230, 0.16);
  --line-strong: rgba(60, 210, 219, 0.55);
  --cyan: #37d3dc;
  --green: #bce75d;
  --coral: #ff7a70;
  --amber: #ffd166;
  --ink: #061014;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
  --footer-h: 78px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color-scheme: dark;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 30px 20px calc(var(--footer-h) + 28px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(55, 211, 220, 0.12) 0%, rgba(7, 9, 12, 0) 28%),
    linear-gradient(90deg, rgba(255, 209, 102, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(55, 211, 220, 0.08) 1px, transparent 1px),
    radial-gradient(ellipse at top, rgba(188, 231, 93, 0.08), transparent 42%),
    #07090c;
  background-size: auto, 64px 64px, 64px 64px, auto, auto;
  color: var(--text);
  font-family: "SeoulNamsan", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.exam-shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

.host-shell {
  width: min(1180px, 100%);
}

.site-header {
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-family: "SeoulAlrim", "SeoulNamsan", sans-serif;
  font-size: 12px;
  font-weight: 800;
}

.site-title {
  margin: 0;
  color: var(--text);
  font-family: "SeoulAlrim", "SeoulNamsan", sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.08;
}

.site-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  word-break: keep-all;
}

.question-progress,
.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(55, 211, 220, 0.1);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  min-height: 32px;
  border-color: rgba(188, 231, 93, 0.35);
  background: rgba(188, 231, 93, 0.09);
  color: var(--green);
  font-size: 12px;
}

.container {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(21, 28, 34, 0.97), rgba(12, 16, 20, 0.98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.container:not(.game-container) {
  padding: 32px;
}

.game-container {
  padding: 28px;
}

.question-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.question-header.compact {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.question-number {
  display: block;
  margin-bottom: 10px;
  color: var(--cyan);
  font-family: "SeoulAlrim", "SeoulNamsan", sans-serif;
  font-size: 13px;
  font-weight: 800;
}

.question-text {
  margin: 0;
  color: var(--text);
  font-family: "SeoulAlrim", "SeoulNamsan", sans-serif;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.35;
  word-break: keep-all;
}

.join-form,
.setup-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.setup-form {
  grid-template-columns: minmax(0, 1fr) 130px;
  align-items: end;
}

.setup-form .primary-btn {
  grid-column: 1 / -1;
}

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

.field span {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 9, 12, 0.76);
  color: var(--text);
  padding: 0 15px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus {
  border-color: var(--line-strong);
  background: rgba(11, 18, 22, 0.94);
  box-shadow: 0 0 0 3px rgba(55, 211, 220, 0.12);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.candidate-btn,
.copy-btn,
.remove-btn {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.primary-btn {
  background: linear-gradient(180deg, var(--cyan), #159aa5);
  border-color: rgba(55, 211, 220, 0.66);
  color: var(--ink);
}

.ghost-btn {
  background: rgba(21, 28, 34, 0.86);
  border-color: var(--line);
  color: var(--text);
}

.danger-btn {
  background: rgba(255, 122, 112, 0.12);
  border-color: rgba(255, 122, 112, 0.32);
  color: #ffd4d1;
}

.danger-btn.subtle {
  background: rgba(255, 209, 102, 0.08);
  border-color: rgba(255, 209, 102, 0.26);
  color: #ffe1a1;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.candidate-btn:hover,
.copy-btn:hover,
.remove-btn:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none !important;
}

.notice {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--coral);
  font-size: 14px;
}

.secret-stage {
  min-height: 210px;
  display: grid;
  place-items: center;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(55, 211, 220, 0.1), rgba(188, 231, 93, 0.05)),
    rgba(7, 9, 12, 0.54);
  text-align: center;
  padding: 26px;
}

.secret-label {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
}

.secret-word {
  margin: 16px 0 0;
  color: var(--green);
  font-family: "SeoulHangang", "SeoulNamsan", serif;
  font-size: 44px;
  font-weight: 500;
  line-height: 1.22;
  word-break: keep-all;
}

.liar-title {
  margin: 14px 0 0;
  color: var(--coral);
  font-family: "SeoulAlrim", "SeoulNamsan", sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  word-break: keep-all;
}

.liar-copy {
  margin: 12px auto 0;
  max-width: 520px;
  color: var(--muted-strong);
  font-size: 18px;
  line-height: 1.6;
  word-break: keep-all;
}

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

.section-title-row h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.section-title-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.players-title {
  margin-top: 22px;
}

.meter {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(55, 211, 220, 0.2);
  border-radius: 999px;
  background: rgba(7, 9, 12, 0.8);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width 0.22s ease;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.candidate-btn {
  min-height: 58px;
  background: rgba(21, 28, 34, 0.88);
  border-color: var(--line);
  color: var(--text);
}

.candidate-btn.selected {
  border-color: var(--line-strong);
  background: rgba(55, 211, 220, 0.16);
  color: var(--cyan);
}

.candidate-btn.self {
  color: var(--muted);
}

.player-list,
.host-player-list,
.tally-list,
.url-list,
.ban-list {
  display: grid;
  gap: 8px;
}

.player-chip,
.host-player,
.tally-row,
.url-row,
.ban-row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 9, 12, 0.48);
  padding: 10px 12px;
}

.player-chip strong,
.host-player strong,
.tally-row strong,
.ban-row strong {
  font-size: 15px;
}

.player-chip small,
.host-player small,
.tally-row small,
.url-row small,
.ban-row small {
  color: var(--muted);
  font-size: 12px;
}

.player-chip.eliminated,
.host-player.eliminated {
  opacity: 0.58;
}

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

.tag.liar {
  border-color: rgba(255, 122, 112, 0.42);
  color: #ffd4d1;
  background: rgba(255, 122, 112, 0.11);
}

.tag.safe {
  border-color: rgba(188, 231, 93, 0.32);
  color: #e0ff98;
  background: rgba(188, 231, 93, 0.08);
}

.tag.offline {
  color: var(--muted);
}

.result-zone {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 9, 12, 0.46);
  padding: 18px;
}

.result-zone h3,
.result-zone p {
  margin: 0;
}

.result-zone h3 {
  font-size: 22px;
  line-height: 1.3;
}

.result-zone p {
  margin-top: 8px;
  color: var(--muted-strong);
  line-height: 1.55;
  word-break: keep-all;
}

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

.host-panel {
  padding: 24px;
}

.host-actions,
.danger-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.danger-row {
  margin-top: 10px;
}

.full-width {
  grid-column: 1 / -1;
}

.url-row {
  align-items: stretch;
}

.url-row code {
  display: block;
  margin-top: 3px;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-btn,
.remove-btn {
  min-height: 34px;
  padding: 0 11px;
  background: rgba(55, 211, 220, 0.1);
  border-color: rgba(55, 211, 220, 0.26);
  color: var(--cyan);
  white-space: nowrap;
}

.remove-btn {
  background: rgba(255, 122, 112, 0.09);
  border-color: rgba(255, 122, 112, 0.25);
  color: #ffd4d1;
}

.danger-btn.mini {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

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

.tally-row {
  position: relative;
  overflow: hidden;
}

.tally-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: rgba(55, 211, 220, 0.11);
  transition: width 0.22s ease;
}

.tally-row > *:not(.tally-fill) {
  position: relative;
  z-index: 1;
}

.footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  min-height: var(--footer-h);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(7, 9, 12, 0.88);
  backdrop-filter: blur(16px);
}

body[data-page="host"] {
  padding-bottom: 30px;
}

body[data-page="host"] .footer {
  display: none;
}

.footer-main {
  width: min(980px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.footer-item {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 28, 34, 0.7);
  padding: 0 12px;
}

.footer-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.footer-meta,
.timer {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.timer {
  color: var(--green);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid rgba(255, 122, 112, 0.34);
  border-radius: var(--radius);
  background: rgba(26, 14, 13, 0.94);
  color: #ffd4d1;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  word-break: keep-all;
}

body[data-page="player"] .toast {
  bottom: calc(var(--footer-h) + 18px);
}

@media (max-width: 820px) {
  :root {
    --footer-h: 112px;
  }

  body {
    padding: 18px 12px calc(var(--footer-h) + 18px + env(safe-area-inset-bottom));
  }

  .site-header,
  .question-header.compact {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-title {
    font-size: 28px;
  }

  .question-text {
    font-size: 21px;
  }

  .container:not(.game-container),
  .game-container,
  .host-panel {
    padding: 18px;
  }

  .secret-stage {
    min-height: 190px;
    margin: 18px 0;
    padding: 20px;
  }

  .secret-word {
    font-size: 36px;
  }

  .liar-title {
    font-size: 24px;
  }

  .liar-copy {
    font-size: 16px;
  }

  .host-grid,
  .setup-form {
    grid-template-columns: 1fr;
  }

  .host-actions,
  .danger-row {
    grid-template-columns: 1fr;
  }

  .footer-main {
    display: grid;
    grid-template-columns: 1fr;
  }

  .footer-item {
    justify-content: space-between;
  }

  .url-row,
  .player-chip,
  .host-player,
  .tally-row,
  .ban-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .copy-btn,
  .remove-btn,
  .danger-btn.mini {
    width: 100%;
  }

  .player-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
}
