:root {
  color-scheme: dark;
  --bg: #101725;
  --panel: #172235;
  --panel-2: #1d2b42;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f7fb;
  --muted: #b8c5d7;
  --accent: #f27b23;
  --accent-2: #2dd4bf;
  --danger: #ef4444;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 10%, rgba(242, 123, 35, 0.22), transparent 28%),
    radial-gradient(circle at 84% 16%, rgba(45, 212, 191, 0.16), transparent 30%),
    linear-gradient(135deg, #0c1220 0%, #121c2d 52%, #0f1726 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h1 {
  margin: 10px 0 22px;
  font-size: clamp(1.9rem, 9vw, 3.1rem);
  line-height: 1;
}

.login-card .brand-mark {
  margin-bottom: 18px;
}

.login-card .primary {
  width: 100%;
  margin-top: 16px;
}

.login-switch {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: 14px;
  color: #9ff3e8;
  font-weight: 800;
  text-decoration: none;
}

.login-switch:hover,
.login-switch:focus-visible {
  color: #ffffff;
}

.login-error {
  border: 1px solid rgba(239, 68, 68, 0.36);
  border-radius: 8px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  padding: 10px 12px;
}

.workspace {
  min-height: calc(100vh - 56px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 23, 37, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar,
.control-panel,
.table-layout {
  padding: 18px 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ffb15f);
  color: #1b1208;
  font-weight: 900;
  letter-spacing: 0;
}

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

.brand strong {
  font-size: 1.1rem;
}

.brand small,
.eyebrow,
.status,
label {
  color: var(--muted);
}

.brand small,
.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.room-actions,
.round-buttons,
.join-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.primary,
.secondary,
.join-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.icon-button {
  width: 42px;
  padding: 0;
}

.icon-button:hover,
.secondary:hover {
  border-color: rgba(242, 123, 35, 0.55);
  background: rgba(242, 123, 35, 0.12);
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.logout-link:hover,
.logout-link:focus-visible {
  border-color: rgba(242, 123, 35, 0.55);
  color: #fff;
  background: rgba(242, 123, 35, 0.12);
}

.room-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 22px;
  padding: 34px 22px 28px;
}

.room-hero h1 {
  max-width: 740px;
  margin: 6px 0 0;
  font-size: clamp(2.1rem, 5vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.join-card,
.control-panel,
.voting-area,
.results-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035));
}

.join-card {
  align-self: end;
  padding: 18px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: rgba(7, 12, 22, 0.68);
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: rgba(45, 212, 191, 0.72);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.join-row button,
.primary {
  border-color: color-mix(in srgb, var(--accent) 70%, white 20%);
  background: var(--accent);
  color: #1b1208;
  font-weight: 900;
  padding: 0 18px;
}

.secondary {
  padding: 0 16px;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px auto;
  align-items: end;
  gap: 16px;
  margin: 0 22px;
  padding: 16px;
}

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

.voting-area,
.results-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2,
.section-head p {
  margin: 0;
}

.section-head h2 {
  margin-top: 4px;
  font-size: 1.45rem;
}

.status {
  text-align: right;
}

.deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 12px;
}

.card-option {
  position: relative;
  min-height: 132px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    var(--panel-2);
  font-size: 2rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.card-option::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

.card-option:hover,
.card-option.is-selected {
  border-color: rgba(242, 123, 35, 0.86);
  background:
    linear-gradient(135deg, rgba(242, 123, 35, 0.36), rgba(45, 212, 191, 0.12)),
    var(--panel-2);
  transform: translateY(-1px);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 999px;
  color: #9ff3e8;
  background: rgba(45, 212, 191, 0.1);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
  padding: 12px;
}

.summary-grid span,
.summary-grid strong {
  display: block;
}

.summary-grid span {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-grid strong {
  margin-top: 4px;
  font-size: 1.5rem;
}

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

.participant {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(242, 123, 35, 0.16);
  color: #ffb15f;
  font-weight: 900;
}

.participant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.participant-card {
  min-width: 46px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 7px 8px;
  text-align: center;
  font-weight: 900;
}

.participant-card.is-hidden {
  color: var(--accent-2);
}

.distribution {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.bar {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100% - 36px));
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(15, 23, 38, 0.96);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 18px, 760px);
    padding: 9px 0;
  }

  .workspace {
    min-height: calc(100vh - 18px);
  }

  .room-hero,
  .control-panel,
  .table-layout {
    grid-template-columns: 1fr;
  }

  .room-hero {
    padding-top: 26px;
  }

  .room-hero h1 {
    font-size: clamp(2rem, 13vw, 3.5rem);
  }

  .control-panel {
    margin: 0 14px;
  }

  .topbar,
  .room-hero,
  .table-layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .round-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .deck {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card-option {
    min-height: 104px;
    font-size: 1.55rem;
  }
}

@media (max-width: 460px) {
  .brand small {
    display: none;
  }

  .join-row {
    display: grid;
  }

  .deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
