/* ===== SLIXIT — "toy / sticker" light theme =====
   Cream paper background, ink outlines with hard offset shadows, a dark board tray so the blocks pop.
   Navigation is a floating bottom tab bar; chat is a slide-in drawer. */
:root {
  --bg: #f3eee4;
  --bg-dot: #e4dccb;
  --paper: #fffdf8;
  --paper-2: #f8f3e8;
  --ink: #1f1d2b;
  --ink-2: #4a4860;
  --muted: #7a7790;
  --line: #1f1d2b;
  --coral: #ff5a5f;
  --coral-2: #ff8a8d;
  --teal: #1fb8a6;
  --teal-2: #7fe0d3;
  --yellow: #ffcf4a;
  --sky: #4cc3f5;
  --sky-2: #9be1fb;
  --amber: #ffb02e;
  --amber-2: #ffd27f;
  --violet: #8b7cf6;
  --ok: #2fb46a;
  --danger: #e4393e;
  --tray: #23213a;
  --tray-frame: #343152;
  --tray-grid: rgba(255,255,255,.07);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 8px 8px 0 var(--ink);
  --radius: 18px;
  --rail: 300px;
  --rail-gap: 24px;
  --font: "Pretendard Variable", Pretendard, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Noto Sans", sans-serif;
}
html:lang(ja) { --font: "Pretendard Variable", Pretendard, "Hiragino Sans", "Yu Gothic UI", Meiryo, "Segoe UI", system-ui, sans-serif; }
html:lang(zh) { --font: "Pretendard Variable", Pretendard, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif; }
html:lang(zh-TW) { --font: "Pretendard Variable", Pretendard, "PingFang TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif; }
html:lang(th) { --font: "Pretendard Variable", Pretendard, "Leelawadee UI", Thonburi, "Noto Sans Thai", "Segoe UI", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  padding-bottom: 110px;
}
a { color: inherit; }
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; max-width: 1180px; margin: 0 auto; }
.brand img { height: 44px; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.fw-chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-size: 12px; font-weight: 800; letter-spacing: .04em; padding: 7px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); box-shadow: var(--shadow-sm); }
.fw-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
.lang-select, select.sel { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 7px 10px; font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer; box-shadow: var(--shadow-sm); }
.lang-select { max-width: 130px; }

.account { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 6px 4px 4px; box-shadow: var(--shadow-sm); }
.account .avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--coral); color: #fff; font-weight: 900; font-size: 13px; border: 2px solid var(--ink); }
.account .who { display: flex; flex-direction: column; line-height: 1.1; }
.account .who b { font-size: 13px; }
.account .who small { color: var(--muted); font-size: 10px; }
.account .level-chip { background: var(--yellow); border: 2px solid var(--ink); font-weight: 900; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.account .btn { padding: 4px 10px; box-shadow: none; }

/* ---------- buttons ---------- */
.btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-sm); text-decoration: none;
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { background: #ff6d71; }
.btn-lg { padding: 14px 24px; font-size: 16px; border-radius: 16px; box-shadow: var(--shadow); }
.btn-lg:active { transform: translate(4px, 4px); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); }
.btn-icon { width: 38px; height: 38px; padding: 0; font-size: 15px; }

/* ---------- ads: 300×1050 portrait rails on both sides (same unit as the FaCer World home), 320×100 below the content on phones ----------
   The rails sit at the top of the page and scroll with it, like the home page. They appear when the window is
   wide enough to keep the game area usable (≥1500px). */
.ad-rail { display: none; position: absolute; top: 84px; z-index: 5; width: var(--rail); min-height: 1050px; }
.ad-rail.left { left: var(--rail-gap); } .ad-rail.right { right: var(--rail-gap); }
.ad-rail .ad-label { display: block; text-align: center; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .15em; margin-bottom: 8px; }
.ad-box { display: grid; place-items: center; border: 2px dashed rgba(31,29,43,.3); border-radius: 12px; background: rgba(255,255,255,.4); color: rgba(31,29,43,.4); font-size: 11px; letter-spacing: .12em; text-align: center; line-height: 1.8; font-weight: 700; }
.ad-rail .ad-box { width: 300px; height: 1050px; font-size: 14px; }
.ad-rail ins.adsbygoogle { display: block; width: 300px; min-height: 600px; }
@media (min-width: 1500px) {
  .ad-rail { display: block; }
  body { position: relative; min-height: 1180px; }
  .chat-fab { right: calc(var(--rail) + var(--rail-gap) + 22px); }
}
.ad-mobile { display: none; justify-content: center; padding: 10px 16px 0; }
.ad-mobile .ad-box { width: 320px; height: 100px; }
.ad-mobile ins.adsbygoogle { display: inline-block; width: 320px; height: 100px; }
@media (max-width: 820px) { .ad-mobile { display: flex; } }

/* ---------- layout ---------- */
#app { max-width: 1180px; margin: 0 auto; padding: 10px 24px 30px; }
@media (min-width: 1500px) { #app, .topbar, footer { max-width: min(1180px, calc(100vw - 2 * (var(--rail) + var(--rail-gap) + 16px))); } }
.screen { display: none; animation: rise .28s cubic-bezier(.2,.9,.3,1.2); }
.screen.is-active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
footer { max-width: 1180px; margin: 0 auto; padding: 0 24px 20px; color: var(--muted); font-size: 12px; text-align: center; font-weight: 600; }

.card { background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 900; letter-spacing: .02em; text-transform: uppercase; }
.card-body { padding: 14px 18px 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: 10px 0 8px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-line { color: var(--ink-2); font-size: 13px; margin: 0 0 14px; max-width: 720px; line-height: 1.6; }
.empty { color: var(--muted); font-size: 13px; padding: 12px 0; text-align: center; font-weight: 600; }

/* segmented control */
.seg { display: inline-flex; gap: 0; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); box-shadow: var(--shadow-sm); overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 9px 16px; font-weight: 800; font-size: 13px; cursor: pointer; color: var(--ink-2); border-right: 2px solid var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.is-active { background: var(--ink); color: #fff; }
.seg button.c-easy.is-active { background: var(--teal); color: var(--ink); } .seg button.c-medium.is-active { background: var(--sky); color: var(--ink); }
.seg button.c-hard.is-active { background: var(--amber); color: var(--ink); } .seg button.c-expert.is-active { background: var(--coral); color: #fff; }

/* ---------- bottom tab bar ---------- */
.tabbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 70; display: flex; gap: 4px; padding: 6px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 72px; padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; font-size: 11px; font-weight: 800; color: var(--ink-2); cursor: pointer; }
.tabbar button .ico { font-size: 18px; line-height: 1; }
.tabbar button.is-active { background: var(--ink); color: #fff; }
body.in-game .tabbar { display: none; }

/* ---------- lobby bento ---------- */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(120px, auto); gap: 18px; margin-top: 8px; }
.hero-card { grid-column: span 6; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 20px; padding: 28px; overflow: hidden; background: var(--paper); }
.hero-card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,207,74,.25), transparent 45%, rgba(76,195,245,.2)); pointer-events: none; border-radius: inherit; }
.hero-text { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 12px; min-width: 0; }
.hero-logo { width: min(400px, 100%); height: auto; display: block; }
.tagline { color: var(--coral); font-weight: 900; letter-spacing: .3em; font-size: 12px; }
.hero-text p { margin: 0; color: var(--ink-2); max-width: 520px; line-height: 1.65; font-size: 15px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.progress-line { font-size: 12px; color: var(--muted); font-weight: 700; }
.hero-board { position: relative; width: 100%; max-width: 360px; aspect-ratio: 1 / 1; justify-self: center; align-self: center; transform: rotate(3deg); }
.card-account { grid-column: span 2; }
.card-rank { grid-column: span 2; }
.card-action { grid-column: span 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; padding: 18px; text-align: left; cursor: pointer; transition: transform .08s ease, box-shadow .08s ease; }
.card-action:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.card-action:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.card-action .big-ico { font-size: 34px; margin-bottom: auto; }
.card-action .label { font-size: 16px; font-weight: 900; }
.card-action .sub { font-size: 11px; color: var(--ink-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.vs-card { background: var(--sky); }
.random-card { background: var(--yellow); }

.profile { display: flex; flex-direction: column; gap: 12px; }
.profile .row { display: flex; align-items: center; gap: 12px; }
.avatar-lg { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--coral); color: #fff; font-weight: 900; font-size: 20px; border: 2px solid var(--ink); flex: none; }
.profile .name { font-size: 16px; font-weight: 900; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat .v { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 11px; color: var(--muted); font-weight: 700; }
.stat .k { font-size: 10px; color: var(--muted); letter-spacing: .05em; font-weight: 700; text-transform: uppercase; }
.exp-bar { height: 12px; background: var(--paper-2); border-radius: 999px; overflow: hidden; border: 2px solid var(--ink); }
.exp-bar i { display: block; height: 100%; background: repeating-linear-gradient(135deg, var(--teal) 0 8px, var(--teal-2) 8px 16px); width: 0; transition: width .4s ease; }

.rank-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-mini li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--paper-2); border: 2px solid transparent; font-size: 13px; font-weight: 600; }
.rank-mini li.me { border-color: var(--coral); }
.rank-mini .r { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 12px; background: var(--ink); color: #fff; }
.rank-mini li:nth-child(1) .r { background: var(--yellow); color: var(--ink); } .rank-mini li:nth-child(2) .r { background: #d9d9e3; color: var(--ink); } .rank-mini li:nth-child(3) .r { background: var(--amber-2); color: var(--ink); }
.rank-mini .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-mini .e { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }

/* ---------- stages ---------- */
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.stage-tile { position: relative; aspect-ratio: 1 / 1; border: 2px solid var(--ink); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow-sm); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; transition: transform .08s ease, box-shadow .08s ease; }
.stage-tile:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.stage-tile:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.stage-tile:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); background: var(--paper-2); }
.stage-tile .num { font-size: 30px; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.stage-tile .mini-stars { font-size: 13px; letter-spacing: 1px; color: #d8d3c6; }
.stage-tile .mini-stars b { color: var(--amber); font-weight: 400; }
.stage-tile .par { font-size: 11px; color: var(--muted); font-weight: 700; }
.stage-tile .pts { position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 900; background: var(--yellow); border: 2px solid var(--ink); border-radius: 999px; padding: 1px 6px; }
.stage-tile.cleared { background: #fff; }
.stage-tile.cleared.perfect { background: #fff8dc; }
.stage-tile .lock { position: absolute; top: 8px; right: 8px; font-size: 13px; }
.stage-tile.current { outline: 3px solid var(--coral); outline-offset: 3px; }

/* ---------- ranking ---------- */
.rank-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
table.rank { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 14px; }
table.rank th { text-align: left; color: var(--muted); font-weight: 800; font-size: 11px; padding: 4px 10px; text-transform: uppercase; letter-spacing: .06em; }
table.rank td { padding: 10px; background: var(--paper-2); font-variant-numeric: tabular-nums; font-weight: 600; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
table.rank td:first-child { border-left: 2px solid transparent; border-radius: 12px 0 0 12px; }
table.rank td:last-child { border-right: 2px solid transparent; border-radius: 0 12px 12px 0; }
table.rank tr.me td { border-color: var(--coral); background: #fff0f0; }
table.rank td.r { font-weight: 900; width: 48px; }
table.rank td.num, table.rank th.num { text-align: right; }
table.rank td.num b { font-weight: 900; }

/* ---------- game ---------- */
.game-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.game-top .title { font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.game-top .title small { color: var(--muted); font-weight: 800; letter-spacing: .1em; font-size: 11px; text-transform: uppercase; }
.game-top .actions { margin-left: auto; display: flex; gap: 6px; }
.game-layout { max-width: 640px; margin: 0 auto; }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.chip { background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 8px 10px; display: flex; flex-direction: column; align-items: center; box-shadow: var(--shadow-sm); }
.chip .k { font-size: 10px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.chip .v { font-size: 20px; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; text-align: center; }
.chip .v small { font-size: 11px; color: var(--muted); font-weight: 700; display: block; }
.chip-score { background: var(--yellow); }

.board-wrap { position: relative; display: flex; justify-content: center; }
.board-host { position: relative; width: min(100%, 58vh, 520px); aspect-ratio: 1 / 1; }
.board-frame { position: absolute; inset: 0; }
.board { position: absolute; inset: 0; background: var(--tray); border: 10px solid var(--tray-frame); border-radius: 24px; outline: 2px solid var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; touch-action: none; }
.grid-lines { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(var(--tray-grid) 1.5px, transparent 1.6px); background-size: calc(100% / 6) calc(100% / 6); background-position: calc(100% / 12) calc(100% / 12); }
.pieces { position: absolute; inset: 0; }
.exit { position: absolute; right: -2px; top: calc(10px + (100% - 20px) * 2 / 6); width: 14px; height: calc((100% - 20px) / 6); background: var(--bg); border-radius: 0 6px 6px 0; display: flex; align-items: center; justify-content: center; color: var(--ink); font-size: 22px; font-weight: 900; pointer-events: none; transition: color .2s; }
.exit.open { color: var(--coral); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

.piece { position: absolute; transition: left .18s cubic-bezier(.2,.8,.2,1), top .18s cubic-bezier(.2,.8,.2,1); will-change: left, top; cursor: grab; }
.board.static .piece { cursor: default; }
.piece.dragging { transition: none; cursor: grabbing; z-index: 5; }
.piece.exiting { transition: left .45s cubic-bezier(.4,0,.8,1); }
.piece .body { position: absolute; inset: 4px; border-radius: 10px; background: var(--c1); border: 2px solid var(--ink); box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.35); }
.piece .body::after { content: ''; position: absolute; left: 10px; right: 10px; top: 6px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.35); }
.piece.v .body::after { left: 6px; right: auto; top: 10px; bottom: 10px; width: 4px; height: auto; }
.piece.h { --c1: var(--sky); }
.piece.v { --c1: var(--amber); }
.piece.is-hero { --c1: var(--coral); z-index: 2; }
.piece.is-hero .body::before { content: "›"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #fff; font-weight: 900; font-size: 26px; line-height: 1; }
.piece.dragging .body { box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.35), 0 10px 18px rgba(0,0,0,.45); }
.piece.hint .body { animation: hintPulse .6s ease-in-out 3; outline: 3px solid #fff; outline-offset: 2px; }
.piece.hint.dir-right .body { animation-name: nudgeRight; } .piece.hint.dir-left .body { animation-name: nudgeLeft; }
.piece.hint.dir-down .body { animation-name: nudgeDown; } .piece.hint.dir-up .body { animation-name: nudgeUp; }
@keyframes hintPulse { 50% { filter: brightness(1.2); } }
@keyframes nudgeRight { 50% { transform: translateX(10px); } } @keyframes nudgeLeft { 50% { transform: translateX(-10px); } }
@keyframes nudgeDown { 50% { transform: translateY(10px); } } @keyframes nudgeUp { 50% { transform: translateY(-10px); } }

.mini-board { position: relative; width: 100%; max-width: 240px; aspect-ratio: 1 / 1; }
.mini-board .board { border-width: 5px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.mini-board .piece .body { inset: 2px; border-radius: 4px; border-width: 1px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.18); }
.mini-board .piece .body::after, .mini-board .piece.is-hero .body::before { display: none; }
.mini-board .exit { width: 8px; right: -1px; font-size: 12px; top: calc(5px + (100% - 10px) * 2 / 6); height: calc((100% - 10px) / 6); border-radius: 0 3px 3px 0; }
.hero-board .board { border-width: 10px; border-radius: 22px; box-shadow: var(--shadow); }
.hero-board .piece .body::after { display: none; }

.ready { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 6px; background: rgba(243,238,228,.55); z-index: 5; pointer-events: none; text-align: center; border-radius: 24px; }
.ready.show { display: flex; }
.ready .stage { font-size: 12px; letter-spacing: .3em; color: var(--coral); font-weight: 900; animation: ready-in .4s ease-out both; }
.ready .name { font-size: 22px; font-weight: 900; animation: ready-in .4s .05s ease-out both; }
.ready .word { font-size: clamp(44px, 10vw, 80px); font-weight: 900; letter-spacing: .04em; margin-top: 8px; color: var(--paper); -webkit-text-stroke: 3px var(--ink); text-shadow: 6px 6px 0 var(--ink); animation: ready-pop .5s cubic-bezier(.2,1.4,.4,1) both; }
.ready .word.go { color: var(--yellow); }
@keyframes ready-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ready-pop { from { opacity: 0; transform: scale(2.2) rotate(-6deg); } to { opacity: 1; transform: scale(1); } }
.board-wrap .toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 6; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.board-wrap .toast.show { opacity: 1; }
.confetti { position: absolute; inset: -20px; pointer-events: none; overflow: hidden; z-index: 7; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; border: 1px solid var(--ink); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(120vh) rotate(720deg); opacity: .6; } }

.howto { text-align: center; color: var(--ink-2); font-size: 13px; font-weight: 700; margin: 16px 0 0; min-height: 18px; }
.controls { display: flex; justify-content: center; gap: 18px; margin: 14px auto 0; }
.ctrl { display: flex; flex-direction: column; align-items: center; gap: 6px; background: transparent; border: 0; cursor: pointer; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.ctrl .ico { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); transition: transform .08s ease, box-shadow .08s ease; }
.ctrl:hover .ico { background: var(--paper-2); }
.ctrl:active .ico { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.ctrl:disabled { opacity: .4; cursor: default; }
.ctrl:disabled .ico { transform: none; box-shadow: var(--shadow); }
.ctrl-hint .ico { background: var(--yellow); }
.help { color: var(--muted); font-size: 12px; text-align: center; margin: 16px 0 0; line-height: 1.9; font-weight: 600; }
kbd { background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; font-family: inherit; font-size: 11px; font-weight: 800; box-shadow: 2px 2px 0 var(--ink); margin: 0 1px; }
@media (pointer: coarse), (max-width: 820px) { .help { display: none; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(31,29,43,.55); backdrop-filter: blur(3px); }
.modal.show { display: flex; }
.modal-card { width: min(440px, 100%); padding: 26px; box-shadow: var(--shadow-lg); animation: pop .25s cubic-bezier(.2,1.4,.4,1); overflow: hidden; }
@keyframes pop { from { transform: scale(.85) rotate(-1deg); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-band { position: absolute; left: 0; right: 0; top: 0; height: 12px; background: repeating-linear-gradient(135deg, var(--coral) 0 10px, var(--coral-2) 10px 20px); border-bottom: 2px solid var(--ink); }
.modal-band.band-yellow { background: repeating-linear-gradient(135deg, var(--yellow) 0 10px, #ffe08a 10px 20px); }
.modal-band.band-teal { background: repeating-linear-gradient(135deg, var(--teal) 0 10px, var(--teal-2) 10px 20px); }
.modal-band.band-sky { background: repeating-linear-gradient(135deg, var(--sky) 0 10px, var(--sky-2) 10px 20px); }
.modal h2 { margin: 10px 0 6px; font-size: 26px; font-weight: 900; }
.modal h2.accent { color: var(--coral); }
.modal p { margin: 6px 0; color: var(--ink-2); line-height: 1.6; font-size: 14px; }
.modal p b { color: var(--ink); }
.modal .btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.form label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; font-weight: 700; }
.form input { background: var(--paper-2); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-family: inherit; font-weight: 600; }
.form input:focus { outline: none; box-shadow: 3px 3px 0 var(--coral); }
.form .err { color: var(--danger); font-size: 13px; min-height: 18px; font-weight: 700; }
.stars { font-size: 42px; letter-spacing: 6px; color: #e3ddcf; margin: 4px 0 0; text-align: center; -webkit-text-stroke: 1.5px var(--ink); }
.stars span.on { color: var(--yellow); animation: starPop .4s cubic-bezier(.2,1.6,.4,1) both; }
.stars span:nth-child(2).on { animation-delay: .15s; } .stars span:nth-child(3).on { animation-delay: .3s; }
@keyframes starPop { from { transform: scale(0) rotate(-30deg); } }
.score-big { text-align: center; margin: 6px 0 4px; }
.score-big .v { font-size: 46px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -.02em; }
.score-big .v small { font-size: 14px; color: var(--muted); font-weight: 700; }
.score-big .k { color: var(--ink-2); font-size: 12px; margin-top: 4px; font-weight: 700; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.exp-gain { color: var(--teal); font-weight: 900; }
.diff-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.btn-diff { justify-content: space-between; padding: 14px 18px; }
.btn-diff small { color: var(--muted); font-weight: 700; }
.btn-diff[data-diff="easy"] { background: var(--teal-2); } .btn-diff[data-diff="medium"] { background: var(--sky-2); } .btn-diff[data-diff="hard"] { background: var(--amber-2); }

/* ---------- versus ---------- */
.vs-top { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; margin-bottom: 18px; }
.vs-mecard { background: var(--sky); border: 2px solid var(--ink); border-radius: 18px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
.vs-mecard .k { font-size: 10px; letter-spacing: .1em; font-weight: 900; text-transform: uppercase; }
.vs-mecard .v { font-size: 34px; font-weight: 900; }
.vs-actions { display: flex; flex-direction: column; gap: 12px; }
.vs-create, .vs-join { display: flex; gap: 8px; align-items: center; }
.vs-create .sel { flex: 1; min-width: 0; }
.code-input { width: 120px; text-transform: uppercase; letter-spacing: .3em; font-weight: 900; text-align: center; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 9px 10px; font-size: 15px; font-family: inherit; box-shadow: var(--shadow-sm); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 8px; }
.section-head h2 { margin: 0; font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-row { display: grid; grid-template-columns: 76px 1fr auto auto; gap: 12px; align-items: center; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow-sm); }
.room-row.playing { opacity: .6; }
.room-code { font-weight: 900; letter-spacing: .2em; font-size: 15px; }
.room-info { font-weight: 700; }
.room-state { font-size: 12px; color: var(--muted); font-weight: 700; }
.code-chip { background: var(--yellow); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 10px; letter-spacing: .25em; font-size: 16px; font-weight: 900; }
.room-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, .8fr); gap: 18px; }
.room-body { display: flex; flex-direction: column; gap: 14px; }
.room-players { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.player-card { display: flex; align-items: center; gap: 10px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 14px; padding: 12px; }
.player-card.empty-slot { border-style: dashed; opacity: .8; }
.player-card .name { font-weight: 900; }
.vs-mark { font-weight: 900; color: var(--coral); font-size: 20px; letter-spacing: .1em; -webkit-text-stroke: 1px var(--ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c9c6d6; margin-right: 4px; border: 1px solid var(--ink); }
.dot.on { background: var(--ok); }
.room-stage-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.room-stage-row .sel { flex: 1; min-width: 0; }
.room-actions { display: flex; align-items: center; gap: 12px; }
.room-preview-card .card-body { display: flex; justify-content: center; align-items: center; min-height: 200px; }

.vs-panel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; padding: 10px 14px; margin-bottom: 14px; }
.vs-panel .k { font-size: 10px; color: var(--muted); letter-spacing: .08em; font-weight: 900; text-transform: uppercase; }
.vs-panel .v { font-size: 14px; font-weight: 800; }
.vs-side.vs-opp { display: flex; align-items: center; justify-content: flex-end; gap: 12px; text-align: right; }
.vs-side.vs-opp .mini-board { width: 92px; flex: none; }
.vs-center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vs-timer { font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.vs-timer.low { color: var(--danger); animation: blink 1s steps(2) infinite; }
.vsr-title { margin: 10px 0 6px; font-size: 32px; font-weight: 900; }
.vsr-title.win { color: var(--teal); } .vsr-title.lose { color: var(--danger); } .vsr-title.draw { color: var(--muted); }
.vsr-rows { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 6px; }
.vsr-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; font-size: 14px; font-weight: 700; }
#vsr-rating .up { color: var(--ok); } #vsr-rating .down { color: var(--danger); }

/* ---------- chat: FAB + drawer ---------- */
.chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 72; width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--ink); background: var(--teal); box-shadow: var(--shadow); font-size: 24px; cursor: pointer; display: grid; place-items: center; transition: transform .08s ease, box-shadow .08s ease; }
.chat-fab:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.chat-badge { position: absolute; top: -6px; right: -6px; background: var(--coral); color: #fff; font-size: 11px; font-weight: 900; border-radius: 999px; padding: 1px 7px; border: 2px solid var(--ink); }
.chat-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 90; background: var(--paper); border-left: 2px solid var(--ink); box-shadow: -8px 0 0 rgba(31,29,43,.08); display: flex; flex-direction: column; transform: translateX(105%); transition: transform .25s cubic-bezier(.2,.9,.3,1); }
.chat-drawer.open { transform: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 2px solid var(--ink); font-weight: 900; font-size: 15px; background: var(--teal-2); }
.chat-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.chat-msg { display: block; line-height: 1.45; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 14px 14px 14px 4px; padding: 7px 10px; max-width: 92%; align-self: flex-start; }
.chat-msg.me { align-self: flex-end; background: #fff0f0; border-radius: 14px 14px 4px 14px; }
.chat-msg .who { color: var(--teal); font-weight: 900; margin-right: 6px; }
.chat-msg.me .who { color: var(--coral); }
.chat-msg .txt { word-break: break-word; user-select: text; -webkit-user-select: text; font-weight: 600; }
.chat-msg .when { color: var(--muted); font-size: 10px; margin-left: 6px; }
.chat-sys { color: var(--muted); font-size: 12px; text-align: center; padding: 2px 0; font-weight: 700; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 2px solid var(--ink); }
.chat-form input { flex: 1; min-width: 0; background: var(--paper-2); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 9px 12px; font-size: 14px; font-family: inherit; font-weight: 600; }
.chat-form input:focus { outline: none; box-shadow: 3px 3px 0 var(--teal); }
.chat-form input:disabled { opacity: .6; }
body.chat-open .chat-fab { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .bento { grid-template-columns: repeat(4, 1fr); }
  .hero-card { grid-column: span 4; }
  .card-account, .card-rank { grid-column: span 2; }
  .card-action { grid-column: span 2; }
}
@media (max-width: 820px), (pointer: coarse) {
  .chat-drawer { top: auto; width: 100%; height: 62vh; height: 62dvh; max-height: 480px; border-left: 0; border-top: 2px solid var(--ink); border-radius: 20px 20px 0 0; transform: translateY(105%); }
  .chat-drawer.open { transform: none; }
  .chat-form input { font-size: 16px; }
  .vs-top { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: 1fr; }
  .room-players { grid-template-columns: 1fr; }
  .vs-mark { text-align: center; }
  .vs-panel { grid-template-columns: 1fr 1fr; }
  .vs-center { grid-column: 1 / -1; order: -1; flex-direction: row; justify-content: center; gap: 12px; }
  .room-row { grid-template-columns: 64px 1fr auto; }
  .room-row .room-state { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .brand img { height: 34px; }
  .fw-chip { padding: 6px 9px; font-size: 11px; }
  .fw-chip .lbl { display: none; }
  .fw-chip .dot { width: 10px; height: 10px; }
  .account .who { display: none; }
  .lang-select { max-width: 90px; padding: 6px 6px; }
  #app { padding: 8px 14px 30px; }
  .bento { grid-template-columns: 1fr 1fr; gap: 12px; }
  .hero-card { grid-column: span 2; grid-template-columns: 1fr; padding: 20px; }
  .hero-board { max-width: 280px; transform: none; }
  .card-account, .card-rank { grid-column: span 2; }
  .card-action { grid-column: span 1; }
  .page-head h1 { font-size: 22px; }
  .hud { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .chip { padding: 6px 4px; border-radius: 12px; }
  .chip .v { font-size: 16px; }
  .board-host { width: min(100%, 64vh); }
  .controls { gap: 14px; }
  .ctrl .ico { width: 58px; height: 58px; }
  .tabbar button { min-width: 60px; padding: 5px 8px; }
  .chat-fab { right: 14px; bottom: 86px; width: 50px; height: 50px; font-size: 20px; }
  body.in-game .chat-fab { bottom: 18px; }
  .stage-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
  .stage-tile .num { font-size: 24px; }
}

/* lobby demo: highlight the block that is sliding */
.hero-board .piece { transition: left .5s cubic-bezier(.3,.9,.3,1), top .5s cubic-bezier(.3,.9,.3,1); }
.hero-board .piece.exiting { transition: left .6s cubic-bezier(.4,0,.8,1); }
.hero-board .piece.demo-move .body { outline: 3px solid #fff; outline-offset: 1px; filter: brightness(1.12); }

/* ===== chat: lobby card (inline) + who's online ===== */
.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list { min-height: 0; }
.online-pill { margin-left: auto; margin-right: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900; padding: 3px 9px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); white-space: nowrap; }
.online-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); border: 1px solid var(--ink); }
.chat-online { flex: none; display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; border-bottom: 2px solid var(--ink); background: var(--paper-2); scrollbar-width: thin; }
.who-chip { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font-size: 12px; font-weight: 800; white-space: nowrap; flex: none; }
.who-chip em { font-style: normal; font-size: 11px; margin-left: 3px; }
.who-chip.me { background: var(--yellow); }
.who-chip.guest, .who-chip.more { border-style: dashed; color: var(--muted); }

.chat-slot { grid-column: span 4; grid-row: span 2; height: 440px; padding: 0; overflow: hidden; }
.card-rank { grid-column: span 6; }
.card-rank .rank-mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.chat-drawer.inline { position: relative; top: auto; right: auto; bottom: auto; width: auto; height: 100%; max-height: none; z-index: auto; transform: none; transition: none; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.chat-drawer.inline #chat-close { display: none; }
.chat-drawer.inline .online-pill { margin-right: 0; }
.chat-drawer.inline .chat-form { padding-bottom: 10px; }
body.chat-inline .chat-fab { display: none; }
@media (min-width: 761px) {
  /* desktop lobby card: online list as a side column */
  .chat-drawer.inline .chat-main { flex-direction: row-reverse; }
  .chat-drawer.inline .chat-online { flex-direction: column; width: 172px; overflow-x: hidden; overflow-y: auto; border-bottom: 0; border-left: 2px solid var(--ink); align-items: stretch; }
  .chat-drawer.inline .who-chip { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 1000px) {
  .chat-slot { grid-column: span 4; grid-row: auto; height: 420px; }
  .card-action { grid-column: span 1; }
  .card-rank { grid-column: span 4; }
}
@media (max-width: 760px) {
  .chat-slot { grid-column: span 2; height: 400px; }
  .card-rank { grid-column: span 2; }
}

/* the logo already carries the tagline */
.hero-text .tagline { display: none; }

/* lobby ranking card: overall / random / versus switch */
.card-rank .card-head { flex-wrap: wrap; }
.card-rank .card-head h2 { margin-right: auto; }
.seg-sm button { padding: 5px 11px; font-size: 11px; }
.profile .extra { font-size: 12px; font-weight: 700; color: var(--ink-2); text-align: center; }
