@font-face { font-family: 'Baloo 2'; src: url('../assets/fonts/baloo2.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('../assets/fonts/nunito.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }

:root {
  --ink: #1B0D66; --night: #1A0B5E; --indigo: #2B1596; --violet: #5B2EE6; --panel: #2E1AA3; --panel-hi: #4A33D1; --line: rgba(255,255,255,.14);
  --gold: #FFC83D; --gold-d: #E08A00; --green: #2FCB5F; --green-d: #128A3A; --blue: #3B8CFF; --blue-d: #1A56C4; --pink: #FF5C8A; --pink-d: #C92A5C; --orange: #FF9A2E; --orange-d: #D06400;
  --text: #FFFFFF; --muted: #C9C2F5;
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif; --body: 'Nunito', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--night); }
body { font-family: var(--body); color: var(--text); font-size: 15px; line-height: 1.35; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; }
img { display: block; -webkit-user-drag: none; }
h1, h2, h3, p { margin: 0; }

#bg { position: fixed; inset: 0; background:
  radial-gradient(120% 60% at 50% 0%, #7B4BFF 0%, rgba(123,75,255,0) 60%),
  radial-gradient(90% 50% at 50% 105%, #3B1FCB 0%, rgba(59,31,203,0) 70%),
  linear-gradient(180deg, #3A1DBF 0%, #24108A 45%, #170A57 100%); }
#bg::before { content: ''; position: absolute; inset: 0; opacity: .5; background-image:
  radial-gradient(circle at 12% 18%, #fff 0 1.2px, transparent 1.6px), radial-gradient(circle at 78% 9%, #fff 0 1px, transparent 1.4px),
  radial-gradient(circle at 34% 62%, #fff 0 1px, transparent 1.4px), radial-gradient(circle at 88% 44%, #fff 0 1.3px, transparent 1.7px),
  radial-gradient(circle at 58% 84%, #fff 0 1px, transparent 1.4px), radial-gradient(circle at 6% 78%, #fff 0 1.2px, transparent 1.6px);
  background-size: 310px 370px; animation: twinkle 5s ease-in-out infinite alternate; }
#bg::after { content: ''; position: absolute; inset: 0; opacity: .06; background-image: repeating-linear-gradient(45deg, #fff 0 2px, transparent 2px 46px), repeating-linear-gradient(-45deg, #fff 0 2px, transparent 2px 46px); }
@keyframes twinkle { from { opacity: .25; } to { opacity: .6; } }

#app { position: fixed; inset: 0; display: flex; justify-content: center; }
.screen { position: relative; width: 100%; max-width: 480px; height: 100%; display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 14px calc(12px + var(--safe-b)); animation: screen-in .32s cubic-bezier(.2,.9,.3,1.1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }

/* ---------- shared pieces ---------- */
.display { font-family: var(--display); font-weight: 800; letter-spacing: .2px; }
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 18px; font-family: var(--display); font-weight: 800; font-size: 20px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.22);
  background: linear-gradient(180deg, #4FE07C, var(--green) 60%); box-shadow: 0 6px 0 var(--green-d), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.45); transition: transform .08s, box-shadow .08s, filter .15s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--green-d), 0 4px 8px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.45); }
.btn.gold { background: linear-gradient(180deg, #FFE27A, var(--gold) 60%); box-shadow: 0 6px 0 var(--gold-d), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.6); color: #5A3200; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.btn.gold:active { box-shadow: 0 2px 0 var(--gold-d), inset 0 2px 0 rgba(255,255,255,.6); }
.btn.blue { background: linear-gradient(180deg, #6FB0FF, var(--blue) 60%); box-shadow: 0 6px 0 var(--blue-d), 0 10px 18px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.45); }
.btn.blue:active { box-shadow: 0 2px 0 var(--blue-d), inset 0 2px 0 rgba(255,255,255,.45); }
.btn.ghost { background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); text-shadow: none; }
.btn.ghost:active { transform: scale(.97); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 42px; font-size: 17px; padding: 0 16px; border-radius: 14px; }
.btn[disabled] { filter: grayscale(.7) brightness(.8); pointer-events: none; }

.icon-btn { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(180deg, #5B43E6, #3A22B8); box-shadow: 0 4px 0 #23127E, inset 0 2px 0 rgba(255,255,255,.25); transition: transform .08s, box-shadow .08s; flex: none; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #23127E, inset 0 2px 0 rgba(255,255,255,.25); }
.icon-btn svg { width: 24px; height: 24px; }

.avatar { position: relative; border-radius: 50%; overflow: hidden; background: #fff; flex: none; box-shadow: 0 0 0 3px var(--gold), 0 4px 10px rgba(0,0,0,.35); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.coin-pill { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 6px 0 4px; border-radius: 22px; background: rgba(15,6,70,.55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.14); font-family: var(--display); font-weight: 800; font-size: 19px; }
.coin-pill img { width: 32px; height: 32px; }
.coin-pill .plus { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(180deg, #4FE07C, var(--green)); box-shadow: 0 3px 0 var(--green-d), inset 0 1px 0 rgba(255,255,255,.5); font-size: 22px; line-height: 1; margin-left: 4px; }
.coin-ico { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.28em; }

/* ---------- home ---------- */
.topbar { display: flex; align-items: center; gap: 10px; }
.profile-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; }
.profile-chip .avatar { width: 50px; height: 50px; }
.profile-chip .who { min-width: 0; }
.profile-chip .name { font-family: var(--display); font-weight: 800; font-size: 19px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level { white-space: nowrap; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.level .bar { flex: none; width: 54px; height: 8px; border-radius: 4px; background: rgba(15,6,70,.6); overflow: hidden; }
.level .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #FFE27A, var(--gold)); }

.hero { position: relative; flex: 1; min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero .glow { position: absolute; width: 86%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,214,102,.5), rgba(255,140,60,.16) 45%, transparent 68%); animation: pulse 3.4s ease-in-out infinite; }
.hero .rays { position: absolute; width: 130%; aspect-ratio: 1; background: repeating-conic-gradient(rgba(255,255,255,.07) 0 9deg, transparent 9deg 18deg); mask-image: radial-gradient(circle, #000 12%, transparent 60%); -webkit-mask-image: radial-gradient(circle, #000 12%, transparent 60%); animation: spin 50s linear infinite; }
.hero .board-art { position: relative; height: 62%; max-height: 300px; width: auto; max-width: 84%; object-fit: contain; filter: drop-shadow(0 18px 18px rgba(10,0,60,.5)); animation: floaty 4s ease-in-out infinite; }
.hero .logo { position: relative; height: 34%; max-height: 150px; width: auto; max-width: 70%; object-fit: contain; margin-bottom: -5%; z-index: 2; filter: drop-shadow(0 8px 10px rgba(10,0,60,.5)); animation: pop-in .6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes floaty { 50% { transform: translateY(-9px) rotate(-1.200deg); } }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .8; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } }

.play-online { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 18px 12px 12px; border-radius: 24px; text-align: left; background: linear-gradient(180deg, #5BEA86, #25BD55 62%); box-shadow: 0 7px 0 var(--green-d), 0 14px 24px rgba(0,0,0,.35), inset 0 3px 0 rgba(255,255,255,.5); transition: transform .08s, box-shadow .08s; overflow: hidden; }
.play-online:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--green-d), inset 0 3px 0 rgba(255,255,255,.5); }
.play-online::after { content: ''; position: absolute; top: 0; bottom: 0; width: 60px; left: -80px; background: linear-gradient(100deg, transparent, rgba(255,255,255,.5), transparent); transform: skewX(-18deg); animation: shine 3.6s ease-in-out infinite; }
@keyframes shine { 0%, 55% { left: -80px; } 100% { left: 115%; } }
.play-online img { width: 72px; height: 72px; filter: drop-shadow(0 4px 4px rgba(0,60,20,.4)); }
.play-online .t { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1; text-shadow: 0 2px 0 rgba(0,70,25,.45); }
.play-online .s { font-weight: 800; font-size: 14px; color: #E6FFEE; margin-top: 5px; display: flex; align-items: center; gap: 6px; }
.dot-live { width: 9px; height: 9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0 rgba(255,255,255,.7); animation: live 1.6s infinite; }
@keyframes live { to { box-shadow: 0 0 0 9px rgba(255,255,255,0); } }
.play-online .go { margin-left: auto; width: 46px; height: 46px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(0,90,30,.35); flex: none; }
.play-online .go svg { width: 22px; height: 22px; margin-left: 3px; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.mode { position: relative; padding: 10px 6px 12px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--display); font-weight: 800; font-size: 16px; line-height: 1.1; text-shadow: 0 2px 0 rgba(0,0,0,.2); transition: transform .08s, box-shadow .08s; box-shadow: 0 6px 0 var(--d), 0 12px 18px rgba(0,0,0,.3), inset 0 3px 0 rgba(255,255,255,.4); background: linear-gradient(180deg, var(--a), var(--b) 65%); }
.mode:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--d), inset 0 3px 0 rgba(255,255,255,.4); }
.mode img { width: 66px; height: 66px; filter: drop-shadow(0 4px 4px rgba(0,0,0,.3)); }
.mode.friends { --a: #7DBBFF; --b: var(--blue); --d: var(--blue-d); }
.mode.computer { --a: #FF8FB0; --b: var(--pink); --d: var(--pink-d); }
.mode.pass { --a: #FFC06B; --b: var(--orange); --d: var(--orange-d); }

.dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; padding: 8px; border-radius: 24px; background: rgba(15,6,70,.5); box-shadow: inset 0 0 0 2px var(--line); }
.dock button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; border-radius: 16px; font-weight: 800; font-size: 13px; color: #E9E4FF; transition: transform .1s, background .15s; }
.dock button:active { transform: scale(.93); background: rgba(255,255,255,.1); }
.dock img { width: 46px; height: 46px; }
.badge { position: absolute; top: 0; right: 14%; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #FF3B4E; box-shadow: 0 0 0 2px #2A1790; font-size: 13px; font-weight: 900; display: grid; place-items: center; animation: bob 1.200s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }

/* ---------- modals & sheets ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(10,3,50,.68); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fade .2s; }
.overlay.center { align-items: center; padding: 18px; }
.overlay.closing { animation: fade .18s reverse forwards; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: 100%; max-width: 480px; max-height: 92%; overflow-y: auto; padding: 30px 18px calc(22px + var(--safe-b)); border-radius: 30px 30px 0 0; background: linear-gradient(180deg, #4A30DB, #2C1799 45%); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), 0 -10px 40px rgba(0,0,0,.4); animation: sheet-up .32s cubic-bezier(.2,.9,.3,1.05); }
.overlay.center .sheet { border-radius: 30px; animation: card-in .32s cubic-bezier(.2,1.2,.4,1); max-width: 400px; box-shadow: inset 0 3px 0 rgba(255,255,255,.3), 0 0 0 4px #1C0E70, 0 24px 60px rgba(0,0,0,.5); }
.overlay.closing .sheet { animation: sheet-down .18s ease-in forwards; }
.overlay.center.closing .sheet { animation: card-out .18s ease-in forwards; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes card-in { from { transform: scale(.8); opacity: 0; } }
@keyframes card-out { to { transform: scale(.9); opacity: 0; } }
.sheet h2 { font-family: var(--display); font-weight: 800; font-size: 27px; text-align: center; line-height: 1.1; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.sheet .sub { text-align: center; color: var(--muted); font-weight: 700; margin-top: 4px; }
.sheet .close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 50%; background: rgba(15,6,70,.55); display: grid; place-items: center; z-index: 2; }
.sheet .close svg { width: 18px; height: 18px; }
.sheet .grab { position: absolute; top: 9px; left: 50%; width: 46px; height: 5px; margin-left: -23px; border-radius: 3px; background: rgba(255,255,255,.3); }
.overlay.center .grab { display: none; }
.label { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--muted); margin: 18px 2px 8px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button { min-height: 62px; border-radius: 18px; background: rgba(15,6,70,.5); box-shadow: inset 0 0 0 2px var(--line); font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform .1s, background .15s, box-shadow .15s; }
.seg button small { font-family: var(--body); font-size: 13px; font-weight: 800; color: var(--muted); }
.seg button.on { background: linear-gradient(180deg, #FFE27A, var(--gold)); color: #4A2A00; box-shadow: 0 4px 0 var(--gold-d), inset 0 2px 0 rgba(255,255,255,.6); transform: translateY(-2px); }
.seg button.on small { color: #7A4B00; }
.seg .pips { display: flex; gap: 3px; }
.seg .pips i { width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }

.stakes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stake { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 8px 12px; border-radius: 18px; text-align: left; background: rgba(15,6,70,.5); box-shadow: inset 0 0 0 2px var(--line); transition: transform .1s; }
.stake img { width: 38px; height: 38px; }
.stake b { font-family: var(--display); font-weight: 800; font-size: 20px; line-height: 1; display: block; }
.stake small { font-size: 13px; font-weight: 800; color: var(--muted); }
.stake.on { background: linear-gradient(180deg, #FFE27A, var(--gold)); color: #4A2A00; box-shadow: 0 4px 0 var(--gold-d), inset 0 2px 0 rgba(255,255,255,.6); transform: translateY(-2px); }
.stake.on small { color: #7A4B00; }
.stake.locked { opacity: .5; }
.stake.free { grid-column: 1 / -1; }
.sheet .btn.wide { margin-top: 20px; }

.field { width: 100%; height: 56px; padding: 0 16px; border-radius: 16px; border: 0; outline: 0; background: rgba(15,6,70,.6); box-shadow: inset 0 0 0 2px var(--line); color: #fff; font-family: var(--display); font-weight: 700; font-size: 20px; user-select: text; -webkit-user-select: text; }
.field:focus { box-shadow: inset 0 0 0 3px var(--gold); }
.field::placeholder { color: rgba(201,194,245,.6); }
.field.code { text-align: center; letter-spacing: 8px; font-size: 28px; font-weight: 800; }
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 4px; }
.avatar-grid button { aspect-ratio: 1; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 3px rgba(255,255,255,.2); transition: transform .12s, box-shadow .12s; }
.avatar-grid button.on { box-shadow: 0 0 0 4px var(--gold), 0 0 18px rgba(255,200,61,.7); transform: scale(1.08); }
.avatar-grid img { width: 100%; height: 100%; }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0 0; color: var(--muted); font-weight: 800; }
.or::before, .or::after { content: ''; flex: 1; height: 2px; background: var(--line); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .field { flex: 1; min-width: 0; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 14px; margin-top: 8px; border-radius: 18px; background: rgba(15,6,70,.45); font-family: var(--display); font-weight: 700; font-size: 18px; }
.switch { width: 58px; height: 32px; border-radius: 16px; background: rgba(15,6,70,.8); position: relative; transition: background .2s; box-shadow: inset 0 0 0 2px var(--line); }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s cubic-bezier(.3,1.5,.5,1); box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(26px); }

.rules { display: grid; gap: 8px; margin-top: 14px; }
.rules div { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; background: rgba(15,6,70,.45); font-weight: 700; font-size: 15px; }
.rules b { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #4A2A00; display: grid; place-items: center; font-family: var(--display); font-size: 18px; }

.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.day { padding: 8px 4px 9px; border-radius: 16px; background: rgba(15,6,70,.5); box-shadow: inset 0 0 0 2px var(--line); text-align: center; font-weight: 800; font-size: 13px; color: var(--muted); }
.day img { width: 38px; height: 38px; margin: 2px auto; }
.day b { display: block; font-family: var(--display); font-size: 17px; color: #fff; line-height: 1; }
.day.done { opacity: .5; }
.day.today { background: linear-gradient(180deg, #FFE27A, var(--gold)); color: #7A4B00; box-shadow: 0 4px 0 var(--gold-d), inset 0 2px 0 rgba(255,255,255,.6); animation: bob 1.200s ease-in-out infinite; }
.day.today b { color: #4A2A00; }
.day.big { grid-column: span 2; }

.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.pack { position: relative; padding: 12px 8px 10px; border-radius: 20px; background: rgba(15,6,70,.5); box-shadow: inset 0 0 0 2px var(--line); text-align: center; }
.pack img { width: 64px; height: 64px; margin: 0 auto; }
.pack b { display: block; font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1.2; }
.pack .btn { margin-top: 8px; width: 100%; }
.pack .tag { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); padding: 2px 10px; border-radius: 10px; background: #FF3B4E; font-size: 13px; font-weight: 900; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { padding: 12px 4px; border-radius: 18px; background: rgba(15,6,70,.5); text-align: center; font-weight: 800; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-family: var(--display); font-size: 26px; color: #fff; line-height: 1.1; }

/* ---------- matchmaking & lobby ---------- */
.center-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.big-title { font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.1; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.slots { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.slot { width: 78px; text-align: center; font-weight: 800; font-size: 14px; }
.slot .avatar { width: 70px; height: 70px; margin: 0 auto 8px; }
.slot .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.empty .avatar { background: rgba(15,6,70,.6); box-shadow: 0 0 0 3px rgba(255,255,255,.25); display: grid; place-items: center; }
.slot.empty .avatar::after { content: ''; width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: var(--gold); animation: spin .9s linear infinite; }
.slot.empty.idle .avatar::after { border: 0; content: '+'; font-family: var(--display); font-size: 34px; color: rgba(255,255,255,.4); animation: none; display: grid; place-items: center; }
.slot.joined .avatar { animation: pop-in .4s cubic-bezier(.2,1.6,.4,1); }
.vs { font-family: var(--display); font-weight: 800; font-size: 26px; color: var(--gold); align-self: center; margin-bottom: 26px; }
.code-box { padding: 12px 22px; border-radius: 22px; background: rgba(15,6,70,.6); box-shadow: inset 0 0 0 2px var(--gold); }
.code-box small { display: block; font-weight: 800; font-size: 14px; color: var(--muted); }
.code-box b { font-family: var(--display); font-weight: 800; font-size: 42px; letter-spacing: 6px; line-height: 1.1; color: var(--gold); user-select: text; -webkit-user-select: text; }
.hint { color: var(--muted); font-weight: 700; max-width: 300px; }
.stack { display: grid; gap: 12px; width: 100%; max-width: 330px; }

/* ---------- game ---------- */
.game { padding-left: 8px; padding-right: 8px; }
.game-top { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.prize { margin: 0 auto; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px 0 6px; border-radius: 20px; background: rgba(15,6,70,.55); box-shadow: inset 0 0 0 2px rgba(255,200,61,.5); font-family: var(--display); font-weight: 800; font-size: 18px; }
.prize img { width: 30px; height: 30px; }
.prize.plain { padding: 0 16px; box-shadow: inset 0 0 0 2px var(--line); }
.table { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 8px; min-height: 0; }
.prow { display: flex; justify-content: space-between; gap: 8px; min-height: 66px; }
.pcard { position: relative; display: flex; align-items: center; gap: 8px; width: calc(50% - 4px); padding: 6px; border-radius: 20px; background: rgba(15,6,70,.55); box-shadow: inset 0 0 0 2px var(--line); transition: box-shadow .25s, background .25s, opacity .3s; }
.pcard.right { flex-direction: row-reverse; text-align: right; margin-left: auto; }
.pcard.active { background: color-mix(in srgb, var(--c) 34%, rgba(15,6,70,.7)); box-shadow: inset 0 0 0 3px var(--c), 0 0 22px color-mix(in srgb, var(--c) 60%, transparent); }
.pcard.hidden { visibility: hidden; }
.pcard .ring { position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p, 1) * 360deg), rgba(255,255,255,.16) 0); }
.pcard .ring.low { background: conic-gradient(#FF3B4E calc(var(--p, 1) * 360deg), rgba(255,255,255,.16) 0); }
.pcard .avatar { width: 40px; height: 40px; box-shadow: 0 0 0 2px #1C0E70; }
.pcard .info { flex: 1; min-width: 0; }
.pcard .name { font-family: var(--display); font-weight: 800; font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .tagline { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.pcard .tagline i { width: 11px; height: 11px; border-radius: 50%; background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.3); transition: background .3s, transform .3s; }
.pcard .tagline i.on { background: var(--c); box-shadow: inset 0 0 0 1.5px #fff, 0 0 8px var(--c); transform: scale(1.15); }
.pcard .who-tag { position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); padding: 0 6px; border-radius: 8px; background: #1C0E70; box-shadow: 0 0 0 1.5px var(--c); font-size: 13px; line-height: 16px; font-weight: 900; white-space: nowrap; }
.pcard.right .tagline { justify-content: flex-end; }
.pcard .chip { width: 11px; height: 11px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(255,255,255,.7); flex: none; }
.dice-well { width: 50px; height: 50px; border-radius: 16px; flex: none; display: grid; place-items: center; background: rgba(8,2,50,.55); box-shadow: inset 0 3px 6px rgba(0,0,0,.4); position: relative; }
.pcard.myturn .dice-well { background: #fff3; box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(255,200,61,.8); animation: nudge 1s ease-in-out infinite; cursor: pointer; }
@keyframes nudge { 50% { transform: scale(1.09); } }
.tap-hint { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); padding: 3px 10px; border-radius: 10px; background: var(--gold); color: #4A2A00; font-family: var(--display); font-weight: 800; font-size: 14px; white-space: nowrap; pointer-events: none; animation: bob 1s ease-in-out infinite; z-index: 6; }
.tap-hint::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--gold); }
.pcard.bottom .tap-hint { bottom: auto; top: calc(100% + 8px); }
.pcard.bottom .tap-hint::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--gold); }

.dice { width: 40px; height: 40px; perspective: 300px; }
.cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transform: rotateX(var(--rx, -18deg)) rotateY(var(--ry, 24deg)); transition: transform .9s cubic-bezier(.15,.8,.25,1); }
.tilt { width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(-16deg) rotateY(18deg); }
.dice.rolling .cube { animation: tumble .9s cubic-bezier(.3,.2,.3,1); }
@keyframes tumble { 0% { transform: translateY(0) rotateX(0) rotateY(0) scale(1); } 30% { transform: translateY(-16px) rotateX(420deg) rotateY(300deg) scale(1.25); } 70% { transform: translateY(0) rotateX(800deg) rotateY(640deg) scale(1.05); } 100% { transform: rotateX(var(--rx)) rotateY(var(--ry)); } }
.face { position: absolute; inset: 0; border-radius: 9px; background: linear-gradient(145deg, #fff, #E6E8F6); box-shadow: inset 0 0 0 1.500px #C3C7E3, inset 0 -3px 5px rgba(60,50,140,.18); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 6px; backface-visibility: hidden; }
.face i { width: 7.500px; height: 7.500px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5A4BB5, #1B0D66); align-self: center; justify-self: center; }
.face.one i { background: radial-gradient(circle at 35% 30%, #FF7A7A, #D31F2C); width: 11px; height: 11px; }
.f1 { transform: translateZ(20px); } .f6 { transform: rotateY(180deg) translateZ(20px); }
.f2 { transform: rotateY(90deg) translateZ(20px); } .f5 { transform: rotateY(-90deg) translateZ(20px); }
.f3 { transform: rotateX(90deg) translateZ(20px); } .f4 { transform: rotateX(-90deg) translateZ(20px); }
.dice .cube { transition: transform .9s cubic-bezier(.15,.8,.25,1), opacity .3s; }
.dice.idle .cube { opacity: 0; }

.board-wrap { position: relative; width: min(100%, calc(100dvh - 330px - var(--safe-t) - var(--safe-b))); max-width: 464px; aspect-ratio: 1; margin: 0 auto; flex: none; padding: 7px; border-radius: 26px; background: linear-gradient(145deg, #FFE27A, #F2A516 55%, #B56A00); box-shadow: 0 10px 0 #7A4300, 0 22px 34px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,255,255,.7); }
.board { position: relative; width: 100%; height: 100%; border-radius: 20px; }
.board-svg { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 20px; display: block; }
.token { position: absolute; width: 7%; aspect-ratio: 168 / 244; left: 0; top: 0; margin: -8.3% 0 0 -3.5%; transition: left .14s linear, top .14s linear, width .2s, margin .2s; z-index: 2; pointer-events: none; will-change: left, top; }
.token .g { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 2.5px 2px rgba(20,10,60,.5)); transform-origin: 50% 82%; position: relative; }
.token.small { width: 5.2%; margin: -6.2% 0 0 -2.6%; }
.token.hop .g { animation: hop .14s ease-out; }
@keyframes hop { 50% { transform: translateY(-34%) scale(1.14); } }
.token.fly { transition: left .5s cubic-bezier(.5,0,.3,1), top .5s cubic-bezier(.5,0,.3,1); z-index: 5; }
.token.fly .g { animation: tumble-back .5s linear; }
@keyframes tumble-back { 50% { transform: scale(1.5) rotate(180deg); } 100% { transform: rotate(360deg); } }
.token.can { z-index: 4; pointer-events: auto; cursor: pointer; }
.token.can .g { animation: can 0.7s ease-in-out infinite; }
.token.can::before { content: ''; position: absolute; left: 50%; bottom: -9%; width: 130%; aspect-ratio: 1; margin-left: -65%; border-radius: 50%; border: 2.500px dashed #fff; box-shadow: 0 0 10px 3px var(--c); animation: spin 3s linear infinite; }
.token.can::after { content: ''; position: absolute; inset: -40% -50% -20%; }
@keyframes can { 50% { transform: translateY(-16%) scale(1.12); } }
.token.arrived .g { animation: arrived .6s ease-out; }
@keyframes arrived { 30% { transform: scale(1.6); filter: brightness(1.6) drop-shadow(0 0 8px #fff); } }
.burst { position: absolute; width: 20%; aspect-ratio: 1; margin: -10% 0 0 -10%; border-radius: 50%; pointer-events: none; z-index: 90; background: radial-gradient(circle, #fff 0 20%, var(--c) 21% 45%, transparent 60%); animation: burst .55s ease-out forwards; }
@keyframes burst { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
.board-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 95; padding: 6px 20px; border-radius: 18px; background: rgba(20,8,90,.92); box-shadow: 0 0 0 3px var(--gold), 0 10px 30px rgba(0,0,0,.4); font-family: var(--display); font-weight: 800; font-size: 24px; white-space: nowrap; pointer-events: none; animation: msg 1.500s ease-out forwards; }
@keyframes msg { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 25%, 75% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -80%) scale(.9); opacity: 0; } }

.bubble { position: absolute; z-index: 9; max-width: 190px; padding: 7px 12px; border-radius: 16px; background: #fff; color: #1B0D66; font-weight: 800; font-size: 14px; line-height: 1.25; box-shadow: 0 6px 16px rgba(0,0,0,.35); animation: bubble 3.200s ease forwards; pointer-events: none; word-break: break-word; left: 6px; top: calc(100% + 6px); text-align: left; }
.pcard.right .bubble { left: auto; right: 6px; }
.pcard.bottom .bubble { top: auto; bottom: calc(100% + 6px); }
@keyframes bubble { 0% { transform: scale(.4); opacity: 0; } 7% { transform: scale(1.06); opacity: 1; } 12%, 88% { transform: scale(1); opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
.emote-fly { position: absolute; z-index: 10; font-size: 54px; line-height: 1; pointer-events: none; left: 8px; top: -6px; animation: emote 2.200s cubic-bezier(.2,.8,.3,1) forwards; filter: drop-shadow(0 6px 8px rgba(0,0,0,.4)); }
.pcard.right .emote-fly { left: auto; right: 8px; }
@keyframes emote { 0% { transform: scale(.2) rotate(-20deg); opacity: 0; } 15% { transform: scale(1.35) rotate(8deg); opacity: 1; } 30% { transform: scale(1) rotate(-4deg); } 45% { transform: scale(1.12) rotate(3deg); } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(.8) translateY(-24px); opacity: 0; } }

.game-bottom { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.emotes { flex: 1; display: flex; justify-content: space-between; height: 50px; padding: 0 8px; border-radius: 25px; background: rgba(15,6,70,.55); box-shadow: inset 0 0 0 2px var(--line); }
.emotes button { font-size: 27px; width: 42px; transition: transform .1s; }
.emotes button:active { transform: scale(1.4) translateY(-6px); }
.chat-btn { position: relative; }
.chat-btn .badge { right: -4px; top: -4px; }

.chat-sheet { height: 70%; display: flex; flex-direction: column; padding-bottom: calc(12px + var(--safe-b)); }
.chat-log { flex: 1; overflow-y: auto; margin-top: 12px; padding: 4px 2px; display: flex; flex-direction: column; gap: 6px; }
.chat-log .empty { margin: auto; color: var(--muted); font-weight: 700; text-align: center; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.msg .avatar { width: 30px; height: 30px; box-shadow: 0 0 0 2px var(--c); }
.msg p { padding: 7px 12px; border-radius: 16px 16px 16px 4px; background: rgba(15,6,70,.6); font-weight: 700; word-break: break-word; }
.msg small { display: block; font-size: 13px; font-weight: 800; color: var(--c); filter: brightness(1.4); }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me p { background: var(--blue); border-radius: 16px 16px 4px 16px; }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; flex: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: none; padding: 8px 14px; border-radius: 18px; background: rgba(15,6,70,.6); box-shadow: inset 0 0 0 2px var(--line); font-weight: 800; font-size: 14px; white-space: nowrap; }
.quick button:active { background: var(--gold); color: #4A2A00; }
.chat-input { display: flex; gap: 8px; flex: none; }
.chat-input .field { height: 50px; font-family: var(--body); font-size: 16px; }
.chat-input .btn { min-height: 46px; padding: 0 18px; }

/* ---------- results ---------- */
.result .crown { width: 84px; height: 84px; margin: -14px auto 2px; animation: pop-in .6s cubic-bezier(.2,1.6,.4,1) both, floaty 3s 0.6s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(0,0,0,.4)); }
.ranks { display: grid; gap: 8px; margin-top: 16px; }
.rank { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 18px; background: rgba(15,6,70,.5); font-family: var(--display); font-weight: 800; font-size: 18px; animation: rank-in .4s both cubic-bezier(.2,1.2,.4,1); }
.rank:nth-child(2) { animation-delay: .1s; } .rank:nth-child(3) { animation-delay: .2s; } .rank:nth-child(4) { animation-delay: .3s; }
@keyframes rank-in { from { transform: translateX(-30px); opacity: 0; } }
.rank.first { background: linear-gradient(180deg, #FFE27A, var(--gold)); color: #4A2A00; box-shadow: 0 4px 0 var(--gold-d), inset 0 2px 0 rgba(255,255,255,.6); }
.rank .pos { width: 28px; text-align: center; font-size: 20px; }
.rank .avatar { width: 40px; height: 40px; box-shadow: 0 0 0 3px var(--c); }
.rank .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .amt { display: flex; align-items: center; gap: 4px; }
.rank .amt img { width: 24px; height: 24px; }
.reward { margin-top: 14px; text-align: center; font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--gold); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

#toast-root { position: fixed; left: 0; right: 0; top: calc(64px + var(--safe-t)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 9px 18px; border-radius: 18px; background: rgba(15,6,70,.95); box-shadow: 0 0 0 2px var(--gold), 0 8px 20px rgba(0,0,0,.4); font-weight: 800; font-size: 15px; max-width: 88%; text-align: center; animation: toast 2.600s ease forwards; }
@keyframes toast { 0% { transform: translateY(-20px); opacity: 0; } 8%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }
.fly-coin { position: fixed; width: 30px; height: 30px; z-index: 95; pointer-events: none; transition: transform .7s cubic-bezier(.5,-0.3,.6,1), opacity .7s; }

@media (max-height: 700px) {
  .hero .logo { max-height: 100px; } .mode img { width: 52px; height: 52px; } .play-online img { width: 58px; height: 58px; }
  .dock img { width: 38px; height: 38px; } .modes, .dock { margin-top: 10px; }
  .prow { min-height: 60px; } .board-wrap { width: min(100%, calc(100dvh - 296px)); }
}
@media (prefers-reduced-motion: reduce) { #bg::before, .hero .rays, .hero .glow, .hero .board-art, .play-online::after { animation: none; } }
