:root {
  --bg-deep: #09111f;
  --bg-panel: #111d32;
  --bg-panel-alt: #152844;
  --accent: #f7c948;
  --accent-strong: #efb70a;
  --primary: #1e7af2;
  --primary-strong: #0d5ad2;
  --danger: #ff5d73;
  --success: #32d39a;
  --text: #edf5ff;
  --muted: #a8bbd7;
  --shadow: rgba(7, 11, 19, 0.4);
  --screen-glow: rgba(84, 128, 255, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(90, 145, 255, 0.45), transparent 35%),
    linear-gradient(135deg, #1f1d65 0%, #2b1a6a 18%, #1d2a52 52%, #101923 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.start-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.56), rgba(11, 18, 31, 0.8));
  backdrop-filter: blur(14px);
  z-index: 30;
  padding: 24px;
}

.start-card {
  width: min(760px, 100%);
  background: linear-gradient(180deg, rgba(18, 29, 46, 0.94), rgba(11, 20, 31, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(130, 160, 255, 0.16);
  padding: 28px 32px 34px;
  position: relative;
  overflow: hidden;
}

.start-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, #f7c948, #5ec9ff, #30c2b0, #f7c948);
  opacity: 0.8;
}

.start-card h2 {
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 2.8vw, 3rem);
  letter-spacing: -0.03em;
}

.start-card label {
  display: block;
  margin: 18px 0 10px;
  color: var(--muted);
  font-weight: 700;
}

.start-card select,
.start-card input {
  width: 100%;
  min-height: 58px;
  border-radius: 14px;
  border: 1px solid rgba(174, 196, 244, 0.18);
  background: rgba(7, 14, 22, 0.82);
  color: var(--text);
  padding: 12px 16px;
  font-size: 1.05rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

.player-name-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.player-name-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wide-button {
  width: 100%;
  margin-top: 22px;
}

.start-card-actions {
  display: grid;
  gap: 12px;
  margin-top: 30px;
}

.start-card-actions .ghost-button,
.start-card-actions .primary-button {
  min-height: 72px;
  font-size: clamp(1.2rem, 2vw, 1.9rem);
  border-radius: 18px;
}

.compact-button {
  margin-top: 0;
}

.admin-panel {
  position: absolute;
  inset: auto 24px 24px 24px;
  background: rgba(11, 18, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.42);
  padding: 18px 18px 16px;
  z-index: 40;
}

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

.admin-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.admin-panel p {
  color: var(--muted);
  margin: 14px 0;
}

#answer-bank-editor {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: rgba(4, 10, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 0.82rem;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
  margin: 0;
}

.app-shell {
  width: min(1700px, 100%);
  background: linear-gradient(180deg, rgba(10, 17, 28, 0.93), rgba(10, 20, 30, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(137, 177, 255, 0.12);
  overflow: hidden;
  position: relative;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(73, 147, 255, 0.18), transparent 28%);
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px;
  background: linear-gradient(180deg, rgba(21, 38, 62, 0.98), rgba(11, 20, 31, 0.96));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 1;
}

.topbar-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    column-gap: 1rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 2.2vw, 3rem);
  letter-spacing: -0.04em;
}

.status-pill {
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(247, 201, 73, 0.18);
  color: var(--accent);
  border: 1px solid rgba(247, 201, 73, 0.5);
  font-weight: 800;
  box-shadow: 0 0 18px rgba(247, 201, 73, 0.18);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  min-height: 850px;
  position: relative;
  z-index: 1;
}

.sidebar {
  padding: 24px;
  background: rgba(15, 25, 41, 0.9);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.panel {
  background: linear-gradient(180deg, rgba(28, 46, 70, 0.96), rgba(19, 30, 46, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 18px 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.players-panel {
  margin-bottom: 22px;
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.2rem;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-item.active {
  background: linear-gradient(135deg, rgba(30, 122, 242, 0.3), rgba(16, 194, 173, 0.16));
  border-color: rgba(116, 172, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(68, 163, 255, 0.28), 0 0 20px rgba(30, 122, 242, 0.22);
}

.player-item .name {
  font-weight: 800;
  font-size: 1.05rem;
}

.player-item .score {
  font-size: 1.2rem;
  color: var(--accent);
  font-weight: 900;
}

.player-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls-panel label {
  font-weight: 700;
  color: var(--muted);
  margin-top: 8px;
}

.controls-panel input {
  width: 100%;
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 14, 22, 0.7);
  color: var(--text);
  padding: 12px 14px;
  font-size: 1.15rem;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.2);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

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

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  min-height: 52px;
  font-weight: 800;
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 12px 18px rgba(13, 34, 67, 0.22);
}

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

.primary-button {
  background: linear-gradient(180deg, #3a97ff, #136bd7);
  color: white;
}

.secondary-button {
  background: linear-gradient(180deg, #ffb954, #e59013);
  color: #1c1200;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.play-area {
  display: flex;
  flex-direction: column;
  padding: 26px 28px 30px;
  background: linear-gradient(180deg, rgba(8, 14, 22, 0.72), rgba(7, 12, 20, 0.85));
}

.theme-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 22px;
}

.label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

#theme-name {
  font-size: clamp(1rem, 1.3vw, 1.5rem);
}

.wheel-and-board {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  align-items: center;
}

.wheel-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  margin: 0 auto;
}

#wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  filter: drop-shadow(0 22px 26px rgba(0, 0, 0, 0.36));
  background: radial-gradient(circle at center, rgba(255,255,255,0.12), rgba(0,0,0,0.12));
}

.wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 35%, #fff2b5, var(--accent));
  color: #270d00;
  font-weight: 900;
  letter-spacing: 0.08em;
  border: 6px solid rgba(8, 14, 22, 0.75);
  box-shadow: 0 0 0 12px rgba(255, 255, 255, 0.05);
}

.board-wrap {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(12, 18, 29, 0.9), rgba(8, 14, 22, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 260px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

#board-canvas {
  width: 100%;
  height: 260px;
  display: block;
}

.game-actions {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}

.spin-button {
  width: min(320px, 100%);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #201400;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  animation: pulse 1.8s ease-in-out infinite;
}

.status-bar {
  margin-top: 22px;
  min-height: 68px;
  padding: 18px 20px;
  border-radius: 14px;
  background: rgba(19, 35, 53, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.06rem;
  line-height: 1.4;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.winner-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 16, 0.7);
  backdrop-filter: blur(12px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.winner-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.winner-card {
  width: min(720px, 88vw);
  background: linear-gradient(180deg, rgba(244, 246, 255, 0.98), rgba(225, 233, 243, 0.96));
  color: #0b1830;
  border-radius: 30px;
  padding: 28px 32px 30px;
  box-shadow: 0 35px 90px rgba(7, 16, 29, 0.45);
  transform: translateY(28px) scale(0.96);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.winner-overlay.is-visible .winner-card {
  transform: translateY(0) scale(1);
}

.winner-card::before,
.winner-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  filter: blur(16px);
}

.winner-card::before {
  left: -40px;
  top: -40px;
}

.winner-card::after {
  right: -30px;
  bottom: -30px;
}

.winner-badge {
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff9d8 0%, #f7d763 30%, #f0b541 100%);
  box-shadow: 0 18px 40px rgba(242, 175, 69, 0.44);
  font-size: 4rem;
  animation: trophyFloat 2.1s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

.winner-header {
  font-size: clamp(1.3rem, 2.4vw, 2.4rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #111a2c;
  position: relative;
  z-index: 1;
}

.winner-name {
  margin-top: 18px;
  font-size: clamp(2.2rem, 4vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  position: relative;
  z-index: 1;
}

.winner-summary {
  margin-top: 10px;
  font-size: clamp(1.2rem, 2vw, 2rem);
  color: #2a3b57;
  position: relative;
  z-index: 1;
}

.winner-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 26px;
  position: relative;
  z-index: 1;
}

.winner-stat {
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(17, 26, 44, 0.08);
  border-radius: 18px;
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.winner-stat.success {
  border-color: rgba(50, 211, 154, 0.3);
}

.winner-stat.danger {
  border-color: rgba(255, 93, 115, 0.28);
}

.winner-stat-value {
  font-size: clamp(2.1rem, 3vw, 3rem);
  font-weight: 900;
  color: #101b2f;
}

.winner-stat-label {
  font-size: 0.9rem;
  color: rgba(16, 27, 47, 0.76);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.winner-button {
  margin-top: 32px;
  min-height: 64px;
  width: min(260px, 100%);
  background: linear-gradient(180deg, #2a7ef2, #155ad9);
  color: white;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(35, 120, 255, 0.28);
  position: relative;
  z-index: 1;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

@keyframes trophyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .wheel-and-board {
    grid-template-columns: 1fr;
  }

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

  .winner-stats {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1400px) {
  body {
    padding: 36px;
  }

  .play-area {
    padding: 32px 36px 40px;
  }

  .status-bar {
    min-height: 80px;
    font-size: 1.2rem;
  }

  .start-card {
    padding: 36px 40px 42px;
  }
}
