/* ---------- fonts & theme (colours from AppColors / text styles from AppTextStyles) ---------- */
@font-face {
  font-family: "ClashDisplay";
  src: url("../fonts/ClashDisplay-Variable.ttf") format("truetype");
  font-weight: 200 700;
  font-display: block;
}

:root {
  --bg: #fff; --text: #000; --pure: #fff; --n200: #eaeaea; --n100: #f8f8f8; --secondary: #f8f8f8;
  --border: #f6e9e9; --topbtn: #fff; --rank-idx: #f8f8f8;
  --primary: #808bfc; --primary-dark: #231467; --accent: #f38e1a; --accent-bright: #fecc05;
  --error: #e81818; --n400: #c8c8c8;
  --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
}
:root.dark {
  --bg: #1a1a1a; --text: #fff; --pure: #212121; --n200: #1a1a1a; --n100: #212121; --secondary: #1a1a1a;
  --border: rgba(255,255,255,.1); --topbtn: #111; --rank-idx: #1a1a1a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* One page, no scrolling or history: nothing for the iPhone edge-swipe / rubber band to act on. */
html, body {
  margin: 0; height: 100%; width: 100%; overflow: hidden; position: fixed; inset: 0;
  overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
  background: var(--bg); color: var(--text);
  font-family: "ClashDisplay", system-ui, sans-serif; font-weight: 400;
}
img { -webkit-user-drag: none; user-drag: none; pointer-events: none; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; }

/* ---------- text styles ---------- */
.t-h1 { font-weight: 700; font-size: 40px; line-height: 1.5; }
.t-h2s { font-weight: 500; font-size: 29px; line-height: 1.5; }
.t-h3 { font-weight: 600; font-size: 32px; line-height: 1.5; }
.t-h4 { font-weight: 600; font-size: 20px; line-height: 1.2; }
.t-h5 { font-weight: 600; font-size: 16px; line-height: 1.5; }
.t-c1 { font-weight: 500; font-size: 14px; line-height: 1.5; }
.t-c1s { font-weight: 500; font-size: 13px; line-height: 1.5; }
.t-c2 { font-weight: 600; font-size: 14px; line-height: 1.5; }
.t-c3 { font-weight: 600; font-size: 12px; line-height: 1.5; }
.t-body1 { font-weight: 400; font-size: 16px; line-height: 1.5; }
.t-body2 { font-weight: 500; font-size: 16px; line-height: 1.5; }
.t-btn { font-weight: 600; font-size: 16px; line-height: 1.2; }
.muted { opacity: .7; }

/* ---------- app shell: background + screens ---------- */
#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; min-height: -webkit-fill-available; overflow: hidden; }
.bg { position: absolute; inset: 0; pointer-events: none; }
.bg.light {
  background:
    linear-gradient(118deg, rgba(241,117,29,.5) 0%, #fff 25%, #fff 50%, #fff 75%, #fff 100%) ,
    #fff;
}
.bg .layer2 { position: absolute; inset: 0;
  background: linear-gradient(106deg, rgba(255,255,255,0) 0%, #fff 33%, rgba(255,255,255,.5) 66%, rgba(35,20,103,.2) 100%); }
.bg .noise { position: absolute; inset: 0; background: url("../img/background_noise.png") center / 248px 534px repeat; }

.screen {
  position: absolute; inset: 0; height: 100%; min-height: 100%; display: flex; flex-direction: column;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  will-change: transform, opacity;
}
.screen.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.page { width: 100%; max-width: 560px; margin: 0 auto; }

/* Splash / welcome: the whole page (incl. notch + home-indicator areas) is the splash colour. */
html.on-splash, html.on-splash body { background: var(--primary); }
.screen.splash { background: var(--primary); position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; min-height: -webkit-fill-available; }

/* ---------- controls ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px;
  border-radius: 32px; background: var(--primary); color: #fff; font-weight: 600; font-size: 16px; line-height: 1.2;
}
.btn.secondary { background: var(--secondary); color: var(--text); }
.btn.white { background: #fff; color: #000; }
.btn.black { background: #000; color: #fff; }
.btn.text { background: var(--text); color: var(--pure); }
.btn.small { height: 45px; width: 133px; }
.btn:disabled { background: rgba(0,0,0,.12); color: rgba(0,0,0,.38); cursor: default; }
.btn:active:not(:disabled) { filter: brightness(.94); }

.topbar { display: flex; align-items: center; justify-content: space-between; height: 90px; padding: 0 16px; flex: none; }
.topbar .left { display: flex; align-items: center; }
.icon-btn { margin-right: 8px; padding: 8px; border-radius: 50%; background: var(--topbtn); display: grid; place-items: center; width: 40px; height: 40px; }
.icon { display: block; flex: none; }
.tint { background-color: currentColor; -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat; }

.card { background: var(--pure); border-radius: 16px; }
.row { display: flex; align-items: center; }
.spacer { flex: 1; }
.center { text-align: center; }

/* ---------- menu ---------- */
.menu-banner { width: 100%; display: block; flex: none; }
.menu-logo-wrap { display: flex; justify-content: center; align-items: center; }
.menu-logo-wrap img { width: 70%; max-width: 420px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 4px; max-width: 450px; margin: 0 auto; width: 100%; }
.menu-grid.glow { background: radial-gradient(circle at 30% 50%, rgba(105,227,215,.1) 0, rgba(105,227,215,.1) 33%, rgba(105,227,215,.1) 66%, rgba(255,255,255,0) 100%); }
.tile { position: relative; aspect-ratio: 1; border-radius: 24px; background: var(--pure); overflow: hidden; container-type: size; text-align: left; }
.tile .bgfx { position: absolute; inset: 0; background: #fff; }
.tile .inner { position: absolute; inset: 0; padding: 11px 9px 11px 11px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; }
.tile .label { font-weight: 600; font-size: 17px; line-height: 1.2; white-space: pre-line; }
.tile.disabled { opacity: .4; pointer-events: none; }

/* ---------- game ---------- */
.score-row { display: flex; gap: 8px; }
.score-box { flex: 1; height: 112px; background: var(--pure); border: 1px solid var(--border); border-radius: 16px; padding: 9px; }
.score-box .icon-box { padding: 8px; border-radius: 8px; display: grid; place-items: center; }
.undo-pill { display: flex; align-items: center; justify-content: center; gap: 8px; width: 110px; height: 36px; border: 1px solid var(--border); border-radius: 70px; flex: none; }
.board-wrap { width: 100%; aspect-ratio: 1; background: var(--n100); border-radius: 8px; padding: 4px; touch-action: none; }
.board { position: relative; width: 100%; height: 100%; }
.cell, .tilex { position: absolute; border-radius: 5px; }
.cell { background: var(--n200); }
.tilex { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-weight: 600; will-change: transform; }
.progress { position: relative; border-radius: 99px; overflow: hidden; background: var(--n100); }
.progress > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); }
.dots { display: flex; justify-content: space-between; position: absolute; inset: 0; align-items: center; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--n100); }
.dots i.on { background: var(--primary); }

/* ---------- dialogs ---------- */
.overlay { position: absolute; inset: 0; background: rgba(0,0,0,.54); display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); z-index: 50; animation: fade .15s ease-out; }
.dialog { background: var(--pure); border-radius: 16px; width: 100%; max-width: 340px; max-height: 100%; overflow-y: auto; padding: 28px; display: flex; flex-direction: column; align-items: center; }
.dialog .avatar { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgba(128,139,252,.1); margin-bottom: 12px; }
.dialog.warn .avatar { background: rgba(232,24,24,.1); }
.dialog.warn .title { color: red; font-weight: 600; font-size: 32px; line-height: 1.5; }
.dialog .title { margin-bottom: 16px; }
.dialog .gap { height: 8px; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.spinner { width: 25px; height: 25px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(128,139,252,.3); border-top-color: var(--primary); width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg) } }

.field { position: relative; width: 100%; }
.field .box { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px; border-radius: 12px; border: 1px solid #ffeb3b; }
.field.focus .box { border: 2px solid var(--primary); }
.field.bad .box { border-color: #b3261e; }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font-size: 16px; }
.field label { position: absolute; left: 12px; top: -9px; padding: 0 4px; background: var(--pure); font-size: 12px; color: var(--text); opacity: .7; }
.field.focus label { color: var(--primary); opacity: 1; }
.field .hints { display: flex; justify-content: space-between; padding: 4px 12px 0; font-size: 12px; min-height: 22px; }

/* ---------- how to play / leaderboard / settings ---------- */
.acc { background: var(--pure); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.acc > button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 56px; padding: 0 16px; text-align: left; }
.acc .chev { margin-left: auto; width: 14px; height: 14px; border-right: 2px solid rgba(0,0,0,.54); border-bottom: 2px solid rgba(0,0,0,.54); transform: rotate(45deg); transition: transform .2s; margin-top: -4px; }
.acc.open .chev { transform: rotate(225deg); border-color: #6750a4; margin-top: 4px; }
.acc .body { display: none; padding: 7px 18px; }
.acc.open .body { display: block; }
.bullet { display: flex; gap: 8px; align-items: flex-start; }
.bullet i { width: 4px; height: 4px; border-radius: 50%; background: var(--text); margin-top: 9px; flex: none; }
.rank { display: flex; align-items: center; height: 62px; margin: 8px 0; padding: 0 8px; border-radius: 50px; background: var(--pure); box-shadow: 0 4px 30px rgba(0,0,0,.05); }
.rank.me { background: var(--primary); color: #fff; }
.rank .av { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--rank-idx); flex: none; margin-right: 16px; }
.rank.me .av { background: var(--n100); }
.rank .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .sc { margin: 0 8px; }
.switcher { display: flex; height: 53px; padding: 5px; background: var(--pure); border: 1px solid var(--n200); border-radius: 50px; }
.switcher button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 32px; }
.switcher button.on { background: var(--primary); color: #fff; }
.ach { display: flex; overflow-x: auto; padding: 0 10px; gap: 16px; }
.ach > div { text-align: center; flex: none; }
.cup { border-radius: 50%; overflow: hidden; width: 50px; height: 50px; display: grid; place-items: center; }

/* ---------- install page ---------- */
.steps { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--pure); border-radius: 16px; box-shadow: 0 4px 30px rgba(0,0,0,.06); }
.step .num { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.share-ico { color: var(--primary); display: grid; place-items: center; flex: none; }
.menu-logo-wrap { display: flex; justify-content: center; align-items: center; min-height: 0; }
.dark .menu-grid.glow { background: none; }
.btn .spinner { margin: 0 auto; }

/* ---------- no scrollbars anywhere (scrolling still works) ---------- */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
