/* Match Point Down (tennis) */
:root { --page-tint: #173a1a; --ball: #d9f99d; }
#app { max-width: 820px; margin: 0 auto; padding: 14px 14px 40px; }

/* ---------- Menu ---------- */
.hero { text-align: center; padding: 18px 8px 8px; }
.hero h1 {
  font-family: var(--display); font-size: clamp(2.8rem, 10vw, 4.8rem);
  text-transform: uppercase; letter-spacing: 2px; margin: 8px 0 6px; text-shadow: 0 4px 0 rgba(0, 0, 0, .35);
}
.hero h1 span { color: var(--ball); }
.hero-sub { color: var(--muted); max-width: 520px; margin: 0 auto 6px; line-height: 1.45; }
.hero-date { font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: .85rem; color: var(--gold); }
.led-board {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 14px;
  background: #050608; border: 3px solid #2a2f38; border-radius: 8px; box-shadow: 0 0 0 2px #000, var(--shadow);
  font-family: var(--led); font-weight: 700;
}
.led-label { font-size: .7rem; letter-spacing: 2px; text-transform: uppercase; color: #9aa4b2; }
.led-num { font-size: 1.8rem; color: var(--led-amber); text-shadow: 0 0 10px rgba(255, 176, 0, .9); }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 18px; }
.mode-card {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; padding: 18px;
  border-radius: var(--radius); border: 2px solid rgba(255, 255, 255, .1);
  background:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, .12) 49% 51%, transparent 51%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 24px, transparent 24px 48px),
    linear-gradient(160deg, #3f8a35, #1f5a1c);
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
@media (hover: hover) and (pointer: fine) { .mode-card:hover { transform: translateY(-3px); border-color: var(--gold); } }
.mode-card[data-surface="clay"] { background: linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, .12) 49% 51%, transparent 51%), linear-gradient(160deg, #c8653a, #8a3a1c); }
.mode-card[data-surface="hard-ao"] { background: linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, .12) 49% 51%, transparent 51%), linear-gradient(160deg, #2f6fbd, #173e72); }
.mode-card[data-surface="hard-uso"] { background: linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, .12) 49% 51%, transparent 51%), linear-gradient(160deg, #3e69b0, #2c5b3e); }
.mode-card.practice { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 14px), repeating-linear-gradient(-45deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 14px), linear-gradient(160deg, #3b3f4a, #1b1d23); }
.mode-card.played { opacity: .85; }
.mode-tag { font-size: .7rem; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.mode-title { font-family: var(--display); font-size: 1.6rem; letter-spacing: 1px; text-transform: uppercase; }
.mode-teaser { color: #e6efe6; font-size: .92rem; line-height: 1.4; min-height: 2.8em; }
.mode-status { margin-top: auto; font-weight: 700; color: var(--gold); }

.stats-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--panel); border: 2px solid rgba(255, 255, 255, .1);
}
.stats-strip span:first-child { font-weight: 700; }
.stats-strip span:last-child { color: var(--muted); }
.stats-strip strong { color: var(--gold); }

.flag-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px 18px; border-radius: var(--radius);
  background: var(--panel); border: 2px solid rgba(255, 255, 255, .1); font-weight: 700;
}
.flag-strip select {
  font: inherit; font-weight: 700; color: inherit; background: var(--panel-2); border: 2px solid rgba(255, 255, 255, .15);
  border-radius: 10px; padding: 8px 10px; max-width: 100%;
}

/* ---------- Tiebreak board ---------- */
.tb-board {
  display: grid; grid-template-columns: 1fr auto; align-items: stretch; border-radius: 12px; overflow: hidden;
  background: #050608; border: 3px solid #22262e; box-shadow: 0 0 0 2px #000, var(--shadow); margin: 2px 0 8px;
}
.tb-board.mp-them { border-color: #b91c1c; }
.tb-board.mp-us { border-color: var(--gold); }
.tb-rows { display: flex; flex-direction: column; min-width: 0; }
.tb-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; font-weight: 800; }
.tb-row + .tb-row { border-top: 1px solid rgba(255, 255, 255, .08); }
.tb-row .serve { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--ball); box-shadow: 0 0 6px var(--ball); visibility: hidden; }
.tb-row.serving .serve { visibility: visible; }
.tb-row .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-row .sets { font-family: var(--led); color: #9fb3cc; letter-spacing: 3px; white-space: nowrap; }
.tb-row .pts { font-family: var(--led); font-size: 1.5rem; color: var(--led-amber); min-width: 2ch; text-align: right; text-shadow: 0 0 6px rgba(255, 176, 0, .6); }
.tb-side {
  display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 12px; background: #13263d;
  font-weight: 800; font-size: .7rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); text-align: center; line-height: 1.3;
}
.mp-them .tb-side { background: #7f1d1d; color: #fff; animation: pulse 1s infinite; }
.mp-us .tb-side { background: #4a3a10; }
.match-ctx { margin: 0; color: var(--muted); font-size: .85rem; font-weight: 700; text-align: center; }
.tb-track { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin: 8px 0; min-height: 14px; }
.tb-track i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .15); animation: pop .3s ease-out; }
.tb-track i.w { background: var(--good); }
.tb-track i.l { background: var(--bad); }
.tb-track i.a { background: var(--gold); }
.tb-track i.now { background: transparent; border: 2px solid #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.4); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Court ---------- */
.court-wrap { max-width: min(100%, calc(38vh * 1000 / 480)); margin: 0 auto; position: relative; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); border: 3px solid #1b2433; background: #2f6f2a; }
#court { display: block; width: 100%; height: auto; }
.court-wrap:has(#court[data-surface="clay"]) { background: #b5552f; }
.court-wrap:has(#court[data-surface="hard-ao"]) { background: #1f4f8f; }
.court-wrap:has(#court[data-surface="hard-uso"]) { background: #3f7a52; }

.court-banner {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(5, 10, 20, .55); text-align: center; padding: 10px; pointer-events: none;
}
.court-banner.gold { background: radial-gradient(circle, rgba(255, 210, 63, .25), rgba(5, 10, 20, .65) 70%); }
.court-banner.bad { background: radial-gradient(circle, rgba(239, 68, 68, .3), rgba(30, 5, 5, .7) 70%); }
.court-banner.pop > * { animation: pop .35s ease-out both; }
.court-banner.pop > *:nth-child(2) { animation-delay: .1s; }
.court-banner.pop > *:nth-child(3) { animation-delay: .2s; }
.bn-big {
  font-family: var(--display); font-size: clamp(2.6rem, 11vw, 5.4rem); color: var(--gold); letter-spacing: 3px; line-height: 1;
  text-shadow: 0 0 18px rgba(255, 210, 63, .5), 0 3px 0 #000;
}
.bn-big.sm { font-size: clamp(1.6rem, 6vw, 2.8rem); color: var(--chalk); text-shadow: 0 3px 0 rgba(0, 0, 0, .5); }
.bn-big.bad { color: #ff6b6b; text-shadow: 0 0 18px rgba(239, 68, 68, .6), 0 3px 0 #000; }
.bn-small { font-weight: 700; font-size: clamp(.85rem, 2.6vw, 1.1rem); margin: 6px 0; max-width: 520px; }
.bn-ans { font-weight: 700; color: var(--gold); margin-top: 6px; font-size: clamp(.85rem, 2.6vw, 1.05rem); }

/* ---------- Choices and questions ---------- */
.question-panel {
  margin-top: 12px; background: var(--panel); border-radius: var(--radius); padding: 14px 16px 16px;
  border: 1px solid rgba(255, 255, 255, .1); box-shadow: var(--shadow); animation: pop .25s ease-out;
}
.pips { letter-spacing: 1px; }
.pips.d1 { color: var(--good); } .pips.d2 { color: #facc15; } .pips.d3 { color: #f43f5e; }

/* ---------- Questions ---------- */
.q-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.q-stage { color: var(--gold); }
.q-diff { color: var(--muted); }
.timer { height: 6px; background: rgba(255, 255, 255, .12); border-radius: 3px; overflow: hidden; margin: 10px 0 4px; }
.timer-fill { height: 100%; width: 100%; background: var(--good); }
.timer-fill.warn { background: var(--bad); }
.timer.off { visibility: hidden; }
.answer.choice strong { display: block; font-size: 1.02rem; }
.answer.choice small { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; line-height: 1.3; font-weight: 600; }
.answer.choice.big { border-color: rgba(255, 210, 63, .55); }
.q-text { font-size: clamp(1.05rem, 2.8vw, 1.3rem); font-weight: 700; line-height: 1.35; margin: 10px 0 14px; min-height: 2.7em; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--panel-2); border: 2px solid rgba(255, 255, 255, .12);
  transition: transform .1s, border-color .15s, background .2s;
}
@media (hover: hover) and (pointer: fine) { .answers:not(.fresh) .answer:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); } }
.answer:disabled { cursor: default; }
.answer-key {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .12); font-size: .8rem; font-weight: 800;
}
.answer.correct { background: #166534; border-color: var(--good); animation: pop .3s; }
.answer.wrong { background: #7f1d1d; border-color: var(--bad); animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Result ---------- */
.result-card {
  margin: 20px auto; max-width: 560px; text-align: center; padding: 28px 22px;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); border: 2px solid rgba(255, 255, 255, .12);
}
.result-card.won { border-color: var(--gold); background: linear-gradient(180deg, #4a3a10, var(--panel) 60%); }
.result-emoji { font-size: 4rem; line-height: 1; animation: pop .5s ease-out both; }
.result-title { font-family: var(--display); font-size: clamp(1.9rem, 7vw, 2.8rem); text-transform: uppercase; letter-spacing: 1px; margin: 10px 0 6px; }
.won .result-title { color: var(--gold); }
.result-sub { color: #dce6f2; font-weight: 700; margin: 0 0 6px; }
.result-score { color: var(--muted); font-family: var(--led); font-weight: 700; margin: 0; }
.result-grid { font-size: 1.4rem; line-height: 1.4; margin: 14px 0; font-family: inherit; white-space: pre-wrap; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.result-next { color: var(--muted); font-size: .9rem; margin-top: 16px; }

/* ---------- Phone ---------- */
@media (max-width: 560px) {
  #app { padding: 10px 10px 32px; }
  .answers { grid-template-columns: 1fr; }
  .tb-row { padding: 6px 10px; gap: 8px; font-size: .92rem; }
  .tb-row .pts { font-size: 1.3rem; }
  .tb-row .sets { letter-spacing: 2px; }
  .tb-side { font-size: .6rem; padding: 0 8px; }
}
