:root {
  --blue-950: #04091f;
  --blue-900: #07164a;
  --blue-800: #102a73;
  --gold: #f4c542;
  --gold-dark: #966d14;
  --cyan: #58d8ff;
  --magenta: #df6cff;
  --green: #44d28f;
  --red: #ff6565;
  --text: #f7fbff;
  --muted: #b9c8e6;
  --panel: rgba(8, 23, 73, 0.9);
  --line: rgba(244, 197, 66, 0.42);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, rgba(88, 216, 255, 0.24), transparent 24rem),
    radial-gradient(circle at 85% 20%, rgba(244, 197, 66, 0.18), transparent 22rem),
    linear-gradient(145deg, #030616 0%, #081543 48%, #030616 100%);
}

button,
input,
select {
  font: inherit;
}

button,
.ghost-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  color: #08133d;
  background: linear-gradient(180deg, #ffe891, var(--gold));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 0 24px rgba(244, 197, 66, 0.2);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.danger {
  color: #fff;
  background: linear-gradient(180deg, #ff8787, #c93333);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.24);
}

select option {
  color: #07164a;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(88, 216, 255, 0.4), 0 2px 0 #000;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.15rem;
  letter-spacing: 0;
}

h3 {
  margin: 18px 0 10px;
  font-size: 1rem;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.show-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(12, 34, 108, 0.92), rgba(3, 9, 31, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 60px rgba(0, 0, 0, 0.35);
}

.show-panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(88, 216, 255, 0.18);
  border-radius: 5px;
  pointer-events: none;
}

.admin-shell,
.player-shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.player-page .login-panel h1 {
  overflow-wrap: anywhere;
  hyphens: auto;
}

.player-page .player-top h1 {
  overflow-wrap: anywhere;
}

.host-panel,
.player-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.host-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-grid,
.management-grid {
  display: grid;
  gap: 18px;
}

.admin-grid {
  grid-template-columns: 260px minmax(360px, 1fr) 310px;
}

.management-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  margin-top: 18px;
}

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

.qr-panel img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.small {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  border: 1px solid rgba(244, 197, 66, 0.45);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.24);
  font-size: 0.86rem;
  font-weight: 800;
}

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

.answer-card,
.answer-button {
  min-height: 68px;
  border: 1px solid rgba(244, 197, 66, 0.62);
  border-radius: 7px;
  padding: 13px 16px;
  color: var(--text);
  background: linear-gradient(90deg, rgba(4, 9, 31, 0.92), rgba(20, 47, 137, 0.9), rgba(4, 9, 31, 0.92));
  box-shadow: inset 0 0 18px rgba(88, 216, 255, 0.09);
  text-align: left;
  font-weight: 800;
}

.answer-card strong,
.answer-button strong {
  color: var(--gold);
  margin-right: 10px;
}

.answer-button {
  cursor: pointer;
}

.answer-button.selected {
  border-color: var(--gold);
  background: linear-gradient(90deg, #3a2302, #b77f14, #3a2302);
}

.answer-button.correct,
.answer-card.correct {
  border-color: var(--green);
  background: linear-gradient(90deg, #062616, #158a52, #062616);
}

.answer-button.wrong,
.answer-card.wrong {
  border-color: var(--red);
  background: linear-gradient(90deg, #2c0909, #a52c2c, #2c0909);
}

.answer-button.hidden-choice {
  opacity: 0.22;
  pointer-events: none;
}

.explanation {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.money-ladder {
  display: grid;
  gap: 5px;
}

.money-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 3px 7px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
}

.money-row.active {
  color: #08133d;
  border-color: var(--gold);
  background: linear-gradient(180deg, #ffe891, var(--gold));
  font-weight: 900;
}

.money-row.milestone {
  color: var(--text);
  border-color: rgba(88, 216, 255, 0.45);
}

.occupants {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.players-list,
.item-list {
  display: grid;
  gap: 8px;
}

.player-row,
.item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.player-row {
  grid-template-columns: 1fr auto auto auto;
}

.player-row strong,
.item-row strong {
  display: block;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.mini-actions {
  display: flex;
  gap: 8px;
}

.mini-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.editor-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

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

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compact .item-row {
  grid-template-columns: 1fr;
}

.login-panel {
  width: min(760px, 100%);
  margin: 10vh auto 0;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  margin: 28px auto 0;
  text-align: left;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
}

.player-top {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.score-box {
  display: grid;
  gap: 4px;
  min-width: 180px;
  text-align: right;
}

.score-box span {
  color: var(--muted);
}

.score-box strong {
  color: var(--gold);
  font-size: 1.5rem;
}

.question-stage {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-stage h2,
.current-panel h2 {
  font-size: clamp(1.4rem, 2.4vw, 2.5rem);
  line-height: 1.15;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.joker-buttons {
  display: grid;
  gap: 10px;
}

.joker-buttons button {
  width: 100%;
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  transform: translateX(-50%) translateY(20px);
  max-width: min(560px, calc(100% - 32px));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(2, 8, 28, 0.95);
  opacity: 0;
  transition: 0.2s ease;
  pointer-events: none;
}

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

@media (max-width: 1080px) {
  .admin-grid,
  .management-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .players-panel {
    grid-column: auto;
  }

  .host-panel,
  .player-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .score-box {
    text-align: left;
  }
}

@media (max-width: 650px) {
  .admin-shell,
  .player-shell {
    width: min(100% - 18px, 1500px);
    padding-top: 9px;
  }

  .answer-grid,
  .four-inputs {
    grid-template-columns: 1fr;
  }

  .player-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
  }
}

@media (max-width: 760px) {
  .player-page {
    min-height: 100svh;
    background:
      radial-gradient(circle at 20% 8%, rgba(88, 216, 255, 0.18), transparent 14rem),
      linear-gradient(160deg, #030616 0%, #07164a 56%, #030616 100%);
  }

  .player-page .player-shell {
    width: min(100% - 14px, 480px);
    padding: 7px 0 calc(18px + env(safe-area-inset-bottom));
  }

  .player-page .show-panel {
    border-radius: 7px;
    padding: 13px;
  }

  .player-page .show-panel::before {
    inset: 4px;
  }

  .player-page .login-panel {
    width: 100%;
    margin: 7vh auto 0;
    padding: 18px 14px;
  }

  .player-page .login-panel h1 {
    font-size: clamp(1.72rem, 8.4vw, 2.55rem);
    line-height: 1.02;
  }

  .player-page .login-form {
    margin-top: 22px;
  }

  .player-page .login-form input,
  .player-page .login-form button {
    min-height: 50px;
    font-size: 1rem;
  }

  .player-page .game-layout {
    gap: 10px;
  }

  .player-page .player-top {
    position: sticky;
    top: 6px;
    z-index: 8;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    padding: 10px 12px;
  }

  .player-page .player-top .eyebrow {
    margin-bottom: 2px;
    font-size: 0.72rem;
  }

  .player-page .player-top h1 {
    font-size: clamp(1.05rem, 5vw, 1.45rem);
    line-height: 1.05;
    text-transform: none;
  }

  .player-page .score-box {
    min-width: 108px;
    gap: 1px;
    text-align: right;
  }

  .player-page .score-box span {
    font-size: 0.72rem;
  }

  .player-page .score-box strong {
    font-size: 1rem;
    white-space: nowrap;
  }

  .player-page .question-stage {
    min-height: auto;
    justify-content: start;
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .player-page .question-stage h2 {
    margin-bottom: 14px;
    font-size: clamp(1.18rem, 6.3vw, 1.65rem);
    line-height: 1.12;
  }

  .player-page .status-row {
    gap: 6px;
    margin-bottom: 10px;
  }

  .player-page .pill {
    padding: 5px 9px;
    font-size: 0.78rem;
  }

  .player-page .answer-grid {
    gap: 9px;
  }

  .player-page .answer-button {
    min-height: 58px;
    padding: 11px 12px;
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .player-page .answer-button strong {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-right: 8px;
    border-radius: 999px;
    color: #08133d;
    background: var(--gold);
    font-size: 0.82rem;
  }

  .player-page .explanation {
    margin-top: 11px;
    font-size: 0.92rem;
  }

  .player-page .side-stack {
    gap: 10px;
  }

  .player-page .side-stack h2 {
    margin-bottom: 10px;
    font-size: 1rem;
  }

  .player-page .joker-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .player-page .joker-buttons button {
    min-height: 46px;
  }

  .player-page .money-ladder {
    max-height: 235px;
    overflow: auto;
    padding-right: 2px;
  }

  .player-page .money-row {
    grid-template-columns: 28px 1fr;
    min-height: 25px;
    padding: 3px 6px;
    font-size: 0.84rem;
  }

  .player-page .money-row span:last-child {
    display: none;
  }

  .player-page .toast {
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    padding: 11px 12px;
  }
}

@media (max-width: 380px) {
  .player-page .login-panel h1 {
    font-size: 1.55rem;
  }

  .player-page .question-stage h2 {
    font-size: 1.12rem;
  }

  .player-page .answer-button {
    font-size: 0.9rem;
  }
}
