/* Home + lobby. Needs base.css first. */

.home {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.home-header {
  text-align: center;
  animation: rise 400ms ease-out both;
}

.home-logo {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(30px, 7vw, 52px);
  line-height: 1;
  padding: 10px 20px;
  background: var(--you);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: rotate(-2deg);
}

.home-tagline {
  margin: 14px 0 0;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.home-foot {
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.screen {
  padding: 22px 20px 24px;
  background-image: var(--paper-grain);
  animation: rise 320ms ease-out both;
}

.screen h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.05;
  margin: 0 0 14px;
  text-align: center;
}

.stack {
  display: grid;
  gap: 14px;
}

/* Staggered entrance, only when the screen changes (not on every lobby update). */
.screen.is-entering .stack > * {
  animation: rise 320ms ease-out both;
}
.screen.is-entering .stack > *:nth-child(2) { animation-delay: 40ms; }
.screen.is-entering .stack > *:nth-child(3) { animation-delay: 80ms; }
.screen.is-entering .stack > *:nth-child(4) { animation-delay: 120ms; }
.screen.is-entering .stack > *:nth-child(n + 5) { animation-delay: 160ms; }

/* ---- Form bits ---- */

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 22px;
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  border: var(--border);
  border-radius: 12px;
  box-shadow: inset 3px 3px 0 rgba(17, 17, 17, 0.08);
}

.text-input:focus {
  outline: 3px solid var(--six);
  outline-offset: 2px;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  text-align: center;
}

.form-error {
  margin: 0;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13px;
  color: var(--paper);
  background: var(--out);
  border: 3px solid var(--ink);
  border-radius: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.row > .text-input {
  flex: 1;
  min-width: 0;
}

.link-btn {
  justify-self: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-wide {
  width: 100%;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-top: 3px solid var(--ink);
}

/* ---- Big mode choices ---- */

.choices {
  display: grid;
  gap: 14px;
}

@media (min-width: 560px) {
  .choices {
    grid-template-columns: 1fr 1fr;
  }
}

.choice {
  display: grid;
  justify-items: start;
  gap: 4px;
  padding: 18px 18px 16px;
  text-align: left;
  color: var(--ink);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.choice:hover {
  transform: translate(-2px, -3px);
  box-shadow: 8px 9px 0 var(--ink);
}

.choice:active {
  transform: translate(4px, 4px);
  box-shadow: 1px 1px 0 var(--ink);
}

.choice:focus-visible {
  outline: 3px solid var(--six);
  outline-offset: 3px;
}

.choice-cpu { background: var(--you); }
.choice-friend { background: var(--opp); }

.choice-icon {
  font-size: 36px;
  line-height: 1;
}

.choice-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.1;
}

.choice-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

/* ---- Lobby ---- */

.lobby-label {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.room-code {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.room-code span {
  width: clamp(52px, 13vw, 72px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(32px, 8vw, 46px);
  background: var(--you);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.room-code span:nth-child(even) {
  background: var(--opp);
}

.copy-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.copy-status {
  font-size: 13px;
  font-weight: 700;
}

.notice {
  text-align: center;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 14px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: var(--you);
}

.slots {
  display: grid;
  gap: 14px;
}

@media (min-width: 560px) {
  .slots {
    grid-template-columns: 1fr 1fr;
  }
}

.slot {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 150px;
  padding: 14px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.slot-me { background: var(--you); }
.slot-friend { background: var(--opp); }

.slot.is-waiting {
  background: var(--paper);
  border-style: dashed;
  box-shadow: none;
}

.slot-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.slot-name {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.slot.is-waiting .slot-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  animation: breathe 1.4s ease-in-out infinite;
}

.ready-pill {
  justify-self: start;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}

.ready-pill.is-ready {
  background: var(--ready);
}

.slot .btn {
  margin-top: auto;
}

.btn-ready-on {
  background: var(--ready);
}

.lobby-status {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 28px);
  padding: 10px;
  background: var(--ready);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  animation: pop 320ms ease-out both;
}

.lobby-hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---- How to play ---- */

.how-to {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: color-mix(in srgb, var(--pitch) 18%, var(--paper));
}

.how-to-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.how-to-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-to-steps li {
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
}

/* ---- Home grid: play on the left, My groups on the right (wide screens) ---- */

.home:has(.home-grid.has-groups) {
  max-width: 1080px;
}

.home-grid {
  display: grid;
  gap: 20px;
  align-items: start;
}

@media (min-width: 960px) {
  .home-grid.has-groups {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  }
}

.groups-panel {
  display: grid;
  gap: 10px;
  padding: 18px 18px 20px;
  background-image: var(--paper-grain);
  animation: rise 320ms ease-out both;
}

.groups-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
}

.groups-list {
  display: grid;
  gap: 8px;
  max-height: 228px;
  overflow-y: auto;
  padding: 2px 4px 4px 2px; /* room for the row shadows */
}

.groups-empty {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.group-row {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  color: var(--ink);
  text-decoration: none;
  background: var(--opp);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.group-row:nth-child(even) {
  background: var(--you);
}

.group-row:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

.group-row:focus-visible {
  outline: 3px solid var(--six);
  outline-offset: 3px;
}

.group-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.group-row-name {
  font-family: var(--font-display);
  font-size: 17px;
  overflow-wrap: anywhere;
}

.group-row-meta,
.group-row-line {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.group-row-line {
  white-space: normal;
}

.small-input {
  font-size: 16px;
  padding: 7px 12px;
}

/* ---- Group page ---- */

.group-page {
  max-width: 820px;
}

.group-head {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.group-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.group-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.code-chip {
  padding: 3px 10px;
  letter-spacing: 0.2em;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
}

.board {
  display: grid;
  gap: 12px;
  padding: 16px 16px 18px;
  background-image: var(--paper-grain);
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  flex: 1;
  font-family: var(--font-display);
  font-size: 15px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.tab[aria-selected='true'] {
  background: var(--you);
  box-shadow: var(--shadow-sm);
}

.tab:hover {
  transform: translateY(-1px);
}

.tab:focus-visible {
  outline: 3px solid var(--six);
  outline-offset: 2px;
}

.standing-line {
  margin: 0;
  padding: 8px 12px;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(16px, 2.4vw, 20px);
  background: var(--ink);
  color: var(--you);
  border-radius: 10px;
}

/* Only the table scrolls, so the page itself fits one screen. */
.table-wrap {
  max-height: min(48vh, 360px);
  overflow-y: auto;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.board-table th {
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-align: right;
  color: var(--paper);
  background: var(--ink);
}

.board-table td {
  padding: 8px 10px;
  font-weight: 700;
  text-align: right;
  border-top: 2px solid rgba(17, 17, 17, 0.12);
}

.board-table th:nth-child(2),
.board-table td:nth-child(2) {
  text-align: left;
  width: 100%;
}

.board-table th:first-child,
.board-table td:first-child {
  text-align: left;
  white-space: nowrap;
}

.board-table td.rank {
  font-family: var(--font-display);
  font-weight: 400;
}

.board-table tr.is-me td {
  background: var(--you);
}

.board-table tr.is-first td.rank {
  font-size: 16px;
}

.board-table .you-tag {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}

.board-empty {
  margin: 0;
  padding: 18px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.group-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.group-logo {
  font-size: clamp(18px, 3vw, 24px);
  padding: 6px 14px;
  color: var(--ink);
  text-decoration: none;
}

.board-empty .btn {
  margin-top: 8px;
}

.group-actions .btn {
  text-decoration: none;
}
