:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65717a;
  --line: #dfe5df;
  --accent: #0b7a75;
  --accent-strong: #075f5b;
  --warm: #f0b849;
  --danger: #b54747;
  --shadow: 0 14px 40px rgba(24, 35, 40, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 247, 242, 0.9)),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.view {
  min-height: calc(100vh - 80px);
}

.home-view,
.expired-view,
.join-view {
  display: grid;
  align-content: center;
  gap: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(36px, 8vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
  line-height: 1.15;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.ghost-button,
.primary-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.primary-button,
.primary-link {
  width: fit-content;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #fff7df;
  color: #6f4a00;
  border-color: #f2d179;
  font-weight: 700;
}

.ghost-button {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.vote-card:active {
  transform: translateY(1px);
}

.back-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

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

.join-form {
  width: min(620px, 100%);
  display: grid;
  gap: 10px;
}

.join-form label {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.15);
}

.room-layout {
  display: grid;
  gap: 22px;
}

.room-header {
  align-items: flex-start;
}

.room-header h1 {
  margin-top: 8px;
  font-size: clamp(30px, 5vw, 48px);
}

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

.status-pill {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.status-pill.connected {
  border-color: rgba(11, 122, 117, 0.35);
  color: var(--accent-strong);
}

.status-pill.disconnected {
  border-color: rgba(181, 71, 71, 0.35);
  color: var(--danger);
}

.table-panel,
.cards-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.table-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

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

.participants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.vote-summary {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: grid;
  gap: 16px;
}

.summary-headline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-average {
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
  color: var(--accent-strong);
}

.summary-label {
  color: var(--muted);
  font-weight: 700;
}

.summary-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-card {
  width: 96px;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  opacity: 0.42;
}

.summary-card.winner {
  border-color: rgba(11, 122, 117, 0.55);
  background: #e8f5f2;
  opacity: 1;
  box-shadow: 0 8px 24px rgba(11, 122, 117, 0.14);
}

.summary-card-value {
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  color: var(--ink);
}

.summary-card-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.summary-scale {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe5df;
}

.summary-scale-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.participant {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
  display: grid;
  gap: 8px;
}

.participant-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.participant-status {
  color: var(--muted);
  font-size: 14px;
}

.vote-value {
  font-size: 34px;
  line-height: 1;
  font-weight: 900;
  color: var(--accent-strong);
}

.voted-dot,
.empty-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.voted-dot {
  background: var(--accent);
}

.empty-dot {
  background: #cad4ce;
}

.cards-panel {
  display: grid;
  gap: 16px;
}

.vote-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 10px;
}

.vote-card {
  aspect-ratio: 3 / 4;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 26px;
  font-weight: 900;
}

.vote-card.selected {
  border-color: var(--accent);
  background: #e8f5f2;
  color: var(--accent-strong);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 24px, 1120px);
    padding: 20px 0;
  }

  .room-topline,
  .room-header,
  .table-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .host-controls {
    justify-content: flex-start;
  }

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

  .vote-cards {
    grid-template-columns: repeat(3, minmax(72px, 1fr));
  }
}
