/* VAR event page and admin tab (docs/tasks/2026-11-25-var-event.md). Loaded after app/brand styles;
   uses the shared tokens and rank palette passed inline, and honours reduced motion. */

.var-page { display: grid; gap: 18px; }
.var-heading { align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.var-clock { display: grid; gap: 2px; justify-items: end; min-width: 140px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.var-clock span { font-size: 12px; color: var(--muted); }
.var-count { font-size: 24px; font-variant-numeric: tabular-nums; color: var(--gold); }
.var-problem { margin: 0; }

.var-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.var-name label { font-weight: 600; }
.var-name input { flex: 1 1 180px; min-width: 0; min-height: 44px; }
.var-name .tiny { flex-basis: 100%; margin: 0; color: var(--muted); }

.var-match, .var-result { display: grid; gap: 12px; padding: 18px; border: 1px solid rgba(var(--accent-rgb), .45); border-radius: 14px; background: linear-gradient(160deg, rgba(var(--accent-rgb), .10), var(--surface) 55%); }
.var-match h2, .var-result h2 { margin: 0; font-size: 20px; }
.var-match-state, .var-outcome { margin: 0; }
.var-outcome { font-size: 18px; font-weight: 700; }
.var-result-win { border-color: #00ed79aa; }
.var-result-loss { border-color: #ff6b6b99; }

.var-hands { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.var-hand { display: grid; gap: 8px; justify-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #0b151e; min-width: 0; }
.var-hand.is-winner { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.var-hand-name { font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.var-vs { font-weight: 800; color: var(--gold); letter-spacing: .08em; }
.var-score { font-size: 20px; color: var(--gold); font-variant-numeric: tabular-nums; }
.var-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.var-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 10px; border-radius: 8px; border-top: 3px solid var(--rank); background: #ffffff0d;
  animation: var-flip .45s ease-out both; animation-delay: var(--delay, 0ms); }
.var-chip b { color: var(--rank); font-size: 13px; }
/* Drawn cards: picture framed in its rank colour, with rank, points and name. */
.var-card-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); width: 100%; }
.var-card-tile { position: relative; display: grid; align-content: start; gap: 4px; min-width: 0; margin: 0; text-align: center; }
.var-card-face { position: relative; display: block; aspect-ratio: 63 / 88; overflow: hidden; border: 2px solid var(--rank); border-radius: 8px; background: #0b151e; box-shadow: 0 6px 16px #0008; }
.var-card-face img { display: block; width: 100%; height: 100%; object-fit: cover; color: transparent; font-size: 0; }
.var-card-fallback { position: absolute; inset: 0; display: none; place-items: center; padding: 6px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.var-card-tile.no-image img { display: none; }
.var-card-tile.no-image .var-card-fallback { display: grid; }
.var-card-tile figcaption { min-width: 0; font-size: 12px; line-height: 1.3; }
.var-card-tile figcaption b { color: var(--rank); }
.var-card-tile figcaption small { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.var-card-tile.is-high .var-card-face { box-shadow: 0 0 0 1px var(--rank), 0 0 18px var(--rank); }

/* Shared reveal: both hands flip on one timeline from the server's end time (see varRevealTimeline). */
/* The app caps dialogs at 550px; the reveal needs room for two hands side by side. */
.var-reveal { width: min(1100px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); overflow-y: auto; }
.var-reveal-count { min-height: 1.4em; margin: 0 0 8px; color: var(--gold); font-size: 22px; font-weight: 800; text-align: center; }
.var-reveal-arena { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 12px; }
.var-reveal-arena > .var-vs { align-self: center; font-size: 22px; }
.var-reveal-side { display: grid; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #0b151e; }
.var-reveal-side header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.var-reveal-side header span { display: grid; color: var(--muted); font-size: 13px; }
.var-reveal-side header span b { color: var(--ink); font-size: 16px; overflow-wrap: anywhere; }
.var-reveal-score { color: var(--gold); font-size: 34px; font-variant-numeric: tabular-nums; }
.var-reveal-cards { display: grid; grid-template-columns: minmax(0, 220px); justify-content: center; gap: 8px; }
.var-reveal-cards.is-many { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.var-reveal-card { position: relative; perspective: 900px; }
.var-reveal-back { position: absolute; top: 0; right: 0; left: 0; aspect-ratio: 63 / 88; border: 1px solid var(--gold); border-radius: 8px;
  background: repeating-linear-gradient(135deg, #142331 0 8px, #0f1b26 8px 16px); backface-visibility: hidden; animation: var-reveal-hide .6s ease-in both; animation-delay: var(--delay); }
.var-reveal-front { backface-visibility: hidden; animation: var-reveal-show .6s ease-out both; animation-delay: var(--delay); }
.var-reveal-front.is-high .var-card-face { animation: var-reveal-glow 1.4s ease-out both; animation-delay: calc(var(--delay) + .5s); }
.var-reveal-outcome { margin: 14px 0 6px; font-size: 28px; font-weight: 800; text-align: center; animation: var-reveal-pop .5s ease-out both; }
.var-reveal-outcome.is-win { color: #00ed79; }
.var-reveal-outcome.is-loss { color: #ff6b6b; }
.var-reveal-outcome.is-even { color: var(--gold); }
.var-reveal.is-done .var-reveal-back { display: none; }
.var-reveal.is-done .var-reveal-front, .var-reveal.is-done .var-card-face { animation: none; }
#varReveal .var-actions { justify-content: center; margin-top: 10px; }
.var-reveal.is-done [data-var-reveal="skip"] { display: none; }

.var-card-back { width: 64px; height: 90px; border-radius: 8px; border: 1px solid var(--line);
  background: repeating-linear-gradient(135deg, #142331 0 8px, #0f1b26 8px 16px); }
.var-card-back.is-spinning { animation: var-pulse 1.1s ease-in-out infinite; }
.var-card-back.is-ready { border-color: var(--gold); }

/* How to play: four short steps, always visible. */
.var-howto { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.var-howto h2 { margin: 0 0 8px; font-size: 17px; }
.var-howto ol { display: grid; gap: 6px 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin: 0; padding: 0; list-style: none; }
.var-howto li { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--muted); }
.var-howto li b { color: var(--ink); }
.var-step { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #1a1405; font-size: 13px; font-weight: 800; }
.var-rules-link { display: inline-block; margin-top: 8px; color: var(--gold); font-size: 14px; }

/* Room choice: the player picks ×1 or ×10 before anything else. */
.var-picker h2 { margin: 0 0 8px; font-size: 17px; }
.var-room-picker { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.var-room-option { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 2px 12px; min-width: 0; padding: 10px 14px;
  border: 2px solid var(--line); border-radius: 14px; background: linear-gradient(150deg, #ffffff0d, var(--surface) 60%); color: inherit; font: inherit; text-align: left;
  cursor: pointer; transition: border-color .2s ease, box-shadow .2s ease; }
.var-room-option:hover { border-color: rgba(var(--accent-rgb), .6); }
.var-room-option:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.var-room-option.is-selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 12px 30px #0006; }
.var-room-option.is-blocked .var-room-option-state { color: #ff8f8f; }
.var-room-option-count { font-size: 30px; font-weight: 800; line-height: 1; color: var(--gold); }
.var-room-option-price { color: var(--ink); font-weight: 700; white-space: nowrap; }
.var-room-option-price small { margin-left: 2px; color: var(--muted); font-weight: 400; }
.var-room-option-state { grid-column: 1 / -1; color: var(--accent); font-size: 12px; }
.var-choose-hint { margin: 0; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
/* "Chi tiết" blocks: details the player opens when they want them. */
.var-details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.var-details > summary { display: flex; align-items: center; min-height: 44px; padding: 0 14px; cursor: pointer; font-weight: 600; list-style: none; }
.var-details > summary::-webkit-details-marker { display: none; }
.var-details > summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .2s ease; }
.var-details[open] > summary::after { transform: rotate(180deg); }
.var-details > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.var-details-body { padding: 0 14px 14px; }
.var-details-body .var-name { padding: 0; border: 0; background: none; }
.var-facts { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin: 0; }
.var-facts div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.var-facts dt { color: var(--muted); }
.var-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.var-room .var-details { background: #0b151e; }
.var-room { display: grid; gap: 10px; align-content: start; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); min-width: 0; }
.var-room header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; }
.var-room header h2 { margin: 0; font-size: 22px; }
.var-room header span { color: var(--gold); font-weight: 600; }
.var-room h3 { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.var-room-meta, .var-streak { margin: 0; color: var(--muted); }
.var-streak strong { color: var(--ink); font-size: 20px; }
.var-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.var-searching { margin: 0; color: var(--accent); }

/* Prize gallery: milestones in order, each with its cards as large pictures like the banner's Top Hit. */
.var-milestones { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 24px; margin: 0; padding: 0; list-style: none; }
.var-milestone-group { min-width: 0; max-width: 100%; }
.var-milestone-group h4 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 8px; font-size: 16px; }
.var-milestone-group h4 span { color: var(--gold); }
.var-milestone-group h4 small { color: var(--muted); font-size: 13px; font-weight: 400; }
.var-prize-grid { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 0; list-style: none; }
.var-prize-card { position: relative; display: grid; align-content: start; gap: 8px; width: 168px; max-width: 100%; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #0b151e; }
.var-prize-card.is-claimable { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 0 24px #f0c86e2e; }
.var-prize-card.is-taken .var-prize-art { filter: grayscale(.85); opacity: .6; }
.var-prize-art { display: block; width: 100%; padding: 0; border: 0; border-radius: 10px; background: none; line-height: 0; }
.var-prize-img.is-card { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 10px; box-shadow: 0 8px 22px #0009; }
.var-prize-placeholder { display: grid; place-content: center; justify-items: center; aspect-ratio: 63 / 88; border: 1px dashed var(--line); border-radius: 10px;
  background: repeating-linear-gradient(135deg, #142331 0 10px, #0f1b26 10px 20px); color: var(--gold); line-height: 1.1; }
.var-prize-placeholder b { font-size: 44px; }
.var-prize-placeholder small { color: var(--muted); }
.var-prize-badge { position: absolute; top: 16px; left: 16px; padding: 3px 10px; border: 1px solid var(--gold); border-radius: 999px; background: #000000cc; color: var(--gold); font-size: 13px; font-weight: 700; }
.var-prize-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.var-prize-text small { color: var(--muted); }
.var-prize-card em { font-style: normal; font-size: 13px; color: var(--muted); }
.var-prize-card.is-claimable em { color: var(--gold); font-weight: 600; }
.var-prize-card .button { justify-self: stretch; }
.var-blocked { margin: 0; padding: 10px 12px; border: 1px solid #ff6b6b55; border-radius: 10px; background: #ff6b6b14; }
.var-queue { min-width: min(100%, 240px); }
.var-prize { display: flex; align-items: center; gap: 10px; min-width: 0; }
.var-prize > span { min-width: 0; overflow-wrap: anywhere; }
.var-prize-img { flex: none; width: 46px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); }
.var-prize-img.is-large { width: min(180px, 46vw); border-radius: 10px; }
.var-prize-img.is-zoom { width: min(360px, 76vw); border-radius: 12px; }
.var-prize-zoom { flex: none; padding: 0; border: 0; border-radius: 6px; background: none; line-height: 0; cursor: zoom-in; }
.var-prize-zoom:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.var-prize-zoom-dialog { width: min(440px, calc(100vw - 32px)); }
.var-claim-prize { display: grid; justify-items: center; margin: 4px 0 8px; }
.var-claims li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; }

.var-board { display: grid; gap: 4px; margin: 0; padding-left: 22px; }
.var-board li span { overflow-wrap: anywhere; }
.var-board li b { margin-left: 8px; color: var(--gold); }
.var-board li small { margin-left: 6px; color: var(--muted); }
.var-claims { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.var-claims h2 { margin: 0 0 6px; font-size: 18px; }
.var-rules > summary h2 { margin: 0; font-size: 17px; scroll-margin-top: 90px; }
.var-rules .var-details-body h3 { margin: 14px 0 6px; font-size: 15px; color: var(--gold); }
.var-rules ul { display: grid; gap: 6px; margin: 0; padding-left: 20px; line-height: 1.5; }
.var-rules ul.var-points { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0; list-style: none; }
.var-points li { display: flex; align-items: center; gap: 6px; }
.var-points .var-chip { animation: none; }
#varClaimDialog .var-actions { margin-top: 12px; }

.var-admin { display: grid; gap: 14px; }
.var-admin-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.var-admin-head h2 { margin: 0 auto 0 0; }
.var-admin-form { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.var-admin-form h3 { margin: 0; }
.var-admin-times, .var-admin-estimate-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); align-items: end; }
.var-admin-room { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.var-admin-room legend { padding: 0 6px; }
.var-admin-room legend .checkbox-line { margin: 0; font-size: 15px; font-weight: 600; }
.var-admin-milestone { display: grid; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.var-admin-milestone-head { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 10px; }
.var-admin-milestone-head .var-admin-streak { width: 90px; }
.var-admin-milestone-head .tiny { flex: 1 1 200px; margin: 0; color: var(--muted); }
.var-admin-card { display: grid; gap: 8px 10px; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); align-items: end; padding-top: 10px; border-top: 1px dashed var(--line); }
.var-admin-prize-thumb { grid-row: span 2; align-self: start; display: grid; place-items: center; width: 64px; aspect-ratio: 63 / 88; overflow: hidden; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; text-align: center; }
.var-admin-prize-thumb img { width: 100%; height: 100%; object-fit: cover; }
.var-admin-prize-actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.var-admin-prize-actions small { color: var(--muted); }
.var-admin-upload { position: relative; cursor: pointer; }
.var-admin-upload:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.var-admin-claim-prize { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--muted); }
.var-admin-claim-prize img { width: 32px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 4px; }
.var-prize-picker { width: min(720px, calc(100vw - 32px)); max-width: none; }
.var-prize-picker label { display: grid; gap: 6px; }
.var-prize-results { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); max-height: min(60vh, 520px); overflow-y: auto; padding: 2px; }
.var-prize-option { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit; text-align: left; cursor: pointer; font: inherit; }
.var-prize-option:hover, .var-prize-option:focus-visible { border-color: var(--gold); }
.var-prize-option img, .var-prize-noimage { flex: none; width: 44px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 5px; }
.var-prize-noimage { display: grid; place-items: center; border: 1px dashed var(--line); color: var(--muted); font-size: 10px; text-align: center; }
.var-prize-option span { min-width: 0; overflow-wrap: anywhere; }
.var-prize-option small { display: block; color: var(--muted); }
.var-admin-estimate, .var-admin-claims { width: 100%; border-collapse: collapse; font-size: 14px; }
.var-admin-estimate th, .var-admin-estimate td, .var-admin-claims th, .var-admin-claims td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.var-admin-event header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; }
.var-admin-event header h3 { margin: 0; }
.var-admin-status { color: var(--gold); }
.var-admin-claims input { min-height: 36px; margin: 4px 0; max-width: 100%; }

@media (max-width: 600px) {
  .var-hands { grid-template-columns: minmax(0, 1fr); }
  .var-reveal-arena { grid-template-columns: minmax(0, 1fr); }
  .var-reveal-arena > .var-vs { justify-self: center; }
  .var-reveal-cards { grid-template-columns: minmax(0, 150px); }
  .var-reveal-cards.is-many { gap: 5px; }
  .var-reveal-score { font-size: 28px; }
  .var-card-tile figcaption { font-size: 10px; }
  .var-card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .var-vs { justify-self: center; }
  .var-clock { justify-items: start; }
  .var-room-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .var-room-option { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px 12px; }
  .var-room-option-count { font-size: 26px; }
  .var-milestones { gap: 14px 12px; }
  .var-prize-grid { gap: 10px; }
  .var-prize-card { width: 146px; padding: 8px; }
  .var-prize-badge { top: 14px; left: 14px; font-size: 12px; }
  .var-howto ol { grid-template-columns: minmax(0, 1fr); }
  .var-admin-card { grid-template-columns: 64px minmax(0, 1fr); }
  .var-admin-prize-name, .var-admin-prize-note { grid-column: 2; }
  .var-admin-prize-actions { grid-column: 1 / -1; }
  .var-admin-claims thead { display: none; }
  .var-admin-claims tr, .var-admin-claims td { display: block; }
}

@keyframes var-reveal-show { 0% { opacity: 0; transform: rotateY(180deg) scale(.92); } 50% { opacity: 0; } 51% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes var-reveal-hide { 0% { opacity: 1; transform: none; } 50% { opacity: 1; } 51% { opacity: 0; } 100% { opacity: 0; transform: rotateY(-180deg); } }
@keyframes var-reveal-glow { 0% { box-shadow: 0 0 0 1px var(--rank); } 35% { box-shadow: 0 0 0 3px var(--rank), 0 0 42px var(--rank); transform: scale(1.06); } 100% { box-shadow: 0 0 0 1px var(--rank), 0 0 18px var(--rank); transform: none; } }
@keyframes var-reveal-pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
@keyframes var-flip { from { opacity: 0; transform: rotateY(90deg) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes var-pulse { 50% { opacity: .55; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) {
  .var-chip, .var-card-back.is-spinning { animation: none; }
  .var-room-option { transition: none; }
  .var-reveal-back { display: none; }
  .var-reveal-front, .var-reveal-front .var-card-face, .var-reveal-outcome { animation: none; }
}
.slow-mode .var-chip, .slow-mode .var-card-back.is-spinning, .slow-mode .var-reveal-front, .slow-mode .var-reveal-front .var-card-face, .slow-mode .var-reveal-outcome { animation: none; }
.slow-mode .var-reveal-back { display: none; }
