:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #647083;
  --line: #d9e0ea;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --table: #1f7a59;
  --table-dark: #155d44;
  --accent: #f5b841;
  --red: #df405a;
  --yellow: #f3c642;
  --green: #3dae6b;
  --blue: #3478e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

aside {
  min-height: 100vh;
  padding: 16px;
  background: #111820;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #f06d49);
  color: #17120a;
  font-weight: 900;
  font-size: 22px;
}

small,
.hint,
p {
  color: var(--muted);
}

.brand small,
.session small,
.mini-player small {
  color: #bfccd8;
}

.session,
.side-box,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.session,
.side-box {
  margin-bottom: 12px;
  padding: 10px;
  border-color: #2b3544;
  background: #172131;
}

.session strong {
  display: block;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-weight: 750;
}

button.secondary {
  background: #edf1f5;
  color: var(--ink);
}

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

.password-wrap input {
  min-width: 0;
}

.password-toggle {
  min-height: 0;
  padding: 9px 10px;
  background: #edf1f5;
  color: var(--ink);
}

button:disabled {
  opacity: .45;
  cursor: default;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

main {
  min-width: 0;
  padding: 18px;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.pill {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 10px;
  background: #dbe2ea;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.pill.live {
  background: #dff8e9;
  color: #167146;
}

.panel {
  padding: 14px;
}

.auth {
  max-width: 430px;
  display: grid;
  gap: 12px;
}

.table {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  border-radius: 8px;
  padding: 14px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.12), transparent 42%),
    linear-gradient(135deg, var(--table), var(--table-dark));
}

.opponents {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.seat {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  padding: 10px;
  background: rgba(12, 34, 28, .52);
  color: white;
}

.seat.turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 184, 65, .18);
}

.seat span,
.seat small {
  display: block;
  color: #dbeee6;
  font-size: 13px;
}

.laid {
  min-height: 62px;
  display: flex;
  gap: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.laid .card {
  width: 38px;
  min-width: 38px;
  height: 56px;
  min-height: 56px;
  padding: 4px;
  font-size: 12px;
}

.stacks {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.stack {
  width: 118px;
  height: 154px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.34);
  border-radius: 8px;
  background: rgba(255,255,255,.16);
  color: white;
}

.stack span {
  font-size: 34px;
  font-weight: 900;
}

.stack .card {
  pointer-events: none;
}

.hand-panel {
  align-self: end;
  display: grid;
  gap: 10px;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255,255,255,.92);
}

.phase-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.phase-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.selected-count {
  justify-self: start;
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf1f5;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scroll-snap-type: x proximity;
}

.card {
  width: 74px;
  min-width: 74px;
  height: 106px;
  min-height: 106px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 3px solid rgba(255,255,255,.88);
  border-radius: 8px;
  padding: 7px;
  color: white;
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
  text-align: left;
  scroll-snap-align: start;
}

.card span {
  font-size: 18px;
  font-weight: 900;
}

.card strong {
  align-self: center;
  text-align: center;
  font-size: 22px;
}

.card i {
  min-height: 14px;
  font-style: normal;
  font-size: 11px;
  opacity: .9;
}

.card.red { background: linear-gradient(160deg, #ff6075, var(--red)); }
.card.yellow { background: linear-gradient(160deg, #ffdf62, var(--yellow)); color: #342706; }
.card.green { background: linear-gradient(160deg, #58d487, var(--green)); }
.card.blue { background: linear-gradient(160deg, #5b9aff, var(--blue)); }
.card.wild { background: linear-gradient(135deg, #e94b5f, #f3c642 34%, #3dae6b 66%, #3478e5); }
.card.skip { background: linear-gradient(160deg, #2c3442, #111820); }
.card.selected {
  transform: translateY(-9px);
  outline: 3px solid var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-actions button {
  flex: 1 1 130px;
}

.invite-strip {
  display: grid;
  gap: 8px;
}

.invite-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,.92);
}

.invite-note strong,
.invite-note span {
  min-width: 0;
}

.invite-note span {
  grid-column: 1;
  color: var(--muted);
  font-size: 14px;
}

.invite-note button {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.invite-panel {
  max-width: 760px;
  display: grid;
  gap: 14px;
}

.invite-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.invite-head p {
  margin-top: 4px;
}

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

.invite-choice {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  color: var(--ink);
}

.invite-choice input {
  width: 20px;
  height: 20px;
}

.invite-choice small {
  display: block;
  margin-top: 2px;
}

.tip-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tip-card {
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,.94);
}

.tip-card strong {
  display: block;
  margin-bottom: 4px;
  color: #8b5a07;
  font-size: 13px;
}

.tip-card p {
  font-size: 14px;
  line-height: 1.35;
}

.turn-notice {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255,255,255,.94);
}

.turn-notice strong,
.turn-notice span {
  display: block;
}

.turn-notice span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.turn-notice.active-turn {
  border-color: var(--accent);
  background: #fff8e7;
}

.tips-page {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.tips-page .panel:last-child {
  grid-column: 1 / -1;
}

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

.tips-list p {
  border-left: 4px solid var(--accent);
  padding: 9px 10px;
  border-radius: 6px;
  background: #fff8e7;
  color: var(--ink);
}

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

.phase-tip-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.phase-tip-list article.current {
  border-color: var(--accent);
  background: #fff8e7;
}

.phase-tip-list strong {
  display: block;
  margin-bottom: 4px;
}

.mini-player {
  border-top: 1px solid #2b3544;
  padding: 8px 0;
}

.mini-player:first-of-type {
  border-top: 0;
}

.mini-player.active strong {
  color: var(--accent);
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #2b3544;
  padding: 8px 0;
}

.score-row:first-of-type {
  border-top: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
}

.admin-grid form,
.user-row {
  display: grid;
  gap: 10px;
}

.user-row {
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 260px) auto;
  align-items: end;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.user-row small {
  display: block;
}

#toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  border-radius: 8px;
  padding: 12px 14px;
  background: #111820;
  color: white;
  box-shadow: 0 12px 32px rgba(0,0,0,.24);
}

.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 16, 24, .68);
}

.guide-overlay[hidden] {
  display: none;
}

.guide {
  width: min(760px, 100%);
  max-height: min(86vh, 760px);
  display: grid;
  gap: 16px;
  overflow: auto;
  border-radius: 8px;
  padding: 20px;
  background: white;
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
}

.eyebrow {
  margin-bottom: 4px;
  color: #a35b13;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.guide article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.guide article strong {
  display: block;
  margin-bottom: 5px;
}

.guide article p {
  font-size: 14px;
  line-height: 1.38;
}

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

@media (max-width: 820px) {
  body {
    display: block;
  }

  aside {
    min-height: 0;
    padding: 10px;
  }

  .brand,
  .session {
    display: none;
  }

  nav {
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    margin-bottom: 8px;
  }

  nav button {
    min-height: 38px;
    padding: 8px 6px;
    font-size: 13px;
  }

  .side-box {
    display: none;
  }

  main {
    padding: 10px;
  }

  header {
    align-items: center;
  }

  h1 {
    font-size: 22px;
  }

  .table {
    min-height: calc(100vh - 118px);
    padding: 10px;
  }

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

  .seat {
    padding: 8px;
  }

  .seat small {
    display: none;
  }

  .stacks {
    gap: 8px;
  }

  .stack {
    width: 98px;
    height: 126px;
  }

  .hand-panel {
    margin: 0 -4px -4px;
    padding: 10px;
  }

  .card {
    width: 66px;
    min-width: 66px;
    height: 96px;
    min-height: 96px;
  }

  .admin-grid,
  .user-row {
    grid-template-columns: 1fr;
  }

  .password-wrap {
    grid-template-columns: 1fr;
  }

  .invite-head,
  .invite-note,
  .turn-notice,
  .tip-strip,
  .tips-page {
    display: grid;
    grid-template-columns: 1fr;
  }

  .invite-note button {
    grid-row: auto;
    grid-column: auto;
    justify-self: stretch;
  }

  .guide-overlay {
    align-items: end;
    padding: 10px;
  }

  .guide {
    max-height: 88vh;
    padding: 14px;
  }

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

  .guide-actions button {
    flex: 1 1 130px;
  }
}
