* { box-sizing: border-box; }

:root {
  --bg: #111217;
  --panel: #1b1d24;
  --panel-2: #242731;
  --text: #f4f4f5;
  --muted: #a7aab5;
  --accent: #6573e8;
  --accent-hover: #7885f1;
  --danger: #ff6f91;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #272a38 0%, var(--bg) 45%);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app { width: min(1400px, 100%); margin: 0 auto; padding: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 30px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 26px; letter-spacing: 1px; }
h2 { margin-bottom: 8px; font-size: 30px; }
.subtitle, .muted { color: var(--muted); }
.screen { width: 100%; }
.hidden { display: none !important; }

.center-screen {
  min-height: 50vh; display: flex; flex-direction: column;
  justify-content: center; align-items: center; color: var(--muted);
}
.loader { width: 38px; height: 38px; border: 4px solid #343743; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  max-width: 480px; margin: 60px auto; padding: 30px;
  background: rgba(27, 29, 36, .95); border: 1px solid #30333e;
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.setup-panel label { display: block; margin: 20px 0 8px; font-weight: 700; }
.setup-panel label:first-of-type { margin-top: 24px; }
.setup-panel input, .setup-select {
  width: 100%; padding: 13px 14px; border: 1px solid #444754;
  border-radius: 10px; background: #111217; color: white; outline: none;
}
.setup-panel input:focus, .setup-select:focus { border-color: var(--accent); }
.setup-select { appearance: auto; }
.multi-select { position: relative; width: 100%; }
.multi-select-button { text-align: left; position: relative; padding-right: 38px !important; }
.multi-select-button::after { content: "▾"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.multi-select-menu { display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: 260px; overflow-y: auto; padding: 7px; background: #111217; border: 1px solid #444754; border-radius: 10px; box-shadow: 0 18px 35px rgba(0,0,0,.45); }
.multi-select-menu.open { display: block; }
.multi-option { display: flex; align-items: center; gap: 9px; padding: 9px 8px; border-radius: 7px; cursor: pointer; font-weight: 400; margin: 0 !important; }
.multi-option:hover { background: #242731; }
.multi-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.multi-option-all { border-bottom: 1px solid #30333e; margin-bottom: 4px !important; padding-bottom: 10px; font-weight: 700; }

.hint { margin: 8px 0 20px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 14px; }

.primary-btn, .secondary-btn { border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 700; }
.primary-btn { background: var(--accent); color: white; }
.primary-btn:hover { background: var(--accent-hover); }
.secondary-btn { background: #2b2e39; color: white; }

.draft-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.draft-actions { display: flex; align-items: center; gap: 18px; }
.choices-btn { white-space: nowrap; }
.eyebrow { display: block; color: #8994ff; font-size: 12px; font-weight: 800; letter-spacing: 1.5px; margin-bottom: 6px; }
.remaining { text-align: right; color: var(--muted); font-size: 13px; }
.remaining strong { display: block; color: white; font-size: 24px; margin-top: 2px; }

.cards-container {
  display: grid; grid-template-columns: repeat(5, minmax(150px, 220px));
  justify-content: center; gap: 18px; align-items: start;
}

/* Carte simplifiée : aspect proche de la maquette de référence. */
.draft-card {
  width: 100%; aspect-ratio: 0.56; border: 0; padding: 0;
  border-radius: 22px; overflow: hidden; background: #000;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative; color: #fff; text-align: center;
}
.draft-card:hover { transform: translateY(-8px) scale(1.02); box-shadow: 0 18px 35px rgba(0,0,0,.55); }

/* Short reveal animation: deliberately quick so it never becomes a substitute
   for image loading. Images are fully preloaded before cards are inserted. */
.cards-container .draft-card {
  opacity: 0;
  animation: card-reveal .22s ease-out forwards;
}
@keyframes card-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}
.draft-card:focus-visible { outline: 4px solid #8994ff; outline-offset: 4px; }

.card-group {
  height: 9%; min-height: 26px; display: flex; align-items: center; justify-content: center;
  padding: 3px 8px; background: #000; color: #fff; font-weight: 700;
  font-size: clamp(10px, 1.1vw, 14px); text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-photo { height: 70%; background: #202020; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-placeholder { font-weight: 700; font-style: italic; font-size: 16px; color: #aaa; }
.card-artist {
  height: 14%; display: flex; align-items: center; justify-content: center;
  padding: 5px 7px; background: #000; color: #fff; font-weight: 900;
  font-size: clamp(12px, 1.5vw, 19px); text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-year { height: 7%; min-height: 22px; display: flex; align-items: center; justify-content: center; background: #000; color: #d7d7d7; font-size: clamp(10px, 1.1vw, 14px); }

.instruction { text-align: center; color: var(--muted); margin: 24px 0 0; }

body.modal-open { overflow: hidden; }
.choices-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(2px);
}
.choices-modal {
  width: min(1050px, 100%); max-height: min(82vh, 760px);
  overflow-y: auto; padding: 28px;
  background: var(--panel); border: 1px solid #363945;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .65);
}
.choices-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 8px;
}
.choices-modal-header h2 { margin-bottom: 0; }
.choices-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 170px));
  justify-content: center; gap: 14px; margin-top: 20px;
}
.choice-mini-card {
  border-radius: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.choice-mini-card:hover { transform: none; box-shadow: 0 6px 18px rgba(0,0,0,.35); }

.final-header { margin-bottom: 24px; }
.final-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 220px)); justify-content: center; gap: 18px; margin-bottom: 30px; }
.final-cards .draft-card { cursor: default; }
.final-cards .draft-card:hover { transform: none; }

@media (max-width: 950px) {
  .cards-container { grid-template-columns: repeat(3, minmax(150px, 210px)); }
}
@media (max-width: 620px) {
  .app { padding: 16px; }
  .topbar { margin-bottom: 20px; }
  .draft-header { align-items: flex-start; }
  .draft-actions { flex-direction: column; align-items: flex-end; gap: 10px; }
  .choices-modal { padding: 20px; border-radius: 16px; }
  .choices-modal-header { align-items: center; }
  .choices-cards { grid-template-columns: repeat(2, minmax(100px, 1fr)); gap: 10px; }
  h1 { font-size: 22px; }
  h2 { font-size: 25px; }
  .cards-container { grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 12px; }
  .draft-card { border-radius: 16px; }
  .final-cards { grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 12px; }
}

/* ==========================================================
   v4.6.3 — Polaroid visual branch
   These styles are intentionally isolated from the v4.6 branch.
   ========================================================== */
:root {
  --bg: #eee7dc;
  --wall: #f4eee5;
  --panel: rgba(255,255,255,.93);
  --panel-2: #f6f1e8;
  --text: #24242a;
  --muted: #77736d;
  --accent: #6b67d8;
  --accent-hover: #5955c5;
  --danger: #b84f61;
}

body {
  background:
    radial-gradient(circle at 18% 10%, rgba(255,255,255,.95), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(214,201,181,.35), transparent 24%),
    linear-gradient(135deg, #e9e0d3 0%, #f5f0e8 48%, #e5dbcc 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    repeating-linear-gradient(0deg, rgba(70,55,40,.05) 0, rgba(70,55,40,.05) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.10) 0, rgba(255,255,255,.10) 1px, transparent 1px, transparent 5px);
  z-index: -1;
}

.app { width: min(1500px, 100%); padding: 24px 30px 36px; }
.topbar { margin-bottom: 28px; }
.brand-block h1 {
  font-size: 28px;
  letter-spacing: 1px;
  font-weight: 900;
  margin-bottom: 4px;
}
.brand-block h1 span { font-family: "Comic Sans MS", "Trebuchet MS", cursive; font-weight: 700; }
.subtitle { color: #8a8177; }

.utility-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.88); color: #33323a;
  box-shadow: 0 5px 18px rgba(71,55,38,.14);
  font-size: 21px; font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.icon-btn:hover { transform: translateY(-2px); background: white; box-shadow: 0 8px 22px rgba(71,55,38,.18); }
.secondary-btn { background: rgba(255,255,255,.9); color: #34333b; box-shadow: 0 5px 18px rgba(71,55,38,.12); }
.secondary-btn:hover { background: white; }

.draft-screen { position: relative; }
.draft-header {
  align-items: center;
  padding: 15px 18px;
  border-radius: 22px;
  background: rgba(255,255,255,.60);
  box-shadow: 0 10px 30px rgba(70,53,35,.08);
  backdrop-filter: blur(5px);
}
.eyebrow { color: #746fca; }
.draft-header h2 { color: #292832; }
.draft-actions { gap: 14px; }
.remaining { color: #817a72; }
.remaining strong { color: #2e2d34; }
.choices-btn {
  border-radius: 22px;
  padding: 12px 20px;
  background: #6966d8;
  color: white;
}
.choices-btn:hover { background: #5855c4; }

.cards-container {
  position: relative;
  min-height: 560px;
  grid-template-columns: repeat(5, minmax(160px, 230px));
  gap: 24px;
  align-items: start;
  padding: 58px 18px 24px;
}
.cards-container::before {
  content: "";
  position: absolute;
  left: 3%; right: 3%; top: 34px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(#a77c4c, #7e5837);
  box-shadow: 0 4px 5px rgba(54,38,22,.16);
  transform: rotate(-1deg);
  z-index: 0;
}

.draft-card {
  --tilt: 0deg;
  position: relative;
  z-index: 1;
  aspect-ratio: .72;
  border-radius: 1px;
  padding: 11px 11px 20px;
  overflow: visible;
  background: #fffdf9;
  color: #25242a;
  box-shadow: 0 12px 22px rgba(65,49,32,.20), 0 2px 4px rgba(65,49,32,.12);
  transform: rotate(var(--tilt));
  transition: transform .18s ease, box-shadow .18s ease;
}
.draft-card::before {
  content: "";
  position: absolute;
  width: 28px; height: 58px;
  left: 50%; top: -25px;
  transform: translateX(-50%) rotate(-2deg);
  border-radius: 3px 3px 7px 7px;
  background: linear-gradient(90deg, #d2ad7a 0%, #f0d3a4 46%, #b78955 100%);
  box-shadow: 1px 2px 4px rgba(60,40,20,.25);
  z-index: 5;
}
.draft-card::after {
  content: "";
  position: absolute;
  left: 50%; top: -2px;
  width: 8px; height: 35px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(126,86,51,.18);
  z-index: 6;
}
.draft-card:hover {
  transform: translateY(-9px) rotate(0deg) scale(1.025);
  box-shadow: 0 22px 35px rgba(65,49,32,.27), 0 3px 6px rgba(65,49,32,.13);
}
.cards-container .draft-card:nth-child(1) { --tilt: -2.2deg; }
.cards-container .draft-card:nth-child(2) { --tilt: 1.7deg; }
.cards-container .draft-card:nth-child(3) { --tilt: -.8deg; }
.cards-container .draft-card:nth-child(4) { --tilt: 2.2deg; }
.cards-container .draft-card:nth-child(5) { --tilt: -1.4deg; }

.cards-container .draft-card { opacity: 0; animation: card-reveal .22s ease-out forwards; }
.card-photo {
  height: 73%;
  min-height: 0;
  background: #ddd5ca;
  border: 1px solid #ece4da;
}
.card-photo img { object-fit: cover; }
.card-artist {
  height: 11%;
  min-height: 34px;
  padding: 5px 4px 0;
  background: transparent;
  color: #222127;
  font-size: clamp(13px, 1.45vw, 20px);
  letter-spacing: .5px;
}
.card-group {
  height: 7%;
  min-height: 22px;
  padding: 0 5px;
  background: transparent;
  color: #55515a;
  font-size: clamp(9px, 1vw, 13px);
  font-weight: 700;
}
.card-year {
  height: 6%;
  min-height: 20px;
  background: transparent;
  color: #77716a;
  font-size: clamp(9px, 1vw, 13px);
}
.photo-placeholder { color: #91897f; }
.draft-card:focus-visible { outline: 4px solid #8581e5; outline-offset: 5px; }

.draft-footer-hint {
  text-align: center;
  color: #81796f;
  font-size: 13px;
  margin: 0 0 8px;
}

/* Small keyboard/filter dialogs. */
.small-overlay {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 82px 30px 24px;
  background: rgba(50,40,30,.16);
  backdrop-filter: blur(2px);
}
.small-modal {
  width: min(390px, 100%);
  padding: 24px;
  border-radius: 22px;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(92,77,59,.13);
  box-shadow: 0 24px 70px rgba(55,40,24,.25);
}
.small-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 15px;
  margin-bottom: 18px;
}
.small-modal-header h2 { margin-bottom: 0; font-size: 24px; }
.modal-close-btn { width: 38px; height: 38px; font-size: 25px; }
.keyboard-grid { display: grid; gap: 10px; }
.keyboard-grid > div {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 7px;
  padding: 9px 10px; border-radius: 12px; background: #f4efe8;
  color: #4a4641; font-size: 14px;
}
.keycap {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; background: #fff; border: 1px solid #d6cec4;
  box-shadow: 0 2px 0 #c5bbae; font-weight: 800; color: #35323a;
}
.keycap-wide { min-width: 70px; }
.filters-summary { display: grid; gap: 10px; }
.filter-chip {
  padding: 12px 14px; border-radius: 13px; background: #f4efe8; color: #45413d;
}
.filter-chip strong { display: block; margin-bottom: 3px; color: #29272c; }
.filter-note { margin: 16px 0 0; color: #8a8278; font-size: 12px; line-height: 1.5; }

/* Keep the choices popup on demand only; its visual language follows the board. */
.choices-overlay { background: rgba(49,39,29,.62); }
.choices-modal {
  background: #f8f4ed;
  border: 1px solid rgba(90,70,45,.15);
  border-radius: 22px;
  box-shadow: 0 28px 90px rgba(45,32,18,.42);
}
.choices-modal-header h2 { color: #29272d; }
.choices-cards { grid-template-columns: repeat(auto-fill, minmax(120px, 165px)); }
.choice-mini-card {
  aspect-ratio: .72;
  padding: 8px 8px 14px;
  border-radius: 1px;
  transform: none !important;
  box-shadow: 0 8px 16px rgba(65,49,32,.18);
}
.choice-mini-card::before, .choice-mini-card::after { display: none; }
.choice-mini-card .card-photo { height: 73%; }
.choice-mini-card .card-artist { font-size: 14px; }
.choice-mini-card .card-group, .choice-mini-card .card-year { font-size: 10px; }
.choice-mini-card:hover { transform: translateY(-2px) !important; box-shadow: 0 10px 20px rgba(65,49,32,.22); }

.final-cards .draft-card { cursor: default; }
.final-cards .draft-card:hover { transform: rotate(var(--tilt)); }

@media (max-width: 950px) {
  .cards-container { grid-template-columns: repeat(3, minmax(155px, 210px)); min-height: 760px; }
}
@media (max-width: 620px) {
  .app { padding: 16px; }
  .topbar { align-items: flex-start; }
  .brand-block h1 { font-size: 23px; }
  .subtitle { font-size: 12px; }
  .utility-actions { gap: 6px; }
  .icon-btn { width: 39px; height: 39px; font-size: 18px; }
  .draft-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .draft-actions { justify-content: space-between; flex-direction: row; align-items: center; }
  .cards-container { grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 18px 13px; padding: 52px 5px 20px; min-height: 640px; }
  .cards-container::before { left: 0; right: 0; }
  .draft-card { padding: 8px 8px 14px; }
  .small-overlay { padding: 70px 14px 14px; }
  .small-modal { width: 100%; padding: 20px; }
  .choices-modal { padding: 18px; border-radius: 18px; }
  .choices-cards { grid-template-columns: repeat(2, minmax(105px, 1fr)); gap: 10px; }
}

/* ==========================================================
   v4.7 — Polaroid board / simplified interface
   ========================================================== */

body {
  overflow-x: hidden;
}

.app {
  width: min(1540px, 100%);
  padding: 22px 34px 42px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
}

.brand-block {
  justify-self: start;
}

.brand-block h1 {
  margin: 0;
  color: #27242a;
  font-size: 30px;
  line-height: .95;
  letter-spacing: .5px;
  font-weight: 900;
}

.brand-block h1 span {
  font-family: "Comic Sans MS", "Trebuchet MS", cursive;
  font-size: .94em;
  letter-spacing: 0;
}

.utility-actions {
  justify-self: end;
  display: flex;
  align-items: center;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(91,73,55,.08);
  background: rgba(255,255,255,.88);
  color: #39343a;
  box-shadow: 0 6px 18px rgba(71,55,38,.14);
  font-size: 21px;
}

.icon-btn:hover {
  background: #fff;
  transform: translateY(-2px) rotate(8deg);
}

.phase-nav {
  width: min(590px, 48vw);
  min-height: 64px;
  padding: 9px 11px 9px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid rgba(104,84,62,.10);
  border-radius: 34px;
  background: rgba(255,255,255,.76);
  box-shadow: 0 10px 28px rgba(70,53,35,.12);
  backdrop-filter: blur(10px);
}

.phase-nav-title {
  min-width: 0;
}

.phase-nav-title .eyebrow {
  margin-bottom: 2px;
  color: #827b72;
  font-size: 10px;
  letter-spacing: 1.4px;
}

.phase-nav-title strong {
  display: block;
  color: #29272e;
  font-size: 20px;
  white-space: nowrap;
}

.phase-choice-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 26px;
  padding: 12px 20px;
  background: #6966d8;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(84,80,194,.20);
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.phase-choice-btn:hover {
  background: #5955c7;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(84,80,194,.25);
}

/* The five photos live on a real-looking clothesline. */
.cards-container,
.final-cards {
  position: relative;
  grid-template-columns: repeat(5, minmax(160px, 225px));
  justify-content: center;
  gap: 34px 25px;
  padding: 72px 24px 38px;
}

.cards-container {
  min-height: 610px;
}

.cards-container::before,
.final-cards::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 2%;
  right: 2%;
  top: 39px;
  height: 5px;
  border-radius: 50%;
  background:
    repeating-linear-gradient(90deg,
      rgba(122,83,49,.98) 0 8px,
      rgba(157,112,69,.98) 8px 15px,
      rgba(111,73,43,.98) 15px 22px);
  box-shadow: 0 3px 3px rgba(63,42,24,.22), 0 1px 0 rgba(255,239,214,.45) inset;
  transform: rotate(-1.1deg);
}

.cards-container::after,
.final-cards::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 3%;
  right: 3%;
  top: 44px;
  height: 2px;
  border-radius: 50%;
  background: rgba(86,56,34,.25);
  transform: rotate(-1.1deg);
}

.draft-card {
  --tilt: 0deg;
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: .72;
  border: 0;
  border-radius: 2px;
  padding: 12px 12px 22px;
  overflow: visible;
  background: #fffdf9;
  color: #25242a;
  box-shadow: 0 15px 24px rgba(65,49,32,.20), 0 3px 6px rgba(65,49,32,.12);
  transform: rotate(var(--tilt));
  transition: transform .18s ease, box-shadow .18s ease;
}

/* A wooden clothespin sits in front of the rope. */
.draft-card::before {
  content: "";
  position: absolute;
  z-index: 6;
  width: 29px;
  height: 57px;
  left: 50%;
  top: -25px;
  transform: translateX(-50%) rotate(-2deg);
  border-radius: 4px 4px 8px 8px;
  background:
    linear-gradient(90deg,
      #a87543 0%,
      #d5a96d 15%,
      #f0cf9b 43%,
      #d6aa6c 70%,
      #9c6839 100%);
  border: 1px solid rgba(112,72,37,.24);
  box-shadow: 1px 3px 5px rgba(60,40,20,.28);
  clip-path: polygon(0 0, 100% 0, 100% 76%, 70% 76%, 61% 100%, 39% 100%, 30% 76%, 0 76%);
}

.draft-card::after {
  content: "";
  position: absolute;
  z-index: 7;
  width: 19px;
  height: 5px;
  left: 50%;
  top: 7px;
  transform: translateX(-50%) rotate(-2deg);
  border-radius: 5px;
  background: rgba(115,75,39,.38);
  box-shadow: 0 8px 0 rgba(255,231,195,.35);
}

.draft-card:hover {
  transform: translateY(-10px) rotate(0deg) scale(1.025);
  box-shadow: 0 24px 38px rgba(65,49,32,.28), 0 4px 8px rgba(65,49,32,.14);
}

.cards-container .draft-card:nth-child(1) { --tilt: -2.4deg; }
.cards-container .draft-card:nth-child(2) { --tilt: 1.8deg; }
.cards-container .draft-card:nth-child(3) { --tilt: -.9deg; }
.cards-container .draft-card:nth-child(4) { --tilt: 2.3deg; }
.cards-container .draft-card:nth-child(5) { --tilt: -1.5deg; }

.final-cards .draft-card:nth-child(5n + 1) { --tilt: -2.1deg; }
.final-cards .draft-card:nth-child(5n + 2) { --tilt: 1.6deg; }
.final-cards .draft-card:nth-child(5n + 3) { --tilt: -.8deg; }
.final-cards .draft-card:nth-child(5n + 4) { --tilt: 2deg; }
.final-cards .draft-card:nth-child(5n + 5) { --tilt: -1.3deg; }

.card-photo {
  height: 73%;
  background: #ddd5ca;
  border: 1px solid #e8dfd4;
}

.card-photo img { object-fit: cover; }

.card-artist {
  height: 11%;
  min-height: 34px;
  padding: 7px 4px 0;
  background: transparent;
  color: #222127;
  font-size: clamp(13px, 1.45vw, 20px);
  letter-spacing: .5px;
}

.card-group {
  height: 7%;
  min-height: 22px;
  padding: 0 5px;
  background: transparent;
  color: #55515a;
  font-size: clamp(9px, 1vw, 13px);
}

.card-year {
  height: 6%;
  min-height: 20px;
  background: transparent;
  color: #77716a;
  font-size: clamp(9px, 1vw, 13px);
}

/* On-demand settings and help. */
.small-overlay {
  z-index: 120;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 82px 34px 24px;
  background: rgba(55,42,30,.16);
}

.small-modal {
  width: min(410px, 100%);
  padding: 25px;
  border-radius: 26px;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(92,77,59,.13);
  box-shadow: 0 28px 75px rgba(55,40,24,.25);
}

.settings-actions {
  display: grid;
  gap: 9px;
}

.settings-action {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 0;
  border-radius: 17px;
  background: #f5f0e8;
  color: #353139;
  text-align: left;
  transition: transform .15s ease, background .15s ease;
}

.settings-action:hover {
  background: #eee7dd;
  transform: translateX(-2px);
}

.settings-action-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(70,53,35,.10);
  font-size: 20px;
}

.settings-action strong,
.settings-action small {
  display: block;
}

.settings-action strong { font-size: 14px; margin-bottom: 3px; }
.settings-action small { color: #827b73; font-size: 12px; line-height: 1.35; }

.settings-action-danger {
  background: #f8e9e9;
  color: #8d3434;
}
.settings-action-danger:hover {
  background: #f2dada;
}
.settings-action-danger .settings-action-icon {
  color: #a13f3f;
  background: #fff7f7;
}

/* Long artist names stay on one line so the Polaroid proportions remain unchanged. */
.card-artist.long-name { font-size: clamp(11px, 1.15vw, 16px); letter-spacing: .25px; }
.card-artist.very-long-name { font-size: clamp(10px, 1vw, 14px); letter-spacing: 0; }

/* Setup/filter text uses the same light tone as the rest of the dark interface. */
.setup-panel h2,
.setup-panel label,
.setup-panel .setup-select,
.multi-option,
.multi-option-all { color: #e9e9ec; }
.multi-option:hover { color: #fff; }

.settings-instruction {
  margin-top: 18px;
  padding: 14px 15px;
  border-radius: 16px;
  background: #fbf8f3;
  color: #55504a;
  font-size: 13px;
  line-height: 1.5;
}

.settings-instruction p { margin: 5px 0 0; }

.choices-overlay { background: rgba(49,39,29,.64); }

.choices-modal {
  width: min(1080px, 100%);
  max-height: min(84vh, 820px);
  padding: 30px;
  border-radius: 28px;
  background: #f8f4ed;
  border: 1px solid rgba(90,70,45,.15);
  box-shadow: 0 30px 95px rgba(45,32,18,.44);
}

.choices-cards {
  grid-template-columns: repeat(5, minmax(125px, 165px));
  justify-content: center;
  gap: 24px 18px;
}

.choice-mini-card {
  aspect-ratio: .72;
  padding: 8px 8px 14px;
  border-radius: 1px;
}

.choice-mini-card::before,
.choice-mini-card::after { display: none; }

/* Final screen: same clothesline, five Polaroids maximum per row. */
.final-content {
  width: 100%;
}

.final-summary {
  text-align: center;
  margin: 2px 0 0;
  color: #81796f;
}

.final-cards {
  min-height: 0;
  margin-bottom: 8px;
}

.final-cards .draft-card {
  cursor: default;
}

.final-cards .draft-card:hover {
  transform: rotate(var(--tilt));
  box-shadow: 0 15px 24px rgba(65,49,32,.20), 0 3px 6px rgba(65,49,32,.12);
}

/* There is deliberately no large permanent action panel on the final page. */

@media (max-width: 1000px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }
  .phase-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    width: min(620px, 100%);
  }
  .cards-container,
  .final-cards {
    grid-template-columns: repeat(3, minmax(155px, 215px));
  }
}

@media (max-width: 680px) {
  .app { padding: 16px 14px 28px; }
  .topbar { gap: 12px; margin-bottom: 10px; }
  .brand-block h1 { font-size: 24px; }
  .icon-btn { width: 42px; height: 42px; }
  .phase-nav { min-height: 58px; padding: 8px 8px 8px 15px; }
  .phase-nav-title strong { font-size: 17px; }
  .phase-choice-btn { padding: 10px 14px; }

  .cards-container,
  .final-cards {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
    gap: 27px 13px;
    padding: 62px 3px 30px;
  }

  .cards-container { min-height: 0; }
  .cards-container::before,
  .final-cards::before { left: -2%; right: -2%; }
  .cards-container::after,
  .final-cards::after { left: -2%; right: -2%; }

  .draft-card { padding: 9px 9px 17px; }
  .draft-card::before { width: 25px; height: 51px; top: -23px; }
  .draft-card::after { top: 6px; }

  .choices-modal { padding: 19px; border-radius: 22px; }
  .choices-cards { grid-template-columns: repeat(2, minmax(105px, 145px)); gap: 17px 11px; }
  .small-overlay { padding: 70px 14px 14px; }
  .small-modal { width: 100%; padding: 20px; }
}

/* Final action remains a single calm capsule, separated from the board. */
.final-new-draft-btn {
  display: block;
  margin: 8px auto 0;
  border: 0;
  border-radius: 28px;
  padding: 13px 24px;
  background: #6966d8;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(84,80,194,.20);
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.final-new-draft-btn:hover {
  background: #5955c7;
  transform: translateY(-2px);
  box-shadow: 0 11px 24px rgba(84,80,194,.25);
}

/* Flex-wrap keeps incomplete rows visually centered (1–4 cards included). */
.choices-cards,
.final-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

.choices-cards .choice-mini-card,
.final-cards .draft-card {
  flex: 0 0 165px;
}

@media (max-width: 680px) {
  .choices-cards .choice-mini-card,
  .final-cards .draft-card {
    flex-basis: 145px;
  }
}

/* Each Polaroid contributes its own rope segment, allowing every wrapped row
   on the final screen to have its own clothesline. */
.cards-container::before,
.cards-container::after,
.final-cards::before,
.final-cards::after {
  display: none;
}

.card-rope {
  position: absolute;
  z-index: 0;
  left: -72px;
  right: -72px;
  top: -3px;
  height: 5px;
  border-radius: 50%;
  background:
    repeating-linear-gradient(90deg,
      rgba(122,83,49,.98) 0 8px,
      rgba(157,112,69,.98) 8px 15px,
      rgba(111,73,43,.98) 15px 22px);
  box-shadow: 0 3px 3px rgba(63,42,24,.22), 0 1px 0 rgba(255,239,214,.45) inset;
  transform: rotate(-1.1deg);
  pointer-events: none;
}

.draft-card > .card-photo,
.draft-card > .card-artist,
.draft-card > .card-group,
.draft-card > .card-year {
  position: relative;
  z-index: 1;
}

/* v4.7.1 — final screen: fixed Polaroid size and hard maximum of 5 per row.
   This intentionally matches the draft card width at each responsive breakpoint. */
.final-cards {
  width: min(100%, 1225px);
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  column-gap: 25px;
  row-gap: 34px;
}

.final-cards .draft-card {
  flex: 0 0 225px;
  width: 225px;
  max-width: 225px;
}

@media (max-width: 1000px) {
  .final-cards {
    width: min(100%, 950px);
  }
  .final-cards .draft-card {
    flex-basis: 215px;
    width: 215px;
    max-width: 215px;
  }
}

@media (max-width: 680px) {
  .final-cards {
    column-gap: 13px;
    row-gap: 27px;
    width: 100%;
  }
  .final-cards .draft-card {
    flex-basis: 145px;
    width: 145px;
    max-width: 145px;
  }
}
