/* Rang Badal — a durrie mat on a festival night, cards in four bright colours. */
:root {
  --desk: #141721; --panel: #20253a; --panel-2: #2a3049; --line: #363d5c; --ink: #f5f3ff; --muted: #a9abc6;
  --orange: #ff9a3c; --pink: #f04fa8; --violet: #8b5cf6; --teal: #2fd4c8; --acc: #2f7fd8;
  --grad: linear-gradient(100deg, var(--orange), var(--pink) 50%, var(--violet));
  --display: "Outfit", "Trebuchet MS", system-ui, sans-serif; --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --cw: 64px; --ch: 90px; --pw: 80px; --ph: 112px; --cur: #2f7fd8;
  color-scheme: dark;
}
@media (min-width: 700px) { :root { --cw: 84px; --ch: 118px; --pw: 104px; --ph: 146px; } }
@media (max-width: 699px) and (min-height: 760px) { :root { --cw: 74px; --ch: 104px; --pw: 92px; --ph: 129px; } }
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: radial-gradient(80% 45% at 50% 0%, rgba(47, 127, 216, .14), transparent 70%), var(--desk); color: var(--ink); font-family: var(--body); font-size: 16px; -webkit-tap-highlight-color: transparent; min-height: 100vh; -webkit-user-select: none; user-select: none; overflow-x: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 10px; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
p { margin: 0; }
svg { display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 999px; font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(240, 79, 168, .28); }
.btn.teal { background: var(--teal); color: #08221f; }
.btn.ghost { border: 2px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- playing ---------- */
.play { max-width: 980px; margin: 0 auto; padding: 8px 12px 6px; display: flex; flex-direction: column; gap: 8px; min-height: calc(100svh - var(--kd-h, 68px) - env(safe-area-inset-bottom, 0px)); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bar-t { display: flex; flex-direction: column; min-width: 0; }
.bar-t b { font-family: var(--display); font-size: 22px; font-weight: 800; background: linear-gradient(100deg, #ff8a1f, #2f7fd8 35%, #22a45a 65%, #e63d96); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bar-t span { color: var(--muted); font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.opps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.opp { position: relative; width: calc((100% - 16px) / 3); max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 7px; border-radius: 16px; background: var(--panel); border: 2px solid var(--line); transition: border-color .2s, transform .2s; }
.opps.n1 .opp { width: auto; min-width: 160px; flex-direction: row; gap: 10px; padding: 8px 14px; }
.opps.n1 .opp .oinfo { align-items: flex-start; }
.opp .av { position: relative; width: 40px; height: 40px; flex: none; }
.opp .av svg { width: 100%; height: 100%; }
@media (max-width: 699px) { .opp .av { width: 34px; height: 34px; } .opp { padding: 6px 4px 5px; gap: 2px; } }
.opp .av svg { position: relative; z-index: 1; }
.opp.turn { border-color: var(--oc); transform: translateY(-2px); }
.opp.turn .av::before { content: ""; position: absolute; inset: -5px; border-radius: 50%; background: conic-gradient(var(--oc), transparent 40%, var(--oc) 70%, transparent); animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.opp .oinfo { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; }
.opp .oname { font-weight: 800; font-size: 13px; line-height: 1.15; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp .ocnt { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; color: var(--muted); }
.opp .backs { display: flex; height: 18px; }
.opp .backs i { width: 12px; height: 17px; border-radius: 3px; background: linear-gradient(135deg, #7a4fe0, #3a1f8a); border: 1px solid #ffd23c; margin-left: -7px; box-shadow: 1px 0 2px rgba(0,0,0,.4); }
.opp .backs i:first-child { margin-left: 0; }
.opp.low .ocnt b { color: #ffd23c; }
.opp .tag { position: absolute; top: -9px; right: -4px; font-size: 11px; font-weight: 900; padding: 2px 7px; border-radius: 999px; background: #ffd23c; color: #141721; white-space: nowrap; z-index: 2; }
.opp .bot { font-size: 10.5px; color: var(--muted); font-weight: 800; }
.opp.hit { animation: hit .5s; }
@keyframes hit { 30% { transform: translateX(-5px) rotate(-2deg); } 60% { transform: translateX(5px) rotate(2deg); } }

.order { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; color: var(--muted); min-height: 20px; }
.order .arw { display: inline-flex; gap: 2px; }
.order .arw i { width: 8px; height: 8px; border-top: 3px solid var(--teal); border-right: 3px solid var(--teal); transform: rotate(45deg); animation: chev 1.2s ease-in-out infinite; }
.order .arw i:nth-child(2) { animation-delay: .15s; } .order .arw i:nth-child(3) { animation-delay: .3s; }
.order.back .arw { transform: scaleX(-1); }
@keyframes chev { 50% { opacity: .25; } }

.table { margin-top: auto; position: relative; display: flex; justify-content: center; align-items: flex-start; gap: clamp(18px, 7vw, 56px); padding: 18px 0 10px; }
.table::before { content: ""; position: absolute; left: 50%; top: 4px; width: min(100%, 420px); height: calc(var(--ph) + 46px); transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(139, 92, 246, .22), rgba(139, 92, 246, .06) 70%, transparent), repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 210, 60, .06) 0 6deg, transparent 6deg 12deg); z-index: -1; }
.pilebox { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile { position: relative; width: var(--pw); height: var(--ph); }
.pile .cs, .hcard .cs, .fc .cs { width: 100%; height: 100%; }
.cardbox { position: absolute; inset: 0; border-radius: 12px; }
.deck .stack { position: absolute; inset: 0; border-radius: 12px; background: #3a1f8a; transform: translate(4px, 4px); box-shadow: 2px 2px 0 #2a165f, 0 10px 20px rgba(0,0,0,.4); }
.deck .cnt { position: absolute; right: -8px; bottom: -8px; z-index: 2; background: var(--panel); border: 2px solid var(--line); border-radius: 999px; font-size: 12px; padding: 1px 7px; }
.deck.go .cardbox { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-6px); filter: drop-shadow(0 0 12px rgba(255, 210, 60, .8)); } }
.deck:disabled { cursor: default; }
.disc { border-radius: 12px; box-shadow: 0 0 0 4px var(--cur), 0 0 34px color-mix(in srgb, var(--cur) 70%, transparent); transition: box-shadow .3s; }
.disc .cs { filter: drop-shadow(0 8px 14px rgba(0,0,0,.45)); }
.disc .under { position: absolute; inset: 0; transform: rotate(-8deg); opacity: .55; }
.plab { font-size: 13px; font-weight: 800; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; min-height: 26px; }
.plab.colour { color: #fff; background: var(--cur); padding: 3px 12px 3px 8px; border-radius: 999px; transition: background .3s; }

.msg { text-align: center; font-weight: 800; color: #d8d7ee; min-height: 22px; padding: 0 4px; }
.msg b { color: #ffd23c; }
.actions { display: flex; justify-content: center; gap: 10px; min-height: 0; }
.actions .btn { min-height: 44px; font-size: 15px; padding: 8px 18px; }

.hand-wrap { margin-top: auto; overflow-x: auto; overflow-y: hidden; padding: 24px 2px 6px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.hand { position: relative; height: calc(var(--ch) + 18px); margin: 0 auto; }
.hcard { position: absolute; left: 0; bottom: 14px; width: var(--cw); height: var(--ch); border-radius: 10px; transform: translate(var(--x), var(--y, 0px)) rotate(var(--r, 0deg)); transform-origin: 50% 130%; transition: transform .25s cubic-bezier(.3, 1.4, .5, 1), filter .2s; box-shadow: -3px 4px 10px rgba(0,0,0,.35); }
.hcard.ok { --y: -18px; box-shadow: -3px 4px 10px rgba(0,0,0,.35), 0 0 0 3px #ffd23c, 0 0 18px rgba(255, 210, 60, .55); }
.hand.mine .hcard.no { filter: brightness(.62) saturate(.75); }
.hcard.drawn { --y: -22px; box-shadow: 0 0 0 3px #2fd4c8, 0 0 22px rgba(47, 212, 200, .8); }
.hcard.new { animation: deal .35s ease-out; }
@keyframes deal { from { opacity: 0; } }
.hcard.shake { animation: cshake .35s; }
@keyframes cshake { 25% { margin-left: -6px; } 75% { margin-left: 6px; } }
@media (hover: hover) { .hand.mine .hcard.ok:hover { --y: -26px; } }

.fly { position: fixed; inset: 0; pointer-events: none; z-index: 950; }
.fc { position: fixed; left: 0; top: 0; border-radius: 10px; will-change: transform; filter: drop-shadow(0 10px 18px rgba(0,0,0,.5)); }
.ek { position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 960; pointer-events: none; text-align: center; animation: ekpop 1.6s ease-out both; }
.ek b { display: block; font-family: var(--display); font-weight: 800; font-size: clamp(44px, 12vw, 80px); line-height: 1; background: linear-gradient(100deg, #ffd23c, #ff8a1f 40%, #f04fa8); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 18px rgba(0,0,0,.6)); white-space: nowrap; }
.ek span { display: inline-block; margin-top: 6px; background: rgba(20, 23, 33, .85); padding: 4px 12px; border-radius: 999px; font-weight: 800; }
@keyframes ekpop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-8deg); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(2deg); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
.burst { position: fixed; z-index: 955; pointer-events: none; width: 10px; height: 10px; border-radius: 3px; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 2147483000; background: rgba(8,10,18,.72); display: grid; place-items: center; padding: 14px; }
.box { width: min(480px, 100%); max-height: calc(100vh - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.box h2 { font-size: 25px; font-weight: 800; }
.box p { color: #d2d1e8; line-height: 1.5; }
.small { font-size: 13px; color: var(--muted); }
.kick { color: #7fb6f0; font-weight: 800; font-size: 14px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.btns.col { flex-direction: column; align-items: stretch; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; color: #d2d1e8; }
.steps .mini { display: inline-flex; gap: 4px; vertical-align: middle; }
.steps .mini svg { width: 26px; height: 36px; }
.marks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.marks span { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 12px; font-weight: 800; font-size: 12.5px; color: #fff; }
.lab { font-weight: 800; font-size: 14px; color: var(--muted); margin-top: 4px; }
.chips { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 8px; }
.chip { min-height: 50px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel-2); font-weight: 800; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; padding: 4px; }
.chip small { font-size: 11.5px; color: var(--muted); font-weight: 800; }
.chip small.st { color: #ffc23d; letter-spacing: 1px; }
.chip[aria-pressed="true"] { border-color: #2f7fd8; background: color-mix(in srgb, #2f7fd8 22%, var(--panel-2)); box-shadow: 0 0 0 3px rgba(47, 127, 216, .3); }
.cpick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cpick button { min-height: 78px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-family: var(--display); font-weight: 800; font-size: 19px; color: #fff; border: 3px solid rgba(255,255,255,.85); text-shadow: 0 1px 3px rgba(0,0,0,.35); box-shadow: 0 6px 14px rgba(0,0,0,.3); }
.cpick button small { font-family: var(--body); font-size: 12px; font-weight: 800; opacity: .9; }
.cpick button:active { transform: scale(.97); }
.rtab { display: flex; flex-direction: column; gap: 6px; }
.rtab div { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; background: var(--panel-2); font-weight: 800; }
.rtab div span.n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rtab div small { color: var(--muted); font-weight: 800; font-size: 12px; white-space: nowrap; }
.rtab div b { font-family: var(--display); font-size: 20px; min-width: 44px; text-align: right; }
.rtab div.top { box-shadow: 0 0 0 2px #ffc23d inset; }
.win-stars { display: flex; justify-content: center; gap: 8px; font-size: 54px; line-height: 1; }
.win-stars span { color: #3a3f5e; }
.win-stars span.on { color: #ffc23d; animation: star .5s cubic-bezier(.3, 1.6, .5, 1) both; text-shadow: 0 0 18px rgba(255, 194, 61, .6); }
@keyframes star { from { transform: scale(.2) rotate(-40deg); opacity: 0; } }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 10px 8px; border-radius: 16px; background: var(--panel-2); border: 2px solid var(--line); }
.badge svg { width: 46px; height: 46px; }
.badge b { font-size: 14px; line-height: 1.2; }
.badge small { font-size: 12px; color: var(--muted); font-weight: 700; line-height: 1.3; }
.badge.off { opacity: .45; filter: grayscale(1); }
.badge.new { border-color: #ffc23d; animation: star .5s both; }
.starrow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.starrow div { background: var(--panel-2); border-radius: 14px; padding: 8px; text-align: center; font-weight: 800; }
.starrow div span { display: block; color: #ffc23d; letter-spacing: 2px; font-size: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 2147483100; background: #f5f3ff; color: #141721; font-weight: 800; padding: 10px 18px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100vw - 32px); text-align: center; pointer-events: none; }
@media (max-width: 360px) { .play { padding: 6px 8px 4px; gap: 6px; } .opp { padding: 6px 2px; } .opp .oname { font-size: 12px; } .table { padding-top: 14px; } }
@media (min-width: 700px) { .opp { width: calc((100% - 32px) / 5); max-width: 150px; } .bar-t b { font-size: 26px; } .play { gap: 10px; } }
@media (max-height: 700px) and (max-width: 699px) { :root { --pw: 68px; --ph: 95px; } .table { padding-top: 12px; } .opp { padding: 5px 3px; } .opp .av, .opp .av svg { width: 32px; height: 32px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
