/* Tile Heaven. Portrait layout: banner slot, then either the home screen or hud + board + toolbar. */
:root {
  --banner-h: 60px;
  --bg: #121722;
  --surface: #1c2433;
  --surface-2: #27324a;
  --ink: #eef2f8;
  --ink-soft: #93a0b5;
  --line: #2d3850;
  --accent: #4f8cff;
  --accent-ink: #ffffff;
  --gold: #ffc940;
  --bad: #ff7b7b;
  --ph: #1a2130;
  --table-a: #2f9068;
  --table-b: #1a5c43;
  --tile-top: #fffdf6;
  --tile-low: #f1e7cc;
  --tile-side: #d3bd84;
  --tile-edge: #a38a4e;
  --sel: #ff9d1c;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
body[data-theme='light'] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #e6eaf1;
  --ink: #1c2536;
  --ink-soft: #65728a;
  --line: #d3dae6;
  --accent: #2f6fed;
  --gold: #f0a800;
  --bad: #d93a3a;
  --ph: #e1e5ec;
  --shadow: 0 2px 10px rgba(28, 37, 54, 0.12);
}
body[data-table='night'] { --table-a: #34497c; --table-b: #17223f; }
body[data-table='rose'] { --table-a: #96463f; --table-b: #57211f; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { opacity: 0.38; cursor: default; }
.hidden { display: none !important; }
svg { display: block; }

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Banner slot: reserved from first paint so nothing jumps when the ad loads. */
.banner {
  flex: 0 0 auto;
  height: var(--banner-h);
  margin-bottom: 8px; /* gap so no control touches the ad */
  display: flex;
  align-items: center;
  justify-content: center;
}
.banner.collapsed { display: none; }
.banner-ph {
  width: 100%;
  height: 100%;
  background: var(--ph);
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* Buttons */
.btn { width: 100%; min-height: 52px; padding: 10px 18px; border-radius: 14px; background: var(--surface-2); font-size: 16.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; transition: transform 0.08s; }
.btn:active { transform: scale(0.97); }
.btn svg { width: 22px; height: 22px; flex: 0 0 22px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 64px; font-size: 20px; border-radius: 18px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); flex: 0 0 auto; }
.icon-btn svg { width: 24px; height: 24px; }

/* Tiles */
.tile {
  position: absolute;
  width: var(--tw);
  height: var(--th);
  border-radius: calc(var(--tw) * 0.13);
  background: var(--tile-tex, none), linear-gradient(165deg, var(--tile-top) 30%, var(--tile-low));
  box-shadow: var(--side);
  cursor: pointer;
  transition: transform 0.16s ease-out, opacity 0.16s ease-out;
}
.tile::before { content: ''; position: absolute; inset: 0; border-radius: inherit; border: 1px solid var(--tile-line, rgba(122, 98, 44, 0.6)); pointer-events: none; }
.tile svg { position: absolute; left: 4%; top: 3%; width: 92%; height: 94%; pointer-events: none; }
.board.dim .tile.blocked::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: rgba(38, 30, 12, 0.36); pointer-events: none; }
.tile.sel { background: linear-gradient(165deg, #fff6c9 20%, #ffd75e); box-shadow: 0 0 0 3px var(--sel), var(--side); transform: translate(-2px, -2px); }
.tile.hint { animation: hintpulse 0.85s ease-in-out infinite alternate; }
@keyframes hintpulse {
  from { box-shadow: 0 0 0 2px #35b3ff, var(--side); }
  to { box-shadow: 0 0 0 5px #35b3ff, 0 0 14px 6px rgba(53, 179, 255, 0.75), var(--side); }
}
.tile.out { transform: scale(0.5); opacity: 0; pointer-events: none; }
.tile.gone { display: none; }
.tile.shake { animation: shake 0.26s; }
@keyframes shake { 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }

/* Home */
.home { padding: 6px 18px 14px; gap: 12px; justify-content: center; overflow-y: auto; }
.hero { --tw: 66px; --th: 88px; --side: 1px 1px 0 var(--tile-side), 2px 2px 0 var(--tile-side), 3px 3px 0 var(--tile-side), 4px 4px 0 var(--tile-side), 5px 5px 0 var(--tile-side), 6px 6px 0 var(--tile-edge), 8px 10px 8px rgba(0, 0, 0, 0.35); position: relative; width: 230px; height: 112px; margin: 0 auto 4px; flex: 0 0 auto; }
.hero .tile { cursor: default; }
.hero .h1 { left: 6px; top: 16px; transform: rotate(-9deg); }
.hero .h2 { left: 80px; top: 4px; z-index: 2; }
.hero .h3 { left: 154px; top: 16px; transform: rotate(9deg); }
.daily { justify-content: flex-start; text-align: left; padding: 10px 16px; min-height: 64px; background: var(--surface); border: 1px solid var(--line); }
.daily > svg { width: 28px; height: 28px; flex-basis: 28px; color: var(--accent); }
.daily .dl { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.daily .dl b { font-size: 17px; }
.daily .dl small { color: var(--ink-soft); font-size: 12.5px; font-weight: 600; }
.chip { background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.home-row { display: flex; gap: 10px; }
.home-row .btn { font-size: 15px; background: var(--surface); border: 1px solid var(--line); }
.foot { margin: 6px 0 0; text-align: center; color: var(--ink-soft); font-size: 12.5px; }

/* HUD */
.hud { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 0 10px 8px; }
.hud-mid { flex: 1; min-width: 0; text-align: center; line-height: 1.25; }
.hud-mid b { display: block; font-size: 18px; }
.hud-mid small { color: var(--ink-soft); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Board */
.board-wrap { flex: 1 1 auto; min-height: 0; position: relative; margin: 0 6px; border-radius: 16px; background: radial-gradient(ellipse at 50% 40%, var(--table-a), var(--table-b)); overflow: hidden; touch-action: none; }
.board { position: absolute; z-index: 0; touch-action: none; } /* z-index 0: keeps the tile z-indexes below dialogs */
.board.deal { animation: deal 0.28s ease-out; }
@keyframes deal { from { opacity: 0; transform: scale(0.96); } }
.gtip { flex: 0 0 auto; margin: 6px 16px 0; text-align: center; font-size: 13.5px; line-height: 1.4; color: var(--ink-soft); }

.bar { flex: 0 0 auto; display: flex; background: var(--surface); border-top: 1px solid var(--line); margin-top: 8px; }
.bar button { flex: 1; padding: 8px 2px 9px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.bar button svg { width: 26px; height: 26px; }
.bar button:not(:disabled):active { color: var(--ink); }

.toast { position: absolute; left: 50%; top: 132px; transform: translateX(-50%); max-width: 92%; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 7px 14px; border-radius: 14px; font-size: 13.5px; width: max-content; font-weight: 700; text-align: center; z-index: 30; pointer-events: none; }

/* Modal */
.modal { position: absolute; inset: 0; background: rgba(8, 11, 17, 0.62); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; }
.modal-card { width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; background: var(--surface); border-radius: 18px; padding: 22px 20px 18px; box-shadow: var(--shadow); text-align: center; animation: pop2 0.18s ease-out; }
@keyframes pop2 { from { transform: scale(0.92); opacity: 0; } }
.modal-card h2 { margin: 0 0 8px; font-size: 21px; }
.modal-card p { margin: 0 0 6px; color: var(--ink-soft); font-size: 14.5px; line-height: 1.45; }
.modal-card .btns { display: flex; gap: 10px; margin-top: 16px; }
.modal-card .btn.go { background: var(--accent); color: var(--accent-ink); }
.stars { display: flex; justify-content: center; gap: 6px; margin: 8px 0 4px; }
.stars svg { width: 46px; height: 46px; color: var(--surface-2); }
.stars svg.on { color: var(--gold); animation: starpop 0.35s ease-out backwards; }
.stars svg.on:nth-child(2) { animation-delay: 0.12s; }
.stars svg.on:nth-child(3) { animation-delay: 0.24s; }
@keyframes starpop { from { transform: scale(0.2) rotate(-30deg); opacity: 0; } }
.big-num { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14.5px; text-align: left; }
.kv:last-of-type { border-bottom: 0; }
.kv span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 15px; min-height: 46px; text-align: left; }
.set:last-of-type { border-bottom: 0; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { padding: 7px 10px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--surface-2); position: relative; flex: 0 0 auto; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.link { color: var(--accent); font-weight: 600; text-align: left; flex: 1; min-height: 32px; }
.about { text-align: center; color: var(--ink-soft); font-size: 12px; margin: 12px 0 4px; }
.modal-card .btn.danger { margin-top: 10px; background: var(--surface-2); }

@media (max-height: 640px) {
  .hero { display: none; }
  .title { font-size: 26px; }
  .btn.big { min-height: 56px; }
  .bar button { padding: 5px 2px 6px; }
  .bar button svg { width: 22px; height: 22px; }
  .gtip { font-size: 12px; margin-top: 3px; }
  .hud { padding-bottom: 5px; }
}
@media (max-width: 360px) {
  .home { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .stars svg.on, .modal-card, .board.deal, .tile.shake { animation: none; }
  .tile { transition: none; }
}

/* music volume slider (settings) */
input.vol { width: 130px; max-width: 45vw; accent-color: var(--accent); }
.set .np-title { font-size: 12px; color: var(--ink-soft); max-width: 55vw; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- start screen (shared "hm-" kit, see tools/home) ---- */
.hm-wrap { --hm-pad: 14px; padding: 0 var(--hm-pad) 10px; }
.hm-hero { position: relative; height: 176px; margin: 0 calc(var(--hm-pad) * -1) 12px; overflow: hidden; border-radius: 0 0 26px 26px; background: linear-gradient(160deg, var(--h0, #274a8c), var(--h1, #0f1d3f)); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3); color: #fff; }
.hm-hero::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.16), transparent 60%); pointer-events: none; z-index: 2; }
.hm-art { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
.hm-art > svg { width: 100%; height: 100%; display: block; }
.hm-txt { position: absolute; left: 18px; right: 18px; top: 18px; z-index: 3; text-align: left; }
.hm-txt h1 { margin: 0; font-size: 31px; line-height: 1.05; font-weight: 900; letter-spacing: 0.01em; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 255, 255, 0.3); }
.hm-txt h1 span { background: linear-gradient(180deg, #fff2a8, #ffc940 70%, #f29b1c); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35)); }
.hm-txt p { margin: 6px 0 0; font-size: 13px; color: rgba(255, 255, 255, 0.92); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); letter-spacing: 0.03em; }
.hm-icons { position: absolute; z-index: 4; right: 10px; top: 10px; display: flex; gap: 8px; }
.hm-ic { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: rgba(6, 14, 32, 0.5); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(4px); position: relative; }
.hm-ic svg, .hm-np svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.hm-ic .hm-dot { position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%; background: #ff5d6c; border: 2px solid rgba(6, 14, 32, 0.8); }
.hm-np { position: absolute; z-index: 4; left: 12px; right: 12px; bottom: 10px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 0; border-radius: 999px; background: rgba(6, 14, 32, 0.62); color: #fff; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; backdrop-filter: blur(4px); }
.hm-np svg { width: 14px; height: 14px; flex: 0 0 14px; color: #ffd23f; }
.hm-np span { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-np b { font-size: 9px; opacity: 0.7; letter-spacing: -1px; }
.hm-np.off svg { color: #8a9bb8; }
.hm-art .hm-logo { position: absolute; right: 16px; top: 44px; width: 78px; height: 78px; border-radius: 20px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.5); animation: hm-bob 4.2s ease-in-out infinite; }

.hm-banner { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 12px; padding: 12px 14px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; border: 1.5px solid var(--accent); border-radius: 16px; background: linear-gradient(90deg, rgba(255, 201, 64, 0.2), var(--surface) 72%); box-shadow: var(--shadow, 0 2px 10px rgba(0, 0, 0, 0.2)); }
.hm-banner:active { transform: scale(0.985); }
.hm-banner.done { border-color: var(--line); background: var(--surface); opacity: 0.92; }
.hm-banner .bi { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-ink, #fff); }
.hm-banner.done .bi { background: var(--line); color: var(--ink-soft); }
.hm-banner .bi svg { width: 20px; height: 20px; fill: currentColor; }
.hm-banner .hm-bt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hm-banner .hm-bt b { font-size: 15px; line-height: 1.15; }
.hm-banner .hm-bt small { font-size: 12px; color: var(--ink-soft); line-height: 1.25; }
.hm-banner .bg { flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; background: var(--accent); color: var(--accent-ink, #fff); }
.hm-banner.done .bg { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.hm-banner .dots { display: flex; gap: 4px; margin-top: 3px; }
.hm-banner .dots i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); display: block; }
.hm-banner .dots i.on { background: var(--accent); }

.hm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 12px; }
.hm-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 6px; text-align: center; min-width: 0; }
.hm-stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.hm-stats small { display: block; margin-top: 2px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hm-card { margin: 0 0 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow, 0 2px 10px rgba(0, 0, 0, 0.2)); color: var(--ink); text-align: left; }
.hm-card h3 { margin: 0; font-size: 16px; }
.hm-card p { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.4; }
.hm-card .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.hm-card .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #ffd23f, #ff9a3d); }
.hm-row { display: flex; align-items: center; gap: 12px; }
.hm-row > .pv { flex: 0 0 auto; }
.hm-row > .tx { flex: 1; min-width: 0; }
.hm-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hm-chips button { flex: 1 1 0; min-width: 64px; padding: 9px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2, var(--bg)); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.hm-chips button:active { transform: scale(0.96); }
.hm-chips button small { display: block; font-size: 10.5px; font-weight: 500; color: var(--ink-soft); margin-top: 1px; }

.hm-wrap .hm-cta { margin: 0 calc(var(--hm-pad, 14px) * -1); }
.hm-cta { position: sticky; bottom: 0; z-index: 5; margin: 0; padding: 14px var(--hm-pad, 14px) 14px; background: linear-gradient(180deg, rgba(0, 0, 0, 0), var(--bg) 40%); display: flex; flex-direction: column; gap: 8px; }
.hm-btn { width: 100%; padding: 15px 16px; border: 0; border-radius: 16px; font: inherit; font-size: 17px; font-weight: 800; letter-spacing: 0.03em; cursor: pointer; color: #2a1a00; background: linear-gradient(180deg, #ffe27a, #ffbf2f); box-shadow: 0 6px 18px rgba(255, 190, 40, 0.35); animation: hm-glow 2.2s ease-in-out infinite; display: flex; align-items: center; justify-content: center; gap: 8px; flex-direction: column; line-height: 1.15; }
.hm-btn small { font-size: 12px; font-weight: 600; opacity: 0.8; letter-spacing: 0; }
.hm-btn:active { transform: scale(0.98); }
.hm-btn.alt { background: var(--surface-2, var(--surface)); color: var(--ink); box-shadow: none; animation: none; border: 1px solid var(--line); font-size: 15px; padding: 12px 16px; }
.hm-btn.hidden { display: none; }

/* idle games: Home tab lives in the panel */
.hm-panel { padding: 0 !important; display: flex; flex-direction: column; }
.hm-panel .hm-wrap { flex: 1 0 auto; display: flex; flex-direction: column; }
.hm-panel .hm-cta { margin-top: auto; }
.hm-art .pt { position: absolute; bottom: -14px; z-index: 1; width: 11px; height: 11px; border-radius: 3px; background: var(--c, #ffd23f); opacity: 0.75; box-shadow: 0 0 10px var(--c, #ffd23f); animation: hm-rise 9s linear infinite; }
.on-home #stage, .on-home .top, .on-home #mine-tabs { display: none !important; }
@keyframes hm-glow { 0%, 100% { box-shadow: 0 6px 18px rgba(255, 190, 40, 0.3); } 50% { box-shadow: 0 6px 28px rgba(255, 190, 40, 0.65); } }
@keyframes hm-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
@keyframes hm-drift { from { transform: translateX(0); } to { transform: translateX(560px); } }
@keyframes hm-twinkle { from { opacity: 0.25; } to { opacity: 0.95; } }
@keyframes hm-rise { 0% { transform: translateY(20px); opacity: 0; } 15% { opacity: 0.9; } 100% { transform: translateY(-190px); opacity: 0; } }
@keyframes hm-spin { to { transform: rotate(360deg); } }
@keyframes hm-flicker { 0%, 100% { transform: scale(1, 1); opacity: 1; } 30% { transform: scale(0.94, 1.08); opacity: 0.9; } 60% { transform: scale(1.04, 0.95); opacity: 1; } }
.hm-art .dg { position: absolute; bottom: -10px; font-weight: 900; color: rgba(255, 255, 255, 0.45); font-size: 26px; animation: hm-rise 9s linear infinite; z-index: 1; }
.hm-art .ar { position: absolute; bottom: -14px; z-index: 1; animation: hm-rise 9s linear infinite; }
.hm-art .ar i { display: block; width: 0; height: 0; border-left: 17px solid var(--c, #ff6b6b); border-top: 10px solid transparent; border-bottom: 10px solid transparent; opacity: 0.8; }
.hm-art .tl { position: absolute; bottom: -34px; z-index: 1; animation: hm-rise 10s linear infinite; }
.hm-art .tl i { display: block; width: 22px; height: 30px; border-radius: 6px; background: linear-gradient(160deg, #fffdf2, #e3dcc2); box-shadow: 2px 2px 0 var(--c, #1f9e7a); opacity: 0.8; }
.hm-bob { animation: hm-bob 4.2s ease-in-out infinite; }
.hm-twinkle { animation: hm-twinkle 3s ease-in-out infinite alternate; }
.hm-spin { animation: hm-spin 14s linear infinite; }
.hm-svg { transform-box: fill-box; transform-origin: center; }
.hm-cloud { position: absolute; z-index: 1; height: 26px; width: 90px; border-radius: 40px; background: rgba(255, 255, 255, 0.55); filter: blur(1px); opacity: 0.8; animation: hm-drift 38s linear infinite; left: -110px; }
.hm-cloud::before, .hm-cloud::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.hm-cloud::before { width: 42px; height: 42px; left: 14px; top: -20px; }
.hm-cloud::after { width: 32px; height: 32px; left: 46px; top: -12px; }
.hm-cloud.c1 { top: 100px; }
.hm-cloud.c2 { top: 62px; animation-duration: 52s; animation-delay: -20s; transform: scale(0.7); opacity: 0.55; }
.hm-cloud.c3 { top: 126px; animation-duration: 44s; animation-delay: -33s; transform: scale(1.15); opacity: 0.45; }
.hm-rise { position: absolute; bottom: 0; z-index: 1; font-weight: 800; color: rgba(255, 255, 255, 0.85); text-shadow: 0 0 10px rgba(255, 255, 255, 0.6); animation: hm-rise 9s linear infinite; pointer-events: none; }

@media (max-width: 360px) {
  .hm-txt h1 { font-size: 25px; }
  .hm-txt p { font-size: 12px; }
  .hm-art .hm-logo { width: 58px; height: 58px; top: 56px; right: 12px; border-radius: 15px; }
  .hm-ic { width: 32px; height: 32px; }
}
@media (max-height: 600px) {
  .hm-hero { height: 128px; margin-bottom: 8px; }
  .hm-txt { top: 12px; }
  .hm-txt h1 { font-size: 24px; }
  .hm-txt p { display: none; }
  .hm-art .hm-logo { width: 56px; height: 56px; top: 36px; border-radius: 14px; }
  .hm-rise { animation-name: hm-rise-s; }
}
@keyframes hm-rise-s { 0% { transform: translateY(20px); opacity: 0; } 15% { opacity: 0.9; } 100% { transform: translateY(-140px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .hm-cloud, .hm-rise, .hm-bob, .hm-twinkle, .hm-spin, .hm-btn, .hm-art .hm-logo { animation: none !important; }
}
#home.hm { padding: 0; gap: 0; justify-content: flex-start; overflow-y: auto; }
.hm-tiles { --tw: 36px; --th: 48px; --side: 1px 1px 0 var(--tile-side), 2px 2px 0 var(--tile-side), 3px 3px 0 var(--tile-edge), 4px 5px 5px rgba(0, 0, 0, 0.3); position: relative; width: 112px; height: 64px; }
.hm-tiles .tile { position: absolute; width: var(--tw); height: var(--th); top: 8px; cursor: default; }
.hm-tiles .tile.a { left: 0; transform: rotate(-9deg); }
.hm-tiles .tile.b { left: 38px; top: 0; z-index: 2; }
.hm-tiles .tile.c { left: 76px; transform: rotate(9deg); }
#home.hm .hm-wrap { flex: 1 0 auto; }

/* Tablets: let the column grow beyond the phone cap (boards size themselves from the column). Phones (< 700 px) are unchanged. */
@media (min-width: 700px) {
  #app { max-width: 760px; }
}

/* ---- tile sets (v1.2): the worn set is body[data-tset]; the collection icons set the same variables on their own element ---- */
:root { --set: #e9dcae; }
[data-tset='bamboo'] { --tile-top: #fbfff0; --tile-low: #dcefb8; --tile-side: #9fc86a; --tile-edge: #5f8f35; --tile-line: rgba(70, 110, 30, 0.6); --tile-tex: repeating-linear-gradient(90deg, rgba(90, 140, 40, 0.09) 0 2px, transparent 2px 9px); }
[data-tset='jade'] { --tile-top: #f1fcf6; --tile-low: #c2ecd6; --tile-side: #3fae80; --tile-edge: #1f7a58; --tile-line: rgba(20, 110, 80, 0.6); --tile-tex: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.55), transparent 55%), repeating-linear-gradient(115deg, rgba(40, 150, 110, 0.07) 0 3px, transparent 3px 11px); }
[data-tset='amber'] { --tile-top: #fff9e6; --tile-low: #ffdf96; --tile-side: #e39a2a; --tile-edge: #9c5d0c; --tile-line: rgba(160, 95, 10, 0.6); --tile-tex: radial-gradient(circle at 70% 80%, rgba(255, 170, 40, 0.28), transparent 55%); }
[data-tset='coral'] { --tile-top: #fff5f1; --tile-low: #ffcfc3; --tile-side: #ee6f5e; --tile-edge: #a7382c; --tile-line: rgba(170, 60, 45, 0.6); --tile-tex: radial-gradient(circle at 20% 85%, rgba(255, 110, 90, 0.22), transparent 50%); }
[data-tset='lapis'] { --tile-top: #f4f7ff; --tile-low: #cad6fb; --tile-side: #4468d6; --tile-edge: #223a8f; --tile-line: rgba(40, 65, 150, 0.65); --tile-tex: radial-gradient(circle, rgba(255, 215, 90, 0.5) 0 1px, transparent 1.5px) 0 0 / 11px 11px, radial-gradient(circle at 80% 20%, rgba(80, 110, 230, 0.2), transparent 55%); }
[data-tset='ebony'] { --tile-top: #f6f3ee; --tile-low: #d6d0c4; --tile-side: #3a3748; --tile-edge: #15131c; --tile-line: rgba(30, 27, 40, 0.8); }
[data-tset='rosewood'] { --tile-top: #fff4ef; --tile-low: #f1c9b8; --tile-side: #9b4b36; --tile-edge: #55220f; --tile-line: rgba(110, 50, 30, 0.7); --tile-tex: repeating-linear-gradient(172deg, rgba(150, 70, 40, 0.1) 0 2px, transparent 2px 8px); }
[data-tset='pearl'] { --tile-top: #ffffff; --tile-low: #ecd9fa; --tile-side: #d4bde8; --tile-edge: #9d80bb; --tile-line: rgba(150, 120, 190, 0.6); --tile-tex: linear-gradient(135deg, rgba(255, 190, 220, 0.3), rgba(190, 230, 255, 0.3) 45%, rgba(255, 240, 190, 0.3)); }
[data-tset='gold'] { --tile-top: #fff4c4; --tile-low: #f5c553; --tile-side: #e1a928; --tile-edge: #8c610e; --tile-line: rgba(150, 100, 10, 0.75); --tile-tex: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.55) 48%, transparent 58%); }
[data-tset='crystal'] { --tile-top: #f6feff; --tile-low: #b4eafa; --tile-side: #5cc7e4; --tile-edge: #2686a8; --tile-line: rgba(255, 255, 255, 0.9); --tile-tex: linear-gradient(125deg, rgba(255, 255, 255, 0.7), transparent 40%, rgba(120, 210, 255, 0.25) 75%); }
[data-tset='dragon'] { --tile-top: #fff7f0; --tile-low: #ffc3b0; --tile-side: #d12d4a; --tile-edge: #6f0b22; --tile-line: rgba(255, 190, 60, 0.95); --tile-tex: linear-gradient(115deg, transparent 40%, rgba(255, 215, 120, 0.5) 50%, transparent 60%); }
body[data-tset='crystal'] .tile:not(.blocked):not(.gone) { filter: drop-shadow(0 0 2px rgba(120, 230, 255, 0.55)); }
body[data-tset='dragon'] .tile:not(.blocked):not(.gone) { filter: drop-shadow(0 0 2px rgba(255, 120, 90, 0.5)); }

.tset-ic { --tw: 27px; --th: 36px; --side: 1px 1px 0 var(--tile-side), 2px 2px 0 var(--tile-edge), 3px 4px 4px rgba(0, 0, 0, 0.3); display: inline-block; position: relative; flex: 0 0 auto; width: 32px; height: 40px; vertical-align: middle; }
.tset-ic .tile { position: absolute; left: 0; top: 0; cursor: default; transition: none; }
.tset-ic.big { --tw: 36px; --th: 48px; width: 42px; height: 52px; }
.hud-mid small .tset-ic { --tw: 10px; --th: 13px; --side: 1px 1px 0 var(--tile-edge); width: 12px; height: 15px; vertical-align: -3px; }
.hm-set { display: block; width: 100%; font: inherit; cursor: pointer; }
.hm-set:active { transform: scale(0.985); }
.hm-set .hm-row { display: flex; align-items: center; gap: 12px; }
.hm-set .tx { flex: 1; min-width: 0; }
.hm-set .gh, .set-row .gh { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hm-set .gh b { font-size: 16px; }
.hm-set .gm, .set-row .gm { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.hm-set .tx p { margin: 2px 0 0; }
.hm-set .go { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--accent); }
.hm-set p.nx { margin: 6px 0 0; font-size: 12px; }
.hm-set .bar i { background: linear-gradient(90deg, var(--set), var(--accent)); }
.modal-card.sets { max-width: 400px; text-align: left; padding: 18px 14px 14px; }
.modal-card.sets h2 { text-align: center; }
.modal-card .set-sum { text-align: center; margin-bottom: 10px; }
.set-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.set-row.on { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 1px var(--accent) inset; }
.set-row.locked .tset-ic { filter: grayscale(1) brightness(0.75); opacity: 0.45; }
.set-row .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-row .gh b { font-size: 15px; overflow-wrap: anywhere; }
.set-row small { font-size: 12px; color: var(--ink-soft); line-height: 1.3; overflow-wrap: anywhere; }
.set-row small.perk { color: var(--ink); }
.set-row.locked small.perk { color: var(--ink-soft); }
.set-row small.cnt { font-variant-numeric: tabular-nums; }
.set-row .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 3px; }
.set-row .bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #ffd23f, #ff9a3d); }
.set-eq { flex: 0 0 auto; min-width: 0; padding: 7px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.set-eq.on, .set-eq:disabled { background: transparent; color: var(--accent); cursor: default; }
.modal-card .set-hint { margin: 4px 2px 12px; font-size: 12px; text-align: center; }
.modal-card .setline { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 10px; font-size: 14px; font-weight: 700; color: var(--ink); }
.modal-card .set-got { display: flex; align-items: center; gap: 12px; text-align: left; margin: 0 0 12px; padding: 10px 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--accent); animation: pop2 0.35s ease-out; }
.modal-card .set-got .tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal-card .set-got b { font-size: 14px; }
.modal-card .set-got small { font-size: 12px; color: var(--ink-soft); overflow-wrap: anywhere; }
.fx { position: absolute; inset: 0; z-index: 25; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .fx { display: none; } }

.banner .adsbygoogle { position: relative; z-index: 1; }
.banner.filled .banner-ph { display: none; }
