/* Monoline v3 — "ink on hanji" casual-game look.
   Layout: phone-first app shell. Lobby = app bar + scrolling tab pages + bottom tab bar; game = full-height board.
   One deliberate light look (the board themes from the shop add other moods, including a night theme). */
:root {
  --paper: #eceee9;
  --paper-2: #e2e5de;
  --surface: #fbfbf7;
  --ink: #1b1e21;
  --ink-2: #33383d;
  --muted: #6a706b;
  --line: #1b1e21;
  --line-bleed: rgba(27, 30, 33, .14);
  --wash: rgba(27, 30, 33, .085);
  --seal: #c63a2e;
  --seal-dk: #8f2219;
  --gold: #e8b021;
  --gold-dk: #a87405;
  --s1: #3f8a68; --s2: #b07c16; --s3: #b5432f; --s4: #4659b0; --s5: #5d5a8a;
  --mtn: #7b837d; --mtn-hi: #aab1ab;
  --fog: #d6dad4;
  --goblin: #2a2d31;
  --gold-key: #c9971a; --jade: #2b9a77; --violet: #7a5bd4; --teal: #1a9cb0; --rose: #cf507a;
  --star: #e3a51b;
  --b-bg: var(--surface); --b-cell: var(--paper); --b-wash: var(--wash); --dot: var(--muted);
  --shadow: 0 1px 2px rgba(27, 30, 33, .06), 0 10px 26px rgba(27, 30, 33, .08);
  --press: 0 4px 0 rgba(27, 30, 33, .16);
  --scrim: rgba(17, 19, 21, .5);
  --font-ui: "Jua", "Noto Sans KR", system-ui, -apple-system, sans-serif;
  --font-brush: "Nanum Brush Script", "Jua", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { height: 100%; background: var(--paper); }
body {
  margin: 0; min-height: 100%; color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.5;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .11 0 0 0 0 .1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--seal); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
h1, h2, h3 { font-weight: 400; text-wrap: balance; margin: 0; }

.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.screen { display: flex; flex-direction: column; gap: 14px; }
#home { flex: 1; padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }

/* ---------- icons (inline SVG) ---------- */
.coin-ico, .q-ico, .t-ico, .i-ico { display: inline-block; background: no-repeat center / contain; flex: none; }
.coin-ico { width: 22px; height: 22px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='13' r='10' fill='%23a87405'/%3E%3Ccircle cx='12' cy='11.5' r='10' fill='%23ffcf3a'/%3E%3Ccircle cx='12' cy='11.5' r='6.5' fill='none' stroke='%23fff3b0' stroke-width='1.6'/%3E%3Cpath d='M9 13.5c1-3.5 3-4.2 3.6-2s2.3 2 3.4-2.3' fill='none' stroke='%23a87405' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); }
.q-ico { width: 40px; height: 40px; }
.q-ico.gift { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect x='6' y='16' width='28' height='19' rx='4' fill='%23c63a2e'/%3E%3Crect x='4' y='11' width='32' height='8' rx='3' fill='%23e05244'/%3E%3Crect x='17.5' y='11' width='5' height='24' fill='%23ffcf3a'/%3E%3Cpath d='M20 11c-3-6-10-6-9-1s9 1 9 1zM20 11c3-6 10-6 9-1s-9 1-9 1z' fill='none' stroke='%23ffcf3a' stroke-width='2.6'/%3E%3C/svg%3E"); }
.q-ico.chest { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M5 18a15 9 0 0130 0v3H5z' fill='%238a4b22'/%3E%3Crect x='5' y='19' width='30' height='16' rx='3' fill='%23a85e2c'/%3E%3Crect x='5' y='19' width='30' height='4' fill='%23e8b021'/%3E%3Crect x='17' y='21' width='6' height='8' rx='1.5' fill='%23ffcf3a' stroke='%23a87405' stroke-width='1.2'/%3E%3Cpath d='M30 6l1.2 2.6 2.8.4-2 2 .5 2.8-2.5-1.3-2.5 1.3.5-2.8-2-2 2.8-.4z' fill='%23ffcf3a'/%3E%3C/svg%3E"); }
.t-ico { width: 30px; height: 30px; opacity: .55; transition: transform .15s, opacity .15s; }
.t-ico.home { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M4 14L15 5l11 9v11a2 2 0 01-2 2H6a2 2 0 01-2-2z' fill='%231b1e21'/%3E%3Crect x='12' y='18' width='6' height='9' rx='1.5' fill='%23c63a2e'/%3E%3C/svg%3E"); }
.t-ico.shop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M5 10h20l-2 16H7z' fill='%231b1e21'/%3E%3Cpath d='M10 11V8a5 5 0 0110 0v3' fill='none' stroke='%231b1e21' stroke-width='2.6' stroke-linecap='round'/%3E%3Ccircle cx='15' cy='18' r='4' fill='%23ffcf3a'/%3E%3C/svg%3E"); }
.t-ico.rank { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M8 4h14v7a7 7 0 01-14 0z' fill='%23e8b021'/%3E%3Cpath d='M8 7H4a4 4 0 004 5M22 7h4a4 4 0 01-4 5' fill='none' stroke='%23e8b021' stroke-width='2.4'/%3E%3Crect x='13' y='17' width='4' height='6' fill='%231b1e21'/%3E%3Crect x='8' y='23' width='14' height='4' rx='1.5' fill='%231b1e21'/%3E%3C/svg%3E"); }
.t-ico.group { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Ccircle cx='11' cy='10' r='5' fill='%231b1e21'/%3E%3Cpath d='M2 26a9 9 0 0118 0z' fill='%231b1e21'/%3E%3Ccircle cx='21' cy='11' r='4' fill='%23c63a2e'/%3E%3Cpath d='M17 26a7.5 7.5 0 0112.5-5.5V26z' fill='%23c63a2e'/%3E%3C/svg%3E"); }
.i-ico { width: 24px; height: 24px; }
.i-ico.eraser, .ico-e { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 15l9-9 7 7-6 6H8z' fill='%23f28aa0'/%3E%3Cpath d='M3 15l5 5h5l-6-6z' fill='%233a6fd6'/%3E%3Cpath d='M12 20h9' stroke='%231b1e21' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.i-ico.charm, .ico-h { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='2' width='12' height='20' rx='1' fill='%23ffd84a' stroke='%23d9a21b'/%3E%3Cpath d='M12 5v14M9 8h6M8.5 12c2 1 5 1 7 0M9 16l6-2' stroke='%23c63a2e' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); }
.ico-c { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='13' r='10' fill='%23a87405'/%3E%3Ccircle cx='12' cy='11.5' r='10' fill='%23ffcf3a'/%3E%3Ccircle cx='12' cy='11.5' r='6.5' fill='none' stroke='%23fff3b0' stroke-width='1.6'/%3E%3C/svg%3E"); }
.ico-c, .ico-e, .ico-h { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -.25em; background-repeat: no-repeat; background-size: contain; }

/* ---------- app bar ---------- */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; padding-bottom: 6px;
  background: linear-gradient(var(--paper) 75%, transparent); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.appbar-right { display: flex; align-items: center; gap: 6px; }
.nick-pill { display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px; padding: 4px 14px 4px 4px; min-width: 0; max-width: 46%; }
.nick-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--paper-2); object-fit: cover; flex: none; }
.coin-pill { display: inline-flex; align-items: center; gap: 5px; background: var(--ink); color: #ffe48a; border-radius: 999px; padding: 6px 12px 6px 7px; box-shadow: var(--shadow); }
.coin-pill b { font-weight: 400; font-size: 1.02rem; min-width: 2ch; }
.coin-pill.bump { animation: bumpy .3s; }
.coin-pill.small { padding: 5px 10px 5px 6px; }
.coin-pill.small .coin-ico { width: 18px; height: 18px; }
.topbar .gtitle { order: 0; }
@keyframes bumpy { 40% { transform: scale(1.15); } }
.lang-seg { display: inline-flex; background: var(--surface); border-radius: 12px; padding: 3px; box-shadow: var(--shadow); }
.lang-seg button { border: 0; background: transparent; padding: 6px 8px; border-radius: 9px; font-size: .78rem; color: var(--muted); letter-spacing: .04em; }
.lang-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.icon-btn { width: 42px; height: 42px; flex: none; border: 0; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- pages & tab bar ---------- */
.pages { display: block; }
.page { display: none; flex-direction: column; gap: 14px; animation: fadein .2s; }
.page.on { display: flex; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; margin: 0 auto;
  padding: 6px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(27, 30, 33, .1); }
.tabbar button { position: relative; border: 0; background: none; display: grid; justify-items: center; gap: 1px; padding: 6px 0 2px; font-size: .78rem; color: var(--muted); border-radius: 14px; }
.tabbar button[aria-pressed="true"] { color: var(--ink); background: var(--paper); }
.tabbar button[aria-pressed="true"] .t-ico { opacity: 1; transform: translateY(-2px) scale(1.1); }
.dot { position: absolute; top: 4px; right: calc(50% - 22px); width: 10px; height: 10px; border-radius: 50%; background: var(--seal); border: 2px solid var(--surface); }
.quick-btn .dot { top: 8px; right: 10px; }

/* ---------- home ---------- */
.hero { display: grid; justify-items: center; text-align: center; gap: 2px; padding: 10px 0 4px; }
.hero-mark { width: 54px; height: 54px; transform: rotate(-4deg); filter: drop-shadow(0 6px 10px rgba(27, 30, 33, .2)); }
.wordmark { font-family: var(--font-brush); font-size: 4rem; line-height: .95; letter-spacing: .01em; margin-top: 4px; }
.tagline { margin: 0; color: var(--muted); font-size: .92rem; }
.play-card { border: 0; width: 100%; display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-radius: 22px; background: var(--seal); color: #fff; text-align: left;
  box-shadow: 0 6px 0 var(--seal-dk), 0 14px 26px rgba(198, 58, 46, .3); transition: transform .08s, box-shadow .08s; }
.play-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--seal-dk), 0 6px 14px rgba(198, 58, 46, .25); }
.play-ico { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: grid; place-items: center; flex: none; }
.play-ico svg { width: 26px; height: 26px; margin-left: 3px; }
.play-text { display: grid; min-width: 0; }
.play-text b { font-weight: 400; font-size: 1.6rem; line-height: 1.1; }
.play-text small { font-size: .9rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; }
.quick-btn { position: relative; border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: 18px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; text-align: left; font-size: 1rem; min-width: 0; }
.quick-btn:active { transform: scale(.98); }
.chest-text { display: grid; gap: 3px; flex: 1; min-width: 0; }
.chest-bar { height: 8px; border-radius: 6px; background: var(--paper-2); overflow: hidden; }
.chest-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--gold), #ffd86b); transition: width .4s; }
.chest-btn small { font-size: .74rem; color: var(--muted); }
.chest-btn.ready { background: linear-gradient(135deg, #fff6d6, var(--surface)); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(232, 176, 33, .35), var(--shadow); } }
.stats-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--ink); color: var(--paper); border-radius: 20px; padding: 14px 16px; }
.stats-card div { display: grid; min-width: 0; }
.stats-card b { font-weight: 400; font-size: 1.45rem; line-height: 1.15; }
.stats-card span { font-size: .74rem; opacity: .7; }
.account-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; font-size: .8rem; color: var(--muted); margin-top: -6px; padding: 0 4px; }
.section-title { font-size: 1.3rem; margin-top: 8px; }
.stages { display: grid; gap: 10px; }
.stage { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 20px; padding: 12px; box-shadow: var(--shadow); }
.stage .art { width: 70px; height: 70px; border-radius: 16px; background: color-mix(in srgb, var(--tc) 13%, var(--surface)); display: grid; place-items: center; }
.stage .art svg { width: 54px; height: 54px; }
.stage .body { min-width: 0; display: grid; gap: 1px; }
.stage .label { font-size: .74rem; color: var(--tc); letter-spacing: .04em; }
.stage h3 { font-size: 1.3rem; line-height: 1.15; }
.stage .subtitle { margin: 0; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .meta { font-size: .78rem; color: var(--muted); }
.stage .meta b { color: var(--ink); font-weight: 400; }
.stage .side { display: grid; gap: 6px; justify-items: end; }
.stage .info { border: 0; background: none; color: var(--muted); font-size: .76rem; padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px; }
.stage .go { border: 0; background: var(--tc); color: #fff; border-radius: 14px; padding: 9px 14px; font-size: .95rem; display: inline-flex; align-items: center; gap: 4px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--tc) 60%, #000); }
.stage .go:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--tc) 60%, #000); }
.stage .go svg { width: 12px; height: 12px; }
.foot-note { text-align: center; font-size: .74rem; color: var(--muted); margin: 4px 0 0; }

/* ---------- shop ---------- */
.shop-head { display: grid; gap: 10px; }
.shop-head .seg { display: grid; grid-template-columns: repeat(3, 1fr); }
.shop-head h2 { font-size: 1.7rem; }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 10px; font-size: .92rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.shop-desc { margin: -4px 2px 0; color: var(--muted); font-size: .85rem; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.shop-card { position: relative; border: 0; text-align: left; background: var(--surface); border-radius: 18px; padding: 10px; box-shadow: var(--shadow); display: grid; gap: 8px; }
.shop-card.cur { outline: 3px solid var(--ink); }
.shop-card .pv { aspect-ratio: 4 / 3; width: 100%; max-width: 100%; border-radius: 12px; overflow: hidden; display: block; }
.shop-card .pv svg { width: 100%; height: 100%; display: block; }
.shop-card .nm { font-size: 1.05rem; line-height: 1.1; }
.shop-card .act { display: flex; align-items: center; justify-content: center; gap: 4px; border-radius: 12px; padding: 7px 0; font-size: .9rem; background: var(--paper-2); }
.shop-card .act.buy { background: var(--ink); color: #ffe48a; }
.shop-card .act.poor { opacity: .55; }
.shop-card .act.on { background: transparent; color: var(--muted); }
.item-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); }
.item-row .i-ico { width: 52px; height: 52px; }
.item-row b { font-weight: 400; font-size: 1.1rem; display: block; }
.item-row small { color: var(--muted); font-size: .8rem; display: block; line-height: 1.4; }
.item-row .own { font-size: .78rem; color: var(--ink); background: var(--paper-2); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }
.buy-btn { border: 0; background: var(--ink); color: #ffe48a; border-radius: 14px; padding: 9px 12px; display: inline-flex; align-items: center; gap: 4px; font-size: .95rem; box-shadow: 0 3px 0 #000; }
.buy-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.buy-btn.poor { opacity: .5; }

/* ---------- groups ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.7rem; }
.section-actions { display: flex; gap: 6px; }
.chip-btn { border: 0; border-radius: 999px; padding: 8px 13px; font-size: .85rem; background: var(--surface); box-shadow: var(--shadow); }
.chip-btn.solid { background: var(--ink); color: var(--paper); }
.invite-banner { border: 0; text-align: left; background: color-mix(in srgb, var(--seal) 12%, var(--surface)); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.invite-banner::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--seal); flex: none; }
.groups { display: grid; gap: 10px; }
.group-card { border: 0; text-align: left; background: var(--surface); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 2px; }
.group-card b { font-weight: 400; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-card span { font-size: .8rem; color: var(--muted); }
.empty-card { background: var(--surface); border-radius: 18px; padding: 16px; font-size: .88rem; color: var(--muted); line-height: 1.6; }

/* ---------- ranking ---------- */
.card-panel { background: var(--surface); border-radius: 22px; padding: 16px 12px; box-shadow: var(--shadow); }
.rank-panel { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.rank-panel .rank-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; }
.rank-panel h2 { font-size: 1.7rem; }
.scopes { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; flex: none; }
.scopes::-webkit-scrollbar { display: none; }
.scopes button { border: 1.5px solid var(--paper-2); background: transparent; border-radius: 999px; padding: 6px 12px; font-size: .82rem; white-space: nowrap; color: var(--muted); }
.scopes button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.rank-meta { font-size: .76rem; color: var(--muted); padding: 0 4px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; min-height: 0; align-content: start; }
.rank-row { display: grid; grid-template-columns: 32px 38px 1fr auto; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 14px; }
.rank-row.me { background: var(--wash); }
.rank-row .pos { text-align: center; color: var(--muted); font-size: 1.05rem; }
.rank-row .pos.p1, .rank-row .pos.p2, .rank-row .pos.p3 { color: #fff; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .9rem; justify-self: center; }
.pos.p1 { background: var(--star); } .pos.p2 { background: #9aa3ad; } .pos.p3 { background: #b9784a; }
.rank-row .avatar { width: 38px; height: 38px; }
.rank-row .nm { min-width: 0; }
.rank-row .nm div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .nm div:last-child { font-size: .74rem; color: var(--muted); }
.rank-row .pt { font-size: 1.05rem; }
.tag { font-size: .66rem; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.tag.me { background: var(--ink); color: var(--paper); }
.tag.owner { background: color-mix(in srgb, var(--star) 25%, transparent); color: var(--ink); }
.empty { text-align: center; color: var(--muted); font-size: .88rem; padding: 28px 12px; line-height: 1.6; }

/* ---------- game ---------- */
body.in-game { height: 100%; overflow: hidden; }
body.in-game .app { height: 100%; padding-block: 10px calc(14px + env(safe-area-inset-bottom, 0px)); }
#game { flex: 1; min-height: 0; width: 100%; max-width: 820px; margin: 0 auto; gap: 12px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; }
.gtitle { text-align: center; flex: 1; min-width: 0; }
.g-stage { font-size: .82rem; color: var(--tc); letter-spacing: .04em; }
.g-lv { font-size: 1.5rem; line-height: 1.1; }
.hud { display: grid; gap: 8px; flex: none; }
.hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .86rem; color: var(--muted); flex-wrap: wrap; }
.hud-row b { color: var(--ink); font-weight: 400; font-size: 1.1rem; }
.hud-row .over { color: var(--s3); }
.hud-row .under { color: var(--s1); }
.try-pill { display: inline-block; font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); color: var(--ink); margin-right: 6px; vertical-align: 1px; }
.try-pill.first { background: color-mix(in srgb, var(--star) 30%, var(--surface)); }
.bar { height: 6px; background: var(--paper-2); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--tc); border-radius: 5px; transition: width .18s; }
.board-card { flex: 1; min-height: 0; display: grid; place-items: center; background: var(--b-bg); border-radius: 26px; padding: 10px; box-shadow: var(--shadow); position: relative; transition: background .3s; }
.board-card.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
svg#board { display: block; max-width: 100%; max-height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }

.c-cell { fill: var(--b-cell); transition: fill .15s; }
.c-cell.on { fill: var(--b-wash); }
.c-wall { fill: transparent; }
.dot { fill: var(--dot); opacity: .28; }
.mtn-back { fill: var(--mtn-hi); }
.mtn-front { fill: var(--mtn); }
.mtn-snow { fill: #fff; opacity: .85; }
.arrow-g path { fill: none; stroke: var(--s2); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.arrow-g.done path { opacity: .35; }
.key-g { color: var(--kc); }
.key-g.done { opacity: .3; }
.door-g rect { fill: color-mix(in srgb, var(--kc) 18%, var(--b-cell)); stroke: var(--kc); stroke-width: 5; }
.door-g .hole { fill: var(--kc); }
.door-g.open rect { fill: transparent; stroke-dasharray: 10 8; }
.door-g.open .hole { opacity: 0; }
.pav { color: var(--s3); }
.portal-g { color: var(--pc); }
.portal-g .swirl { transform-box: fill-box; transform-origin: center; animation: spin 6s linear infinite; }
.portal-g.done { opacity: .35; }
@keyframes spin { to { transform: rotate(360deg); } }
.path-bleed { fill: none; stroke: var(--line-bleed); stroke-linecap: round; stroke-linejoin: round; }
.path-core { fill: none; stroke: var(--brush, var(--line)); stroke-linecap: round; stroke-linejoin: round; }
.board-card.fail .path-core { stroke: var(--seal); }
.board-card.done .path-core { animation: shine 1s ease-out; }
@keyframes shine { 30% { stroke-width: 34px; filter: brightness(1.25); } }
.start-ring { fill: none; stroke: var(--seal); stroke-width: 6; }
.head { fill: var(--tip, var(--seal)); }
.head-dot { fill: #fff; }
.head-pulse { fill: none; stroke: var(--tip, var(--seal)); stroke-width: 4; opacity: .5; transform-box: fill-box; transform-origin: center; animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { from { transform: scale(.8); opacity: .6; } to { transform: scale(1.9); opacity: 0; } }
.enemy { transition: transform .26s ease-in-out; }
.enemy .body { fill: var(--goblin); }
.enemy .eye { fill: #fff; }
.enemy .pupil { fill: #e2463a; }
.enemy .horn { fill: var(--seal); }
.enemy.masked .body, .enemy.masked .horn { opacity: 0; }
.enemy.masked .eye { fill: #ffd84a; filter: drop-shadow(0 0 6px #ffd84a); }
.enemy.masked .pupil { fill: #111; }
.enemy.gone { opacity: 0; transition: opacity .3s; }
.fog-cell { fill: var(--fog); transition: opacity .25s; }
.fog-cell.clear { opacity: 0; }
.hint-flash { fill: var(--seal); opacity: 0; pointer-events: none; }
.hint-flash.go { animation: flash .9s ease-out; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
.warp-flash { fill: none; stroke: var(--pc, var(--violet)); stroke-width: 8; opacity: 0; transform-box: fill-box; transform-origin: center; }
.warp-flash.go { animation: warp .5s ease-out; }
@keyframes warp { from { opacity: .9; transform: scale(.4); } to { opacity: 0; transform: scale(1.6); } }

.board-overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.out-card { background: var(--seal); color: #fff; border-radius: 18px; padding: 6px 28px 10px; transform: rotate(-5deg); text-align: center; animation: pop .3s cubic-bezier(.3, 1.6, .5, 1); box-shadow: 0 10px 30px rgba(198, 58, 46, .4); }
.out-card b { display: block; font-family: var(--font-brush); font-weight: 400; font-size: 3.6rem; line-height: 1; }
.out-card small { font-size: .85rem; }
@keyframes pop { from { transform: rotate(-5deg) scale(.4); opacity: 0; } }
.preview { align-items: start; inset: -20px 0 auto 0; }
.preview-card { background: var(--ink); color: var(--paper); border-radius: 999px; padding: 6px 8px 6px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.preview-card small { font-size: .85rem; }
.preview-card b { width: 32px; height: 32px; border-radius: 50%; background: var(--seal); color: #fff; display: grid; place-items: center; font-weight: 400; }
.combo-pop { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #ffe48a; border-radius: 999px; padding: 6px 14px; font-size: .95rem; white-space: nowrap; pointer-events: none; animation: combo 1.6s ease-out forwards; }
@keyframes combo { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -8px); } }

.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: none; }
.ctrl { position: relative; border: 0; background: var(--surface); box-shadow: var(--shadow), var(--press); border-radius: 16px; padding: 10px 0 8px; display: grid; justify-items: center; gap: 2px; font-size: .85rem; }
.ctrl svg, .ctrl .i-ico { width: 24px; height: 24px; }
.ctrl:active { transform: translateY(3px); box-shadow: var(--shadow); }
.ctrl:disabled { opacity: .4; cursor: default; }
.ctrl .badge { font-size: .76rem; color: var(--muted); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 66px); transform: translate(-50%, -10px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; border-radius: 28px 28px 0 0; max-height: 92vh; display: flex; flex-direction: column; gap: 14px;
  padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); animation: up .28s cubic-bezier(.2, .9, .3, 1); overflow-y: auto; }
@media (min-width: 640px) { .scrim { align-items: center; } .sheet { border-radius: 28px; padding-bottom: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--paper-2); margin: 0 auto; flex: none; }
.sheet h2 { font-size: 1.7rem; line-height: 1.15; }
.sheet h3 { font-size: 1.15rem; }
.sheet p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.sheet .center { text-align: center; }
.field { width: 100%; font: 1.08rem var(--font-ui); color: var(--ink); background: var(--paper); border: 2px solid transparent; border-radius: 14px; padding: 12px 15px; outline: none; }
.field:focus { border-color: var(--ink); }
.field.code { text-transform: uppercase; letter-spacing: .3em; text-align: center; }
.err { min-height: 1.2em; font-size: .82rem; color: var(--seal); margin-top: -6px; }
.btn-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.btn-row.one { grid-template-columns: 1fr; }
.btn-row.two { grid-template-columns: 1fr 1fr; }
.btn { border: 0; border-radius: 16px; padding: 13px 0; background: var(--paper-2); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 1.02rem; box-shadow: 0 3px 0 rgba(27, 30, 33, .12); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.primary { background: var(--ink); color: var(--paper); box-shadow: 0 3px 0 #000; }
.btn.seal { background: var(--seal); color: #fff; box-shadow: 0 4px 0 var(--seal-dk); }
.btn.gold { background: linear-gradient(#ffd864, var(--gold)); color: #4a3200; box-shadow: 0 4px 0 var(--gold-dk); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn.danger { background: transparent; color: var(--seal); border: 1.5px solid rgba(198, 58, 46, .4); box-shadow: none; }
.btn svg { width: 18px; height: 18px; }
.btn small { font-size: .78rem; opacity: .8; }
.btn:disabled { opacity: .5; }

.guide-head { display: flex; gap: 14px; align-items: center; }
.guide-head .art { width: 64px; height: 64px; border-radius: 16px; background: color-mix(in srgb, var(--tc) 13%, var(--surface)); display: grid; place-items: center; flex: none; }
.guide-head .art svg { width: 50px; height: 50px; }
.guide-head .label { font-size: .78rem; color: var(--tc); letter-spacing: .04em; }
.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: r; }
.rules li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; font-size: .92rem; line-height: 1.55; }
.rules li::before { counter-increment: r; content: counter(r); width: 24px; height: 24px; border-radius: 50%; background: var(--tc, var(--ink)); color: #fff; font-size: .8rem; display: grid; place-items: center; margin-top: 1px; }
.scoring { background: var(--paper); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.scoring ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: .84rem; color: var(--muted); line-height: 1.55; }

/* clear */
.clear { text-align: center; }
.clear h2 { font-family: var(--font-brush); font-size: 3.4rem; line-height: 1; }
.stars { display: flex; justify-content: center; gap: 6px; align-items: end; }
.stars svg { width: 42px; height: 42px; opacity: 0; transform: scale(.3); }
.stars svg:nth-child(2) { width: 54px; height: 54px; }
.stars svg.in { animation: starIn .35s cubic-bezier(.3, 1.8, .5, 1) forwards; }
@keyframes starIn { to { opacity: 1; transform: scale(1); } }
.reward-coins { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 2.8rem; line-height: 1; color: var(--ink); }
.reward-coins .coin-ico { width: 40px; height: 40px; }
.reward-sub { font-size: .9rem; color: var(--muted); margin-top: -8px; }
.bonus-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.bonus-chips span { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); border-radius: 999px; padding: 3px 10px; font-size: .8rem; }
.bonus-chips span.m { background: color-mix(in srgb, var(--s1) 18%, var(--surface)); }
.breakdown { display: grid; background: var(--paper); border-radius: 16px; padding: 4px 14px; text-align: left; }
.breakdown div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: .88rem; color: var(--muted); padding: 7px 0; }
.breakdown div + div { border-top: 1px solid var(--paper-2); }
.breakdown b { color: var(--ink); font-weight: 400; font-size: 1.02rem; }
.breakdown em { font-style: normal; font-size: .74rem; margin-left: 6px; }
.breakdown .total b { color: var(--seal); font-size: 1.15rem; }

/* rewards sheet */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day { border-radius: 12px; background: var(--paper); padding: 6px 2px; display: grid; justify-items: center; gap: 2px; font-size: .68rem; color: var(--muted); text-align: center; position: relative; min-width: 0; }
.day .rw { display: grid; justify-items: center; gap: 1px; color: var(--ink); font-size: .74rem; line-height: 1.1; }
.day .rw span { display: inline-flex; align-items: center; gap: 1px; white-space: nowrap; }
.day.got { opacity: .45; }
.day.got::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; color: var(--s1); }
.day.next { background: color-mix(in srgb, var(--gold) 26%, var(--surface)); outline: 2px solid var(--gold); color: var(--ink); }
.day.big { background: color-mix(in srgb, var(--seal) 12%, var(--surface)); }
.missions { display: grid; gap: 8px; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; background: var(--paper); border-radius: 14px; padding: 10px 12px; }
.mission b { font-weight: 400; font-size: .98rem; }
.mission .mbar { grid-column: 1; height: 7px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.mission .mbar i { display: block; height: 100%; background: var(--s1); border-radius: 5px; }
.mission .mr { grid-row: 1 / span 2; grid-column: 2; }
.mission small { color: var(--muted); font-size: .76rem; }
.small-btn { border: 0; border-radius: 12px; padding: 8px 12px; font-size: .88rem; background: var(--paper-2); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.small-btn.ready { background: var(--s1); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--s1) 60%, #000); }
.small-btn.done { background: transparent; }

/* continue sheet */
.ring { width: 86px; height: 86px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 2.2rem; color: var(--ink);
  background: conic-gradient(var(--seal) calc(var(--p, 1) * 360deg), var(--paper-2) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; }
.cont-btns { display: grid; gap: 10px; }
.cont-btns .btn { padding: 12px 14px; justify-content: space-between; }
.cont-btns .btn > span { display: inline-flex; align-items: center; gap: 8px; }

/* misc lists (settings, groups) */
.list { display: grid; gap: 4px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--paper-2); font-size: .95rem; }
.list-row:last-child { border-bottom: 0; }
.list-row .k { color: var(--muted); font-size: .88rem; }
.list-row .v { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.switch { border: 0; width: 52px; height: 30px; border-radius: 999px; background: var(--paper-2); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--s1); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.link-btn { border: 0; background: none; padding: 0; color: var(--seal); font-size: .88rem; }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--paper); border-radius: 16px; padding: 12px 14px; }
.code-box b { font-weight: 400; font-size: 1.7rem; letter-spacing: .25em; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.inline-form .btn { padding: 0 18px; }
.member-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; }
.member-row .avatar { width: 34px; height: 34px; }
.member-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--paper-2); }
.invite-row b { font-weight: 400; display: block; }
.invite-row small { color: var(--muted); font-size: .78rem; }
.invite-row .btn { padding: 9px 14px; font-size: .85rem; }
.sheet .lang-seg { box-shadow: none; background: var(--paper); }

/* ---------- ads & fx ---------- */
.ad-test { position: fixed; inset: 0; z-index: 70; background: rgba(10, 12, 14, .92); display: grid; place-items: center; color: #fff; padding: 20px; }
.ad-test-card { text-align: center; display: grid; gap: 10px; justify-items: center; }
.ad-test-card small { font-size: .9rem; opacity: .8; }
.ad-test-card b { font-weight: 400; width: 84px; height: 84px; border-radius: 50%; border: 5px solid #ffd864; display: grid; place-items: center; font-size: 2.4rem; }
.ad-test-card p { margin: 0; font-size: .82rem; opacity: .65; max-width: 260px; }
.fx-layer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 65; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .stars svg { opacity: 1; transform: none; } }

/* consent & legal notes */
.agree { display: flex; gap: 10px; align-items: flex-start; font-size: .86rem; color: var(--muted); line-height: 1.45; cursor: pointer; text-align: left; }
.agree input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--seal, #c63a2e); }
.agree a, .legal a { color: var(--ink); font-weight: 700; text-decoration: underline; }
.legal { font-size: .74rem; color: var(--muted); margin: 2px 0 0; line-height: 1.45; }
