@font-face { font-family: 'Lilita'; src: url(fonts/lilita.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(fonts/nunito-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(fonts/nunito-800.woff2) format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(fonts/nunito-900.woff2) format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --bg: #0f2e22; --bg2: #13392b; --ink: #1b120c; --cream: #fff6e2; --cream2: #f3e6c8;
  --yellow: #ffc83d; --orange: #c9450f; --red: #e5484d; --green: #4cc764; --blue: #2f6fed; --purple: #7c3aed;
  --panel: #fff6e2; --panelText: #1b120c; --muted: #6b5d4d; --accent: #ffc83d; --accent2: #e5484d;
  --radius: 18px; --shadow: 0 4px 0 var(--ink);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--cream); font-family: 'Nunito', system-ui, sans-serif; font-weight: 800; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
body { background-color: var(--bg); background-image: conic-gradient(var(--bg2) 25%, transparent 0 50%, var(--bg2) 0 75%, transparent 0); background-size: 64px 64px; }
input, select, textarea, button { font: inherit; }
input, textarea { user-select: text; -webkit-user-select: text; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }
h1, h2, h3, .display { font-family: 'Lilita', 'Nunito', sans-serif; font-weight: 400; letter-spacing: .5px; margin: 0; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; padding: 16px 16px calc(24px + var(--safe-b)); }
.wrap { max-width: 640px; margin: 0 auto; width: 100%; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 20px; border-radius: 16px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); font-weight: 900; font-size: 17px; transition: transform .08s, box-shadow .08s; min-height: 52px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--yellow); }
.btn.red { background: var(--red); color: #fff; }
.btn.green { background: var(--green); color: var(--ink); }
.btn.blue { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; color: var(--cream); border-color: rgba(255,246,226,.5); box-shadow: none; }
.btn.small { padding: 8px 12px; min-height: 40px; font-size: 14px; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { width: 46px; height: 46px; border-radius: 14px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-size: 20px; display: inline-flex; align-items: center; justify-content: center; position: relative; flex: none; }
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: 10px; font-size: 11px; min-width: 20px; height: 20px; padding: 0 4px; display: flex; align-items: center; justify-content: center; }

/* Home */
#home .scroll { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.logo { width: min(560px, 96vw); filter: drop-shadow(0 10px 18px rgba(0,0,0,.35)); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-.5deg); } }
.menu { display: grid; gap: 12px; width: min(420px, 100%); }
.menu .btn { font-size: 20px; min-height: 60px; }
.tagline { color: var(--cream2); opacity: .85; text-align: center; font-size: 14px; margin: -4px 0 6px; }
.foot { opacity: .55; font-size: 12px; margin-top: 8px; text-align: center; }

/* Cards / panels */
.panel { background: var(--panel); color: var(--panelText); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.panel h3 { font-size: 20px; margin-bottom: 10px; color: var(--ink); }
.panel .sub { color: var(--muted); font-size: 13px; font-weight: 700; margin: -6px 0 10px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.topbar h2 { font-size: 26px; color: var(--yellow); text-shadow: 0 3px 0 var(--orange), 0 5px 0 var(--ink); flex: 1; }

.seg { display: flex; background: var(--cream2); border: 3px solid var(--ink); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 10px 6px; border-radius: 10px; background: transparent; color: var(--ink); font-weight: 900; font-size: 15px; line-height: 1.1; }
.seg button small { display: block; font-size: 11px; font-weight: 700; opacity: .7; margin-top: 2px; }
.seg button.on { background: var(--yellow); box-shadow: inset 0 0 0 2px var(--ink); }

.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 2px dashed rgba(27,18,12,.15); }
.toggle:first-of-type { border-top: 0; }
.toggle .t { font-weight: 900; }
.toggle .d { font-size: 12px; color: var(--muted); font-weight: 700; }
.switch { width: 54px; height: 32px; border-radius: 20px; background: #cbbf9f; border: 3px solid var(--ink); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: left .2s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 24px; }

.player-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 14px; background: #fff; border: 2px solid var(--ink); margin-bottom: 8px; }
.player-row input { flex: 1; min-width: 0; border: 0; background: transparent; font-weight: 900; font-size: 16px; color: var(--ink); outline: none; padding: 6px 2px; }
.tok { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; font-size: 24px; flex: none; position: relative; }
.tok::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--cream); z-index: 0; }
.tok span { position: relative; z-index: 1; line-height: 1; }
.chip { padding: 6px 10px; border-radius: 10px; border: 2px solid var(--ink); background: var(--cream2); color: var(--ink); font-size: 12px; font-weight: 900; white-space: nowrap; }
.chip.bot { background: #dfe7ff; }
.chip.team { color: #fff; }
.x { width: 32px; height: 32px; border-radius: 10px; background: var(--cream2); color: var(--ink); border: 2px solid var(--ink); font-size: 16px; flex: none; }

.size-val { font-family: 'Lilita'; font-size: 34px; color: var(--ink); min-width: 70px; text-align: center; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 10px; background: var(--cream2); border: 2px solid var(--ink); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-card { border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; background: #fff; text-align: left; padding: 0; color: var(--ink); }
.theme-card.on { box-shadow: 0 0 0 4px var(--yellow), 0 4px 0 6px var(--ink); }
.theme-card .sw { height: 54px; display: grid; grid-template-columns: repeat(6, 1fr); }
.theme-card .nm { padding: 6px 8px; font-weight: 900; font-size: 14px; }

/* Modal / sheet */
.overlay { position: fixed; inset: 0; background: rgba(8,16,12,.62); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .18s; backdrop-filter: blur(2px); }
.overlay.center { align-items: center; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--panel); color: var(--panelText); border: 3px solid var(--ink); border-radius: 22px 22px 0 0; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 18px 16px calc(18px + var(--safe-b)); box-shadow: 0 -4px 0 var(--ink); animation: up .25s cubic-bezier(.2,.9,.3,1.2); }
.overlay.center .sheet { border-radius: 22px; box-shadow: 0 6px 0 var(--ink); width: calc(100% - 24px); animation: pop .28s cubic-bezier(.2,.9,.3,1.3); }
@keyframes up { from { transform: translateY(40%); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.sheet h2 { font-size: 26px; color: var(--ink); margin-bottom: 6px; }
.sheet p { margin: 0 0 12px; color: var(--muted); font-weight: 700; line-height: 1.4; }
.opt { display: block; width: 100%; text-align: left; padding: 14px; border-radius: 14px; border: 3px solid var(--ink); background: #fff; color: var(--ink); margin-bottom: 10px; box-shadow: 0 4px 0 var(--ink); }
.opt b { display: block; font-size: 17px; font-weight: 900; }
.opt span { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opt.hl { background: #fff2c2; }
.waiting { text-align: center; color: var(--muted); padding: 6px; font-weight: 800; }
.dots::after { content: '…'; animation: dots 1s steps(3) infinite; display: inline-block; width: 1.2em; text-align: left; overflow: hidden; vertical-align: bottom; }

.grid-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.grid-pick button { height: 54px; border-radius: 14px; background: #fff; border: 2px solid var(--ink); font-size: 28px; }
.grid-pick button.on { background: var(--yellow); box-shadow: inset 0 0 0 2px var(--ink); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.colors button { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--ink); }
.colors button.on { box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--ink); }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 8px; border-radius: 12px; border: 2px solid var(--ink); background: var(--cream2); color: var(--ink); font-weight: 900; }
.tabs button.on { background: var(--yellow); }

/* Game screen */
#game { flex-direction: column; }
.gtop { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); flex: none; }
.round-chip { background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px; padding: 6px 10px; font-weight: 900; font-size: 14px; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
.turn-banner { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 10px 4px 4px; box-shadow: 0 3px 0 var(--ink); }
.turn-banner .tok { width: 34px; height: 34px; font-size: 18px; border-width: 3px; }
.turn-banner .nm { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.turn-banner .st { font-size: 11px; color: var(--muted); }
.gmain { flex: 1; display: flex; min-height: 0; }
.board-wrap { flex: 1; overflow: auto; position: relative; min-height: 0; padding: 6px; display: flex; }
.board-wrap.fit { display: flex; align-items: flex-start; justify-content: center; }
#board { display: block; margin: auto; flex: none; border-radius: 14px; filter: drop-shadow(0 6px 0 var(--ink)); }
.hud { flex: none; padding: 8px 10px calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.players-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.players-strip::-webkit-scrollbar { display: none; }
.pcard { flex: none; min-width: 108px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 8px; box-shadow: 0 3px 0 var(--ink); position: relative; transition: transform .2s; }
.pcard.active { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--accent), 0 5px 0 4px var(--ink); }
.pcard .top { display: flex; align-items: center; gap: 6px; }
.pcard .tok { width: 30px; height: 30px; font-size: 16px; border-width: 3px; }
.pcard .nm { font-size: 13px; font-weight: 900; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .pos { font-family: 'Lilita'; font-size: 20px; line-height: 1; }
.pcard .inv { display: flex; gap: 6px; font-size: 12px; margin-top: 4px; font-weight: 900; }
.pcard .inv span.off { opacity: .25; }
.pcard .tm { position: absolute; top: -8px; right: 6px; font-size: 10px; color: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 0 5px; }
.pcard.frozen { background: #d9f1ff; }
.actions { display: flex; align-items: center; gap: 8px; }
.hand { flex: 1; display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.card { flex: none; width: 58px; height: 74px; border-radius: 12px; background: linear-gradient(160deg, #fff, var(--cream2)); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); padding: 2px; }
.card i { font-style: normal; font-size: 26px; }
.card small { font-size: 9px; font-weight: 900; text-align: center; line-height: 1.05; margin-top: 2px; }
.card.dis { opacity: .4; }
.card.empty { background: rgba(255,255,255,.08); border-style: dashed; border-color: rgba(255,246,226,.35); box-shadow: none; color: rgba(255,246,226,.5); font-size: 11px; }
.dice-btn { width: 92px; height: 92px; border-radius: 24px; background: var(--yellow); border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink); display: flex; align-items: center; justify-content: center; flex: none; position: relative; }
.dice-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.dice-btn.wait { background: var(--cream2); opacity: .8; }
.dice-btn .lbl { position: absolute; bottom: -2px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 900; color: var(--ink); background: var(--cream); border-top: 3px solid var(--ink); border-radius: 0 0 20px 20px; padding: 1px 0; }
.dice-btn.ready { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateY(-3px) rotate(-3deg); } }
.die { width: 52px; height: 52px; margin-top: -12px; }
.die.spin { animation: spin .5s linear; }
@keyframes spin { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(200deg) scale(1.2); } 100% { transform: rotate(360deg) scale(1); } }
.timer-ring { position: absolute; inset: -8px; pointer-events: none; }
.side-btns { display: flex; flex-direction: column; gap: 6px; }

/* Toasts & fx */
#toasts { position: fixed; top: 64px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 40; }
.toast { background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 14px; font-weight: 900; box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; gap: 8px; animation: tin .25s cubic-bezier(.2,.9,.3,1.4), tout .3s 2.3s forwards; max-width: 92vw; font-size: 15px; }
.toast i { font-style: normal; font-size: 22px; }
.toast .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.toast.big { font-size: 19px; padding: 12px 18px; background: var(--yellow); }
@keyframes tin { from { transform: translateY(-14px) scale(.9); opacity: 0; } }
@keyframes tout { to { transform: translateY(-10px); opacity: 0; } }
.float-emote { position: fixed; font-size: 44px; pointer-events: none; z-index: 45; animation: rise 1.8s ease-out forwards; }
@keyframes rise { 0% { transform: translate(-50%, 0) scale(.4); opacity: 0; } 15% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -140px) scale(1); opacity: 0; } }
.banner { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 46; text-align: center; pointer-events: none; animation: bannerIn 2.2s ease forwards; width: 92vw; }
.banner h1 { font-size: clamp(34px, 9vw, 64px); color: var(--yellow); text-shadow: 0 4px 0 var(--orange), 0 7px 0 var(--ink); }
.banner p { color: var(--cream); font-size: 17px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); margin: 6px 0 0; }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 25% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); } }
.shake { animation: shake .45s; }
@keyframes shake { 20% { transform: translate(-6px, 3px); } 40% { transform: translate(6px, -3px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -1px); } }
.flash-red { animation: flashr .5s; }
@keyframes flashr { 30% { background-color: rgba(229,72,77,.35); } }

/* Emote & chat */
.emote-bar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.emote-bar button { font-size: 30px; width: 54px; height: 54px; border-radius: 14px; background: #fff; border: 2px solid var(--ink); }
.chat-list { height: 46vh; overflow-y: auto; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; user-select: text; }
.msg { max-width: 82%; padding: 6px 10px; border-radius: 12px; background: var(--cream2); color: var(--ink); font-weight: 700; font-size: 14px; word-wrap: break-word; }
.msg b { display: block; font-size: 11px; font-weight: 900; }
.msg.me { align-self: flex-end; background: #fff2c2; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 12px; text-align: center; }
.chat-in { display: flex; gap: 6px; }
.chat-in input { flex: 1; min-width: 0; border: 3px solid var(--ink); border-radius: 12px; padding: 10px; font-weight: 800; outline: none; }
.quick { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.quick button { flex: none; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--ink); background: var(--cream2); color: var(--ink); font-weight: 800; font-size: 13px; }
.log-list { max-height: 60vh; overflow-y: auto; font-size: 14px; font-weight: 700; color: var(--ink); }
.log-list div { padding: 6px 0; border-bottom: 1px dashed rgba(0,0,0,.12); }

/* Online */
.code { font-family: 'Lilita'; font-size: 48px; letter-spacing: 8px; color: var(--ink); text-align: center; background: #fff; border: 3px dashed var(--ink); border-radius: 16px; padding: 6px; }
.code-in { width: 100%; font-family: 'Lilita'; font-size: 36px; letter-spacing: 8px; text-align: center; text-transform: uppercase; border: 3px solid var(--ink); border-radius: 14px; padding: 8px; outline: none; color: var(--ink); }
.net-status { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }

/* Game over */
.podium { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.podium .pl { display: flex; align-items: center; gap: 10px; padding: 8px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; }
.podium .pl.w { background: #fff2c2; }
.podium .rk { font-family: 'Lilita'; font-size: 24px; width: 30px; text-align: center; color: var(--ink); }
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.award { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px; font-size: 12px; color: var(--muted); }
.award b { display: block; color: var(--ink); font-size: 14px; }
.award i { font-style: normal; font-size: 20px; float: right; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* Help */
.help-grid { display: grid; gap: 8px; }
.help-item { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; }
.help-item i { font-style: normal; font-size: 26px; flex: none; width: 34px; text-align: center; }
.help-item b { display: block; color: var(--ink); }
.help-item span { font-size: 13px; color: var(--muted); font-weight: 700; }
.kbd { display: inline-block; background: var(--yellow); border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; color: var(--ink); }

/* Pass device */
.pass { position: fixed; inset: 0; z-index: 48; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(8,16,12,.86); }
.pass .tok { width: 110px; height: 110px; font-size: 60px; border-width: 5px; }
.pass h1 { color: var(--yellow); font-size: 40px; text-shadow: 0 3px 0 var(--orange), 0 6px 0 var(--ink); text-align: center; padding: 0 12px; }

/* SVG board classes */
.tgt { fill: rgba(255,200,61,.55); stroke: #1b120c; stroke-width: 4; cursor: pointer; animation: tg 1s ease-in-out infinite; }
@keyframes tg { 50% { fill: rgba(255,200,61,.25); } }
.tk-inner { transform-box: fill-box; transform-origin: center; }
.tk-active .tk-inner { animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) scale(1.06); } }

@media (orientation: landscape) and (min-width: 720px) {
  .gmain { flex-direction: row; }
  #game .gbody { flex-direction: row !important; }
  #game .hud { width: 360px; justify-content: flex-end; }
  .players-strip { flex-wrap: wrap; overflow: visible; }
}
@media (max-height: 640px) { .dice-btn { width: 78px; height: 78px; } .card { width: 50px; height: 64px; } }
