:root {
  --bg: #12161a;
  --panel: #1b2127;
  --panel-2: #232b33;
  --line: #313b45;
  --text: #ecebe6;
  --muted: #9aa5ae;
  --felt: #146b43;
  --felt-dark: #0b4a2d;
  --rail: #3a2716;
  --card: #fbf8f1;
  --good: #3ddc84;
  --bad: #ff5d5d;
  --gold: #f5c542;
  --accent: #6ec1ff;
  --spades: #1d1d1f;
  --hearts: #d42a3c;
  --diamonds: #1f6fd1;
  --clubs: #17914e;
  --card-w: 3.4rem;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button,
a,
summary {
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a {
  color: var(--accent);
}

kbd {
  font: 600 0.7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 0.2rem 0.35rem;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg);
}

/* Header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* viewport-fit=cover lets the page run under the notch and home bar, so pad by the safe areas. */
  padding: calc(0.75rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.75rem
    max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  background: var(--felt);
  margin-right: 0.35rem;
}

.score {
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.score span {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.score .streak b {
  color: var(--gold);
}

.score.pop .streak {
  animation: pop 0.45s ease-out;
}

.score.drop .streak {
  animation: shake 0.35s ease-in-out;
}

/* Layout */

main {
  flex: 1;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) calc(3rem + env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

/* Keep scrolled-to elements clear of the sticky header. */
.table,
.feedback {
  scroll-margin-top: calc(4.5rem + env(safe-area-inset-top));
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  line-height: 1.2;
  margin: 0.5rem 0;
}

.lede {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

/* Home */

.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.mode-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mode-tile span:not(.mode-icon) {
  color: var(--muted);
  font-size: 0.92rem;
}

a.mode-tile:focus-visible {
  transform: translateY(-3px);
  border-color: var(--felt);
  background: var(--panel-2);
}

/* Hover lifts only where there is a real pointer; on touch they stick after a tap. */
@media (hover: hover) {
  a.mode-tile:hover {
    transform: translateY(-3px);
    border-color: var(--felt);
    background: var(--panel-2);
  }
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  background: var(--felt);
  font-size: 1.2rem;
  font-weight: 700;
}

/* Play */

.play-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.back {
  font-size: 0.9rem;
  text-decoration: none;
}

.table {
  margin: 1rem 0 1.25rem;
  padding: 1.1rem;
  border-radius: 28px;
  background: radial-gradient(ellipse at 50% 30%, var(--felt), var(--felt-dark));
  border: 8px solid var(--rail);
  box-shadow: inset 0 0 40px rgb(0 0 0 / 0.35), 0 10px 30px rgb(0 0 0 / 0.35);
  display: grid;
  gap: 0.9rem;
}

.table.flash-good {
  animation: glow-good 0.7s ease-out;
}

.table.flash-bad {
  animation: shake 0.4s ease-in-out, glow-bad 0.7s ease-out;
}

.row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem;
  border-radius: 12px;
  transition: background 0.3s ease;
}

.row.winner {
  background: rgb(245 197 66 / 0.14);
  box-shadow: inset 0 0 0 1px rgb(245 197 66 / 0.5);
}

.row-label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 0.9rem;
  color: #e3f3ea;
}

.note {
  font-weight: 400;
  font-size: 0.8rem;
  color: #bfe3cf;
}

.row.winner .note {
  color: var(--gold);
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  perspective: 600px;
}

.none {
  color: #bfe3cf;
  font-size: 0.9rem;
}

/* Cards */

.card {
  position: relative;
  width: var(--card-w);
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.25), 0 6px 14px rgb(0 0 0 / 0.25);
  display: grid;
  place-items: center;
  font-weight: 700;
  transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  user-select: none;
}

.card .rank {
  position: absolute;
  top: 0.18rem;
  left: 0.32rem;
  font-size: calc(var(--card-w) * 0.34);
  line-height: 1;
  letter-spacing: -0.04em;
}

.card .pip {
  font-size: calc(var(--card-w) * 0.55);
  line-height: 1;
  margin-top: 0.7rem;
}

.card.small {
  --card-w: 2.2rem;
}

.card.small .pip {
  margin-top: 0.45rem;
}

.suit-spades {
  color: var(--spades);
}
.suit-hearts {
  color: var(--hearts);
}
.suit-diamonds {
  color: var(--diamonds);
}
.suit-clubs {
  color: var(--clubs);
}

.card.dim {
  opacity: 0.38;
  transform: scale(0.94);
}

.card.lift {
  transform: translateY(-4px);
  box-shadow: 0 0 0 2px var(--gold), 0 8px 18px rgb(0 0 0 / 0.35);
}

.table.dealing .card {
  animation: deal 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  animation-delay: var(--delay, 0ms);
}

.row.outs .card {
  animation: deal 0.35s ease-out both;
}

/* Question */

.prompt {
  font-size: 1.25rem;
  margin: 0 0 0.25rem;
}

.sub {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.6rem;
}

.choices.many {
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
}

.choice,
.next {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  min-height: 3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
  .choice:hover:not(:disabled) {
    background: var(--panel-2);
    border-color: var(--muted);
    transform: translateY(-2px);
  }

  .next:hover {
    background: #198553;
  }
}

.choice:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.choice:focus-visible,
.next:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.choice:disabled {
  cursor: default;
  opacity: 0.55;
}

.choice.right {
  opacity: 1;
  border-color: var(--good);
  background: rgb(61 220 132 / 0.16);
  animation: pop 0.4s ease-out;
}

.choice.wrong {
  opacity: 1;
  border-color: var(--bad);
  background: rgb(255 93 93 / 0.14);
  animation: shake 0.35s ease-in-out;
}

/* Feedback */

.feedback {
  margin-top: 1.1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  animation: rise 0.3s ease-out;
}

.feedback p {
  margin: 0 0 0.6rem;
}

.verdict {
  font-size: 1.15rem;
  font-weight: 800;
}

.verdict.good {
  color: var(--good);
}

.verdict.bad {
  color: var(--bad);
}

.next {
  margin-top: 0.4rem;
  background: var(--felt);
  border-color: var(--felt);
}

/* Cheat sheets */

.sheet {
  margin-top: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.25rem 1rem;
}

.sheet summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.6rem 0;
}

.rank-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.75rem;
}

.rank-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: center;
}

.rank-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.rank-list .cards {
  gap: 0.2rem;
  flex-wrap: nowrap;
}

.sheet table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.75rem;
}

.sheet th,
.sheet td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

.sheet th {
  color: var(--muted);
  font-weight: 600;
}

.sheet > p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Confetti */

.burst {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 20;
}

.burst i {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: hsl(var(--hue) 85% 62%);
  animation: confetti 0.95s cubic-bezier(0.15, 0.7, 0.4, 1) forwards;
}

/* Animations */

@keyframes deal {
  from {
    opacity: 0;
    transform: translateY(-24px) rotateY(90deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@keyframes glow-good {
  from {
    box-shadow: inset 0 0 40px rgb(0 0 0 / 0.35), 0 0 0 4px var(--good), 0 0 40px rgb(61 220 132 / 0.6);
  }
}

@keyframes glow-bad {
  from {
    box-shadow: inset 0 0 40px rgb(0 0 0 / 0.35), 0 0 0 4px var(--bad), 0 0 40px rgb(255 93 93 / 0.5);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes confetti {
  to {
    transform: translate(var(--x), calc(var(--y) + 120px)) rotate(var(--r));
    opacity: 0;
  }
}

@media (max-width: 560px) {
  :root {
    --card-w: 2.75rem;
  }

  main {
    padding-top: 0.75rem;
  }

  .score .best {
    display: none;
  }

  .table {
    padding: 0.7rem;
    border-width: 6px;
    border-radius: 20px;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .row-label {
    flex-direction: row;
    gap: 0.5rem;
    align-items: baseline;
  }

  .choices,
  .choices.many {
    grid-template-columns: 1fr 1fr;
  }

  .rank-list .cards {
    --card-w: 1.8rem;
  }

  .rank-list .card.small {
    --card-w: 1.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Seats */

.seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
}

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.2rem;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.18);
  color: #cfe8da;
  font-size: 0.78rem;
  line-height: 1.25;
  min-height: 2.6rem;
  justify-content: center;
}

.seat strong {
  font-size: 0.85rem;
}

.seat.fold {
  opacity: 0.45;
}

.seat.raise {
  background: rgb(255 93 93 / 0.22);
  color: #ffd2d2;
  box-shadow: inset 0 0 0 1px rgb(255 93 93 / 0.6);
}

.seat.you {
  background: rgb(245 197 66 / 0.2);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgb(245 197 66 / 0.7);
}

/* Range grid */

.range {
  margin: 0.75rem 0 0.9rem;
}

.range figcaption {
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.grid {
  display: grid;
  gap: 2px;
  max-width: 520px;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
}

.cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 3px;
  font-size: clamp(0.5rem, 2.3vw, 0.72rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: rgb(255 255 255 / 0.9);
  background: var(--panel-2);
}

.cell.raise {
  background: #b8433f;
}

.cell.call {
  background: #2f7d55;
}

.cell.fold {
  background: #2a3138;
  color: var(--muted);
}

.cell.here {
  outline: 3px solid var(--gold);
  outline-offset: -1px;
  position: relative;
  z-index: 1;
  animation: pop 0.5s ease-out 0.15s;
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend .cell {
  width: 0.9rem;
  aspect-ratio: 1;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.tab {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}

.tab[aria-pressed='true'] {
  background: var(--felt);
  border-color: var(--felt);
}

@media (max-width: 560px) {
  .seat {
    font-size: 0.68rem;
  }

  .seat strong {
    font-size: 0.75rem;
  }
}

/* Account */

.top-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.account {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.menu {
  position: relative;
}

.signin {
  display: inline-block;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: #5865f2;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.signin:hover {
  background: #4752c4;
}

.signin:disabled {
  cursor: progress;
  opacity: 0.7;
}

.menu summary {
  list-style: none;
  cursor: pointer;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  width: min(17rem, calc(100vw - 2rem));
  padding: 0.9rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.45);
  display: grid;
  gap: 0.5rem;
  animation: rise 0.2s ease-out;
}

.menu-body button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  text-align: left;
}

.menu-body button.danger {
  color: var(--bad);
}

.menu-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.offline-tag {
  color: var(--muted);
  font-weight: normal;
}

.menu-note:empty {
  display: none;
}

.lifetime {
  color: var(--good);
  font-size: 0.8rem;
}

.notice {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  margin: 0 0 1rem;
}

@media (max-width: 560px) {
  .score .tally {
    display: none;
  }

  .signin {
    padding: 0.3rem 0.6rem;
  }

  .menu summary {
    max-width: 6.5rem;
  }
}

@media (max-width: 480px) {
  .wide-only {
    display: none;
  }
}

@media (max-width: 400px) {
  .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

/* Sound toggle */

.sound {
  font: inherit;
  font-size: 1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 600;
  cursor: pointer;
}

.menu-toggle input {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0;
  accent-color: var(--good);
}

.settings-menu summary {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

/* iPhone haptics: an invisible switch over a drill button, so the tap itself toggles it. */
.haptic-wrap {
  position: relative;
  display: grid;
}

.haptic-wrap > button {
  width: 100%;
  height: 100%;
}

.haptic-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.haptic-hit input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

.haptic-wrap:active > button:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.haptic-wrap:has(button:disabled) .haptic-hit {
  display: none;
}

/* The hidden switch iOS needs for its haptic tick. Kept rendered (not display: none) but
   invisible and out of the way. */
.haptic-switch {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  opacity: 0;
  pointer-events: none;
}

.sound[aria-pressed='true'] {
  color: var(--gold);
  border-color: var(--gold);
}

/* Weak spots */

.review-mode h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

.review-mode h2 a {
  color: var(--text);
}

.spots {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.spots li {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(4rem, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

.spot-tag {
  overflow-wrap: anywhere;
}

.spot-bar {
  height: 0.45rem;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.spot-fill {
  display: block;
  height: 100%;
  background: var(--bad);
  border-radius: inherit;
}

.spot-count {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

@media (max-width: 560px) {
  .spots li {
    grid-template-columns: 1fr auto;
  }

  .spot-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Account menu links */

.menu-link {
  display: block;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  text-decoration: none;
}

.menu-link:hover,
.menu-link:focus-visible {
  border-color: var(--felt);
}

/* Progress */

.filters {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 1rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  animation: rise 0.25s ease-out;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.stat strong {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.trend {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.trend.up {
  color: var(--good);
}

.trend.down {
  color: var(--bad);
}

.trend.flat {
  color: var(--muted);
}

.mode-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.mode-stat {
  font: inherit;
  color: var(--text);
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.65rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mode-stat:hover,
.mode-stat:focus-visible {
  transform: translateY(-2px);
  border-color: var(--felt);
  background: var(--panel-2);
}

.mode-stat .mode-icon {
  grid-row: 1 / 3;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
}

.mode-stat-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.mode-stat-line {
  font-size: 0.85rem;
  color: var(--muted);
}

.mode-stat-line strong {
  color: var(--text);
}

.chart {
  margin: 0 0 1rem;
  padding: 0.75rem 0.75rem 0.5rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}

.chart-grid line {
  stroke: var(--line);
  stroke-dasharray: 3 4;
}

.chart-hit {
  fill: transparent;
}

.chart-slot:hover .chart-hit {
  fill: rgb(255 255 255 / 0.04);
}

.chart-bar {
  fill: var(--felt);
  opacity: 0.75;
}

.chart-slot:hover .chart-bar {
  opacity: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.9s ease-out forwards;
}

.chart-dot {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 2;
  pointer-events: none;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.chart-key {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.chart-key span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.key-line,
.key-bar {
  display: inline-block;
  width: 0.9rem;
  border-radius: 2px;
}

.key-line {
  height: 3px;
  background: var(--accent);
}

.key-bar {
  height: 0.7rem;
  background: var(--felt);
}

.section-title {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.history th,
.history td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.history tbody tr:last-child td {
  border-bottom: 0;
}

.history tbody tr:hover {
  background: var(--panel-2);
}

.history th button {
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.history th[aria-sort] button {
  color: var(--text);
}

.history .acc {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.history .acc span:first-child {
  min-width: 2.6rem;
}

.acc-bar {
  flex: 1;
  min-width: 3rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.acc-fill {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: inherit;
}

.small {
  font-size: 0.85rem;
}

@media (max-width: 560px) {
  .stat strong {
    font-size: 1.25rem;
  }

  .history th,
  .history td {
    padding: 0.45rem 0.5rem;
  }

  .acc-bar {
    display: none;
  }
}

/* Phones. Tuned on a 440 x 956 viewport (iPhone Pro Max), checked down to 375. */

@media (max-width: 560px) {
  h1 {
    font-size: 1.45rem;
  }

  .play-head {
    gap: 0.25rem 0.75rem;
  }

  .play-head h1 {
    margin: 0;
  }

  .prompt {
    font-size: 1.12rem;
    line-height: 1.35;
  }

  .modes {
    gap: 0.6rem;
  }

  .mode-tile {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    column-gap: 0.9rem;
    row-gap: 0.1rem;
    padding: 0.9rem 1rem;
  }

  .mode-tile .mode-icon {
    grid-row: 1 / span 3;
  }

  .mode-tile > :not(.mode-icon) {
    grid-column: 2;
  }

  .feedback {
    padding: 0.9rem;
  }

  .sheet {
    padding: 0.25rem 0.85rem;
  }
}

@media (min-width: 400px) and (max-width: 560px) {
  :root {
    --card-w: 3.2rem;
  }
}

/* Touch screens: no keyboard hints, bigger targets, and the next-hand button sits right under the answers. */

@media (hover: none) and (pointer: coarse) {
  .choice kbd,
  .next kbd {
    display: none;
  }

  .choice {
    min-height: 3.5rem;
    justify-content: center;
    text-align: center;
  }

  .next {
    width: 100%;
    min-height: 3.5rem;
    margin-top: 0.6rem;
    justify-content: center;
    animation: rise 0.25s ease-out;
  }

  .tab {
    padding: 0.45rem 0.85rem;
  }

  .sound {
    width: 2.4rem;
    height: 2.4rem;
  }

  .signin,
  .menu summary {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }
}
