:root {
  color-scheme: light;
  --ink: #171614;
  --muted: #6d665f;
  --paper: #f8f5ef;
  --panel: #fffdf8;
  --line: #ded6c9;
  --charcoal: #252a2b;
  --green: #547d5f;
  --red: #9f4d45;
  --gold: #d7a84b;
  --blue: #557996;
  --shadow: 0 18px 45px rgba(38, 32, 25, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fbf8f1 0%, #f0e8dc 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.setup-panel,
.invite-panel,
.waiting-panel,
.draft-panel,
.complete-panel {
  min-height: calc(100vh - 56px);
}

.setup-panel,
.invite-panel,
.waiting-panel {
  display: grid;
  align-content: center;
  gap: 28px;
}

.invite-panel,
.waiting-panel {
  justify-items: center;
}

.setup-top,
.draft-header,
.panel-heading,
.stage-top,
.header-actions {
  display: flex;
  align-items: center;
}

.setup-top {
  position: relative;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.setup-top .icon-button {
  position: absolute;
  top: 0;
  right: 0;
}

.home-title {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.brand-mark {
  width: 68px;
  height: 68px;
}

.home-title h1 {
  font-size: clamp(4.4rem, 13vw, 8.8rem);
}

.home-title p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  font-weight: 850;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.25rem, 6vw, 5.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.1;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.invite-card,
.waiting-card,
.quick-draft-card {
  width: min(620px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.waiting-card {
  position: relative;
  padding-top: 58px;
}

.waiting-home-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.invite-card h1,
.waiting-card h1 {
  font-size: clamp(2.4rem, 7vw, 4.9rem);
}

.quick-draft-panel {
  display: grid;
  justify-items: center;
  margin-bottom: 14px;
}

.quick-draft-grid {
  display: grid;
  gap: 14px;
}

.quick-actions,
.complete-actions,
.waiting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.quick-actions {
  justify-content: flex-end;
}

.complete-actions {
  justify-content: center;
}

.waiting-actions {
  justify-content: center;
}

.invite-card strong {
  color: var(--blue);
  font-size: 1.35rem;
  line-height: 1.1;
}

.invite-form {
  display: grid;
  gap: 12px;
}

.waiting-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 820;
}

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

.waiting-player {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f2e9;
}

.waiting-player span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.waiting-player strong {
  align-self: end;
  font-size: 1.1rem;
}

.waiting-player.is-seated {
  border-color: rgba(84, 125, 95, 0.34);
  background: #f0f7ee;
}

.waiting-start-button {
  min-width: min(280px, 100%);
}

.settings-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f2e9;
}

.custom-category-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.55fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f2e9;
}

.custom-category-field textarea {
  min-height: 150px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

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

input {
  min-height: 48px;
  padding: 0 13px;
}

select {
  min-height: 48px;
  padding: 0 36px 0 13px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 21px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 21px / 6px 6px no-repeat,
    #fff;
}

textarea {
  resize: vertical;
  min-height: 210px;
  padding: 13px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(84, 125, 95, 0.18);
}

.wide {
  grid-column: 1 / -1;
}

.room-actions {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 0.45fr);
  gap: 10px;
  align-items: end;
}

.room-code-label {
  min-width: 0;
}

.setup-status {
  min-height: 20px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.room-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 10px 28px rgba(38, 32, 25, 0.08);
}

.room-panel strong {
  display: block;
  font-size: 1.3rem;
  line-height: 1.1;
}

.room-panel span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.share-link-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

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

.primary-button {
  min-height: 50px;
  padding: 0 18px;
  color: #fffdf8;
  background: var(--charcoal);
}

.primary-button:hover {
  background: #111414;
}

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

.ghost-button {
  min-height: 38px;
  padding: 0 13px;
  color: var(--charcoal);
  background: #ede6db;
}

.ghost-button:hover,
.ghost-button.is-selected {
  color: #fffdf8;
  background: var(--green);
}

.draft-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.draft-header {
  justify-content: space-between;
  gap: 16px;
  padding-top: 6px;
}

.draft-header h1 {
  font-size: clamp(2rem, 5vw, 4.25rem);
}

.header-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.seat-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(39, 94, 133, 0.2);
  border-radius: 8px;
  color: var(--blue);
  background: #eaf3f8;
  font-size: 0.86rem;
  font-weight: 900;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--charcoal);
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: 0 10px 20px rgba(38, 32, 25, 0.08);
}

.icon-button span {
  font-size: 1.35rem;
  line-height: 1;
}

.home-action {
  flex: 0 0 44px;
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  align-items: start;
}

.auction-stage,
.snake-stage,
.player-card,
.complete-panel {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-card {
  padding: 14px;
}

.player-card {
  display: grid;
  gap: 14px;
}

.player-card.is-cpu {
  border-color: rgba(85, 121, 150, 0.35);
  background: #f4f8fa;
}

.player-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.player-name {
  font-size: 1.08rem;
  font-weight: 900;
}

.money {
  color: var(--green);
  font-weight: 950;
}

.cpu-control-note {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(85, 121, 150, 0.4);
  border-radius: 8px;
  color: var(--blue);
  background: #eaf3f8;
  font-size: 0.86rem;
  font-weight: 900;
}

.meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee7dc;
}

.meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.player-controls {
  display: grid;
  grid-template-columns: minmax(72px, 0.8fr) minmax(112px, 1.25fr) minmax(82px, 0.9fr);
  gap: 8px;
}

.bid-button,
.give-up-button {
  min-height: 46px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: #fffdf8;
  font-weight: 900;
  line-height: 1.05;
  white-space: normal;
}

.bid-button {
  background: var(--green);
}

.give-up-button {
  background: var(--red);
}

.bid-button:disabled,
.give-up-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #eee7dc;
}

.custom-bid-control {
  display: grid;
  grid-template-columns: 28px minmax(44px, 1fr) 28px;
  gap: 4px;
  padding: 5px;
  border-radius: 8px;
  background: var(--blue);
}

.custom-bid-control input,
.custom-step,
.custom-submit {
  border: 0;
  border-radius: 6px;
  font-weight: 900;
}

.custom-bid-control input {
  min-height: 32px;
  padding: 0 4px;
  text-align: center;
  color: var(--charcoal);
  background: #fffdf8;
}

.custom-step,
.custom-submit {
  color: #fffdf8;
  background: rgba(255, 255, 255, 0.16);
}

.custom-submit {
  grid-column: 1 / -1;
  min-height: 31px;
}

.custom-bid-control.is-disabled {
  background: #eee7dc;
}

.custom-bid-control.is-disabled input,
.custom-bid-control.is-disabled button {
  cursor: not-allowed;
  color: var(--muted);
  background: #f6f1e8;
}

.roster-list,
.item-queue {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

.roster-list li,
.item-queue li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f7f2e9;
  color: var(--muted);
  font-size: 0.9rem;
}

.roster-list li {
  justify-content: flex-start;
}

.roster-list .empty-slot {
  color: var(--muted);
}

.roster-list strong,
.item-queue strong {
  color: var(--ink);
}

.auction-stage {
  min-height: 430px;
  padding: 20px;
  display: grid;
  align-content: center;
  gap: 20px;
  background: #fffdf8;
}

.snake-stage {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.snake-stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.snake-stage h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 3.2rem);
}

.snake-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.snake-pick {
  min-height: 96px;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--charcoal);
  background: #fff;
  text-align: left;
}

.snake-pick:hover:not(:disabled) {
  border-color: rgba(84, 125, 95, 0.42);
  background: #f0f7ee;
}

.snake-pick:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #eee7dc;
}

.snake-pick.is-picked {
  opacity: 0.75;
}

.snake-pick strong {
  font-size: 1rem;
  line-height: 1.15;
}

.snake-pick span,
.snake-pick small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.stage-top,
.panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.queue-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fffdf8;
  background: var(--red);
  font-size: 0.82rem;
  font-weight: 900;
}

.queue-pill.subtle {
  color: var(--charcoal);
  background: #ede6db;
}

.current-item {
  min-height: 260px;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
}

.current-item h2 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 5.25rem);
}

.bid-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  min-height: 40px;
  max-width: 100%;
  padding: 0 14px;
  border-radius: 8px;
  color: #fffdf8;
  background: var(--blue);
  font-weight: 950;
}

.history-panel {
  overflow: hidden;
}

.panel-heading {
  margin-bottom: 10px;
}

.panel-heading span {
  color: var(--muted);
  font-weight: 800;
}

.item-queue {
  counter-reset: item;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.item-queue li {
  flex: 0 0 min(240px, 72vw);
  align-items: center;
}

.item-queue li::before {
  counter-increment: item;
  content: counter(item);
  display: grid;
  place-items: center;
  flex: 0 0 25px;
  height: 25px;
  border-radius: 999px;
  color: #fffdf8;
  background: var(--charcoal);
  font-size: 0.78rem;
  font-weight: 900;
}

.item-queue .picked {
  opacity: 1;
}

.item-queue .empty-history {
  flex-basis: 100%;
  justify-content: center;
  color: var(--muted);
  font-weight: 850;
}

.item-queue .empty-history::before {
  display: none;
}

.complete-panel {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 22px;
}

.complete-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.complete-hero h1 {
  font-size: clamp(2.4rem, 8vw, 5rem);
}

.celebration {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 1;
}

.complete-copy {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}

.winner-line {
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fffdf8;
  background: var(--green);
  font-size: 1.05rem;
  font-weight: 950;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 0;
}

.result-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-card.is-winner {
  border-color: rgba(40, 124, 73, 0.42);
  background: #eff9f0;
  box-shadow: inset 0 0 0 2px rgba(40, 124, 73, 0.18);
}

.result-card.is-loser {
  border-color: rgba(193, 65, 52, 0.38);
  background: #fff0ee;
  box-shadow: inset 0 0 0 2px rgba(193, 65, 52, 0.16);
}

.result-card h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 850;
}

.result-card .roster-list li {
  align-items: flex-start;
  justify-content: space-between;
}

.result-pick-copy {
  display: grid;
  gap: 3px;
}

.result-pick-copy small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.is-hidden {
  display: none;
}

@media (max-width: 920px) {
  .setup-grid,
  .settings-panel,
  .custom-category-field,
  .waiting-players,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .room-actions,
  .room-panel,
  .share-link-wrap {
    grid-template-columns: 1fr;
  }

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

  .auction-stage {
    min-height: 380px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .setup-panel,
  .invite-panel,
  .waiting-panel,
  .draft-panel,
  .complete-panel {
    min-height: calc(100vh - 20px);
  }

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

  .setup-top .icon-button {
    top: 2px;
  }

  .home-title {
    padding-top: 36px;
  }

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

  .current-item h2 {
    max-width: 9ch;
    font-size: clamp(2rem, 13vw, 3.5rem);
  }

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