:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #657185;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(24, 33, 47, 0.12);
  --coral: #f05d5e;
  --teal: #22a6a1;
  --gold: #f2b84b;
  --violet: #6f62d7;
  --green: #4aaf73;
  --shadow: 0 24px 80px rgba(36, 45, 65, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(34, 166, 161, 0.22), transparent 34%),
    linear-gradient(315deg, rgba(240, 93, 94, 0.18), transparent 35%),
    #f6f2e8;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.setup-panel {
  width: min(560px, 100%);
  padding: 28px;
  border-radius: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: 27px;
  border-radius: 8px;
  background: conic-gradient(from 20deg, var(--coral), var(--gold), var(--teal), var(--violet), var(--coral));
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.42);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 7vw, 56px);
  line-height: 0.98;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.choice {
  min-height: 96px;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.choice.is-active {
  border-color: rgba(34, 166, 161, 0.75);
  box-shadow: 0 0 0 4px rgba(34, 166, 161, 0.12);
}

.choice-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  font-size: 20px;
  font-weight: 800;
}

.choice strong,
.choice small {
  display: block;
}

.choice small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: 0;
}

input {
  height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 12px 14px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: rgba(34, 166, 161, 0.8);
  box-shadow: 0 0 0 4px rgba(34, 166, 161, 0.12);
}

.primary,
.secondary,
.spin-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.primary {
  width: 100%;
  min-height: 48px;
  color: white;
  background: var(--ink);
}

.secondary {
  min-height: 44px;
  color: var(--ink);
  background: #efe7d7;
}

.status {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--coral);
  font-weight: 700;
}

.game {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 28px;
  align-items: stretch;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-radius: 8px;
}

.room-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

code {
  min-height: 42px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  padding: 10px;
  border-radius: 8px;
  background: #fffaf0;
  color: #283245;
  font-size: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  color: white;
  background: var(--teal);
  font-size: 18px;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  display: block;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
}

.badge {
  color: white;
  background: var(--violet);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
}

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

.admin-shell {
  min-height: 100vh;
}

.admin-panel {
  align-self: center;
}

.admin-dashboard {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 24px;
  align-items: start;
}

.admin-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-title-row h2 {
  margin-bottom: 0;
  font-size: 28px;
}

.admin-rooms {
  min-height: 620px;
}

.room-list {
  display: grid;
  gap: 8px;
}

.room-list-item {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.room-list-item strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.room-list-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.room-list-item.is-active {
  border-color: rgba(34, 166, 161, 0.75);
  box-shadow: 0 0 0 4px rgba(34, 166, 161, 0.12);
}

.admin-detail {
  min-width: 0;
  display: grid;
  gap: 20px;
  padding: 22px;
  border-radius: 8px;
}

.admin-state {
  padding: 14px;
  border-radius: 8px;
  background: rgba(34, 166, 161, 0.12);
  border: 1px solid rgba(34, 166, 161, 0.34);
  color: #17635f;
  font-weight: 800;
}

.admin-state[data-state="armed"],
.admin-state[data-state="spinning"] {
  background: rgba(242, 184, 75, 0.2);
  border-color: rgba(242, 184, 75, 0.5);
  color: #725410;
}

.spin-state {
  background: rgba(24, 33, 47, 0.07);
  border-color: rgba(24, 33, 47, 0.14);
  color: var(--muted);
}

.spin-state[data-state="spinning"] {
  background: rgba(242, 184, 75, 0.2);
  border-color: rgba(242, 184, 75, 0.5);
  color: #725410;
}

.admin-state[data-state="cleared"] {
  background: rgba(74, 175, 115, 0.16);
  border-color: rgba(74, 175, 115, 0.4);
  color: #276540;
}

.admin-target {
  display: grid;
  gap: 14px;
}

.admin-room h2 {
  margin-bottom: 0;
  font-size: 26px;
}

.target-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.target-choice {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  text-align: left;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.target-choice span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.target-choice.is-active {
  border-color: rgba(240, 93, 94, 0.72);
  box-shadow: 0 0 0 4px rgba(240, 93, 94, 0.12);
}

.landing-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.landing-row strong {
  color: var(--ink);
}

.notice {
  padding: 14px;
  border-radius: 8px;
  color: #725410;
  background: rgba(242, 184, 75, 0.22);
  border: 1px solid rgba(242, 184, 75, 0.45);
}

.chat-panel {
  display: grid;
  gap: 10px;
}

.chat-log {
  min-height: 170px;
  max-height: 250px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.74);
}

.admin-chat-log {
  max-height: 300px;
}

.chat-message {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 8px;
  background: white;
  border: 1px solid rgba(24, 33, 47, 0.08);
}

.chat-message div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chat-message strong {
  color: var(--ink);
}

.chat-message p {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.history-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 10px;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 210px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.74);
}

.admin-history-panel {
  width: 100%;
}

.admin-history-list {
  max-height: 260px;
}

.history-item {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 8px;
  background: white;
  border: 1px solid rgba(24, 33, 47, 0.08);
}

.history-item div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.history-item strong {
  color: var(--ink);
}

.history-item p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.wheel-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto auto;
  justify-items: center;
  align-items: center;
  gap: 18px;
  padding: 8px 0;
}

.wheel-wrap {
  position: relative;
  width: min(72vh, 680px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 28px 40px rgba(42, 48, 60, 0.24));
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(0deg);
  transition: transform 5.2s cubic-bezier(0.12, 0.82, 0.18, 1);
}

.pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  z-index: 3;
  width: 34px;
  height: 52px;
  transform: translateX(-50%);
  background: var(--ink);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 8px 8px rgba(24, 33, 47, 0.18));
}

.hub {
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  color: white;
  background: var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.16);
}

.hub span {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 900;
  font-size: clamp(14px, 2vw, 22px);
}

.result {
  min-height: 94px;
  text-align: center;
}

.result p {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 750;
}

.result h2 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.05;
}

.spin-button {
  width: min(300px, 100%);
  min-height: 58px;
  color: white;
  background: linear-gradient(90deg, var(--coral), var(--gold));
  box-shadow: 0 16px 32px rgba(240, 93, 94, 0.22);
  font-size: 20px;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 620px);
    padding: 10px 0 24px;
    place-items: start center;
  }

  .game {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .admin-dashboard {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: 2;
  }

  .wheel-stage {
    order: 1;
    grid-template-rows: auto auto auto;
  }

  .wheel-wrap {
    width: min(94vw, 540px);
  }
}

@media (max-width: 560px) {
  .setup-panel,
  .side-panel {
    padding: 18px;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

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