/* Devine le parti — styles */

:root {
  --bg:        #f4f4f7;
  --surface:   #ffffff;
  --text:      #111114;
  --muted:     #6b6b75;
  --hairline:  #e7e7ec;
  --good:      #1a7f3a;
  --bad:       #c92a2a;
  --shadow:    0 1px 2px rgba(15,15,30,.04), 0 10px 30px rgba(15,15,30,.06);
  --radius-lg: 18px;
  --radius-md: 11px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ----- top bar ----- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--hairline);
  padding: .85rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.012em;
}
.logo .nav {
  margin-left: .55rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .02em;
}
.logo .nav:hover { color: var(--text); }

.score { display: flex; align-items: center; gap: 1.1rem; }
.metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}
.metric span {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 700;
}
.metric b {
  margin-top: 3px;
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform .25s cubic-bezier(.2,.7,.2,1);
}
.metric b.pop { transform: scale(1.18); }

.metric-rank b { color: #b07900; }

.ghost {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  padding: .35rem .65rem;
  border-radius: 7px;
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: #cfcfd6; }

@media (max-width: 640px) {
  .score    { gap: .55rem; }
  .topbar   { padding: .65rem .75rem; flex-wrap: wrap; }
  .metric span { font-size: .6rem; }
  .metric b    { font-size: .92rem; }
  /* On small screens keep score + streak + best + share, hide the rest. */
  .metric-rank,
  #m-reset,
  #m-name { display: none; }
  .ghost  { padding: .3rem .55rem; font-size: .72rem; }
  .logo   { font-size: .98rem; }
  .logo .nav { font-size: .72rem; }
}

/* ----- main column ----- */

.page {
  max-width: 540px;
  margin: 0 auto;
  padding: 1.4rem 1rem 4rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(180deg, #ececef, #e4e4e9);
  overflow: hidden;
}

.portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .35s ease;
}
.portrait.shown { opacity: 1; }

.caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1rem 1.15rem 1.1rem;
  background: linear-gradient(to top, rgba(0,0,0,.78) 25%, rgba(0,0,0,0));
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s ease;
  pointer-events: none;
}
.caption.visible { opacity: 1; transform: none; }
.who  { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; }
.meta { margin-top: .15rem; font-size: .92rem; opacity: .92; }

/* ----- party buttons ----- */

.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
  padding: .75rem;
}

.party {
  position: relative;
  padding: .9rem .65rem;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 800;
  color: var(--ink, #fff);
  background: var(--c, #888);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  letter-spacing: .005em;
  text-shadow: 0 1px 0 rgba(0,0,0,.06);
  transition: transform .08s, opacity .2s, filter .2s;
}
.party:hover:not(:disabled)  { filter: brightness(1.06); }
.party:active:not(:disabled) { transform: scale(.97); }
.party:disabled              { cursor: default; opacity: .25; filter: grayscale(.35); }

.party.was-correct,
.party.was-wrong { opacity: 1; filter: none; }

.party.was-correct::after,
.party.was-wrong::after {
  content: "";
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font: 700 13px/1 system-ui;
  color: #fff;
  border: 2px solid var(--surface);
}
.party.was-correct::after { content: "✓"; background: var(--good); }
.party.was-wrong::after   { content: "✕"; background: var(--bad); }

@media (min-width: 640px) {
  .choices { grid-template-columns: repeat(3, 1fr); }
  .party { font-size: .85rem; padding: .8rem .55rem; }
}

/* ----- countdown bar ----- */

.bar {
  height: 3px;
  background: var(--text);
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
}
.bar.run {
  opacity: 1;
  animation: drain var(--ms, 1800ms) linear forwards;
}
@keyframes drain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ----- hint and recent list ----- */

.hint {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  margin: 1.2rem 0 0;
}

.recent { margin-top: 2.4rem; }
.recent h2 {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 .7rem;
  padding: 0 .25rem;
}
.recent ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.entry {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--surface);
  padding: .55rem .8rem;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  animation: slip .25s ease;
}
@keyframes slip {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.entry .thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #ececef;
  object-fit: cover;
  flex: 0 0 auto;
}
.entry .lines { flex: 1 1 auto; min-width: 0; }
.entry .nm    { font-weight: 700; font-size: .94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .sub   { font-size: .8rem; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .badge {
  width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center;
  font: 700 13px/1 system-ui; color: #fff;
  flex: 0 0 auto;
}
.entry.ok  .badge { background: var(--good); }
.entry.no  .badge { background: var(--bad); }
.entry.ok  .badge::before { content: "✓"; }
.entry.no  .badge::before { content: "✕"; }

/* ----- crowd breakdown ----- */

.crowd {
  border-top: 1px solid var(--hairline);
  padding: .9rem 1rem 1.05rem;
  animation: slip .3s ease;
}
.crowd-title {
  margin: 0 0 .65rem;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: .45rem;
}
.crowd-count {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: #b3b3bb;
}
.crowd-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.cb {
  display: grid;
  grid-template-columns: 130px 1fr 42px;
  align-items: center;
  gap: .55rem;
  font-size: .82rem;
}
.cb-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--text);
}
.cb-track {
  position: relative;
  height: 8px;
  background: #f0f0f3;
  border-radius: 99px;
  overflow: hidden;
}
.cb-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  transition: width .55s cubic-bezier(.2,.8,.2,1);
}
.cb-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  color: var(--muted);
}
.cb-actual .cb-name { color: var(--good); }
.cb-actual .cb-name::after {
  content: " ✓";
  font-weight: 800;
}
.cb-actual .cb-pct { color: var(--good); }

/* ----- scoreboard (top runs) ----- */

.board { margin-top: 2.4rem; }
.board h2 {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 .7rem;
  padding: 0 .25rem;
  display: flex;
  align-items: baseline;
  gap: .6rem;
}
.board h2 .board-more {
  margin-left: auto;
  font-size: .72rem;
  text-transform: none;
  letter-spacing: .02em;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}
.board h2 .board-more:hover { color: var(--text); }
.board ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.board .run {
  display: grid;
  grid-template-columns: 38px 1fr auto auto;
  align-items: baseline;
  gap: .55rem;
  padding: .55rem .85rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
}
.board .run.me {
  background: #fff5d6;
  border-color: #ead992;
}
.board .run-rank {
  font-size: .8rem;
  font-weight: 800;
  color: var(--muted);
}
.board .run.me .run-rank { color: #856700; }
.board .run-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board .run-len {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -.01em;
}
.board .run-label {
  color: var(--muted);
  font-size: .82rem;
}
.board .run-when {
  color: var(--muted);
  font-size: .78rem;
}
.board-me {
  margin: .7rem .25rem 0;
  font-size: .82rem;
  color: var(--muted);
}

/* used on the stats page scoreboard rows */
.rank {
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: .2rem;
}
.muted { color: var(--muted); font-weight: 500; margin-left: .35rem; }

/* ----- modal (name picker) ----- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,15,30,.55);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1rem;
  animation: fade .2s ease;
}
@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal[hidden] { display: none; }

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.4rem 1.4rem 1.2rem;
  width: min(420px, 100%);
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  animation: rise .25s cubic-bezier(.2,.7,.2,1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-x {
  position: absolute;
  top: .55rem;
  right: .8rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.modal-x:hover { color: var(--text); }

.modal-title {
  margin: 0 0 .3rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.01em;
}
.modal-lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}
.modal-input {
  width: 100%;
  padding: .7rem .85rem;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  background: #fbfbfd;
}
.modal-input:focus {
  outline: 2px solid #b6c8e8;
  border-color: transparent;
  background: #fff;
}
.modal-actions {
  margin-top: 1rem;
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}
.btn-primary {
  background: var(--text);
  color: #fff;
  border: 0;
  padding: .55rem 1rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }

/* ----- toast ----- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 14px);
  background: #15151a;
  color: #fff;
  padding: .65rem 1.05rem;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 700;
  letter-spacing: .005em;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ----- footer ----- */

.legal {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
  font-size: .73rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
