/* A 70s record shop: cream type on dark walnut, with sunset stripes. Always dark. */
:root {
  --bg: #1c1410;
  --surface: #2b201a;
  --surface-2: #3d2e25;
  --text: #fbefd9;
  --muted: #c4ad92;
  --border: #4d3a2e;
  --primary: #f26b1d;        /* burnt orange */
  --primary-text: #2a1206;
  --link: #f5b700;
  --accent: #f5b700;         /* mustard for points */
  --good: #7bd389;
  --bad: #ff6b5b;
  --danger: #d7263d;
  --radius: 16px;
  --display: "Cooper Black", "Cooper Std", "Bookman Old Style", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(ellipse 120% 50% at 50% 0%, rgb(242 107 29 / 0.16), transparent 70%),
    var(--bg);
}

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

button {
  touch-action: manipulation;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  background: var(--surface-2);
  user-select: none;
  -webkit-user-select: none;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }

.primary { background: var(--primary); color: var(--primary-text); }
.secondary { background: var(--surface-2); }
.danger { background: var(--danger); color: #fff; }
.ghost { background: transparent; color: var(--link); }
.wide { width: 100%; }
.big { padding: 16px; font-size: 1.1rem; }

main { padding: 0 16px 24px; max-width: 560px; margin: 0 auto; display: grid; gap: 14px; }

/* Setup */
.hero { text-align: center; padding: 32px 16px 18px; }
.hero h1 {
  margin: 14px 0 6px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 3.2rem;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
  text-shadow: 3px 3px 0 var(--primary), 6px 6px 0 rgb(245 183 0 / 0.55);
}
.amp { color: var(--accent); text-shadow: 3px 3px 0 #d7263d; }
.tagline { margin: 0; color: var(--muted); }

/* Four rainbow stripes bending over the title, like a 70s album sleeve */
.stripes {
  width: 132px;
  height: 66px;
  margin: 0 auto;
  position: relative;
}
.stripes span {
  position: absolute;
  inset: calc(var(--i) * 9px) calc(var(--i) * 9px) auto;
  height: calc(66px - var(--i) * 9px);
  border: 8px solid var(--c);
  border-bottom: none;
  border-radius: 999px 999px 0 0;
}
.stripes span:nth-child(1) { --i: 0; --c: #d7263d; }
.stripes span:nth-child(2) { --i: 1; --c: #f26b1d; }
.stripes span:nth-child(3) { --i: 2; --c: #f5b700; }
.stripes span:nth-child(4) { --i: 3; --c: #2a9d8f; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 14px;
}
.card h2 { margin: 0; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.help { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.player-list:empty::before { content: "Play solo, or add players to take turns."; color: var(--muted); font-size: 0.9rem; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
}
.player-list button { padding: 8px 12px; background: transparent; color: var(--muted); border-radius: 999px; }

.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input[type="text"] {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 16px; /* prevents iOS zoom on focus */
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.segmented.wide { display: flex; }
.segmented button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 9px;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }

.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-label { margin: 0; font-weight: 600; }
.field .segmented button { padding: 9px 14px; }

.chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
.chip {
  padding: 9px 0;
  border-radius: 999px;
  background: transparent;
  border: 2px solid var(--border);
  color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--primary-text); }

/* A board */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0; }
.topbar .ghost { width: 48px; font-size: 1.2rem; color: var(--muted); }
.round-label { margin: 0; font-weight: 700; color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; }

.scoreboard {
  list-style: none;
  margin: 0;
  padding: 2px 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.scoreboard li {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
  border: 2px solid transparent;
}
.scoreboard li.current { border-color: var(--primary); }
.scoreboard .pts { color: var(--accent); font-variant-numeric: tabular-nums; }
.missed { color: var(--bad); font-weight: 600; font-variant-numeric: tabular-nums; }

.turn-label { margin: 0; text-align: center; font-family: var(--display); font-size: 1.4rem; }
.board-score { margin: -8px 0 0; text-align: center; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

.board-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: -6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.board-head span { padding-left: 4px; }

/* Artists in the left column, titles in the right; each row is one height. */
.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(64px, auto);
  gap: 8px;
}
.tile {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  text-align: left;
  line-height: 1.2;
  border-radius: 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  overflow-wrap: anywhere;
}
.tile.artist { font-family: var(--display); font-weight: 400; font-size: 1.02rem; }
.tile.title { font-size: 0.92rem; }
/* The artist side looks like a record sleeve's spine. */
.tile.artist { border-left: 6px solid var(--primary); }
.title-name.album { font-style: italic; }
.tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgb(245 183 0 / 0.16);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.35);
}
.tile.wrong { border-color: var(--bad); background: rgb(255 107 91 / 0.15); animation: shake 0.4s ease-in-out; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Matched pairs share a colour from the 70s palette. */
.tile.matched { opacity: 1; color: #23140a; border-color: transparent; animation: pop 0.35s ease-out; }
.tile.matched .tag { color: rgb(35 20 10 / 0.7); }
.tile.matched.artist { border-left-color: rgb(0 0 0 / 0.2); }
.tile.c0 { background: #f26b1d; }
.tile.c1 { background: #f5b700; }
.tile.c2 { background: #2a9d8f; color: #f8fff9; }
.tile.c3 { background: #e85d75; }
.tile.c4 { background: #a3c45a; }
.tile.c5 { background: #d9a06b; }
.tile.c6 { background: #6fb7d6; }
.tile.c7 { background: #c38fd6; }
.tile.c2 .tag { color: rgb(248 255 249 / 0.8); }
@keyframes pop { 0% { transform: scale(0.92); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }

.result { margin: 0; text-align: center; font-family: var(--display); font-size: 1.3rem; }
.result.good { color: var(--good); }

.actions { display: grid; gap: 10px; }

/* Keep Next board on screen however long the board gets. */
#playScreen .actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: linear-gradient(to bottom, transparent, var(--bg) 20px);
}
#playScreen .actions:has(> [hidden]:only-child) { display: none; }
#playScreen main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

/* Winner */
.win { text-align: center; padding-top: 48px; }
.trophy { font-size: 4.5rem; margin: 0; animation: pop 0.6s ease-out; }
.win h1 { margin: 0; font-family: var(--display); font-size: 2.2rem; color: var(--text); text-shadow: 3px 3px 0 var(--primary); }
.standings { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.standings li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--surface); font-weight: 600; }
.standings li:first-child { outline: 2px solid var(--accent); }
.standings .pts { color: var(--accent); }
.standing-scores { display: flex; gap: 12px; align-items: baseline; }
.standing-scores .missed { font-size: 0.85rem; }

/* Bottom sheet */
.sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  border: none;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.6); }
.sheet form { display: grid; gap: 12px; }
.sheet-title { margin: 0; font-family: var(--display); font-size: 1.25rem; text-align: center; }
.sheet-message { margin: 0 0 4px; text-align: center; color: var(--muted); line-height: 1.4; }
.sheet-body p { margin: 0 0 10px; line-height: 1.45; }
.sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

::view-transition-group(*) { animation-duration: 0.35s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
