/* Számpárok – tiszta, füzetlap hatású megjelenés, világos és sötét témával */
:root {
  --bg: #ffffff;
  --bg2: #f2f5fa;
  --card: #ffffff;
  --ink: #161a23;
  --muted: #6c7686;
  --line: #e1e6ee;
  --frame: #b9c3d2;
  --accent: #2f7be0;
  --accent-2: #1f63c4;
  --accent-soft: #e3effd;
  --added: #3a8fc9;
  --dead: #d3d9e2;
  --sel: #bfe0ff;
  --cand: rgba(47, 123, 224, 0.13);
  --hint: #ffe07a;
  --bad: #e5484d;
  --shadow: 0 6px 22px rgba(30, 50, 90, 0.12);
  --gold: #f5b40f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171f;
    --bg2: #1c2029;
    --card: #1f242e;
    --ink: #eef1f6;
    --muted: #949db0;
    --line: #2b313d;
    --frame: #485163;
    --accent: #5b9cf0;
    --accent-2: #3f82dc;
    --accent-soft: #233650;
    --added: #6cb6ec;
    --dead: #3a414e;
    --sel: #2b4d7a;
    --cand: rgba(91, 156, 240, 0.18);
    --hint: #8a6d12;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171f;
  --bg2: #1c2029;
  --card: #1f242e;
  --ink: #eef1f6;
  --muted: #949db0;
  --line: #2b313d;
  --frame: #485163;
  --accent: #5b9cf0;
  --accent-2: #3f82dc;
  --accent-soft: #233650;
  --added: #6cb6ec;
  --dead: #3a414e;
  --sel: #2b4d7a;
  --cand: rgba(91, 156, 240, 0.18);
  --hint: #8a6d12;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
svg { display: block; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }

/* ---------- felső sáv ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: 60px; padding: 0 14px; flex: none;
  width: 100%; max-width: 640px; margin: 0 auto;
}
.topbar h2 { margin: 0; font-size: 22px; font-weight: 800; }
.ibtn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 12px; flex: none; }
.ibtn svg { width: 30px; height: 30px; }
.ibtn:active { background: var(--accent-soft); }
.ibtn:disabled { opacity: .3; }
.ibtn-spacer { width: 44px; }
.tb-right { display: flex; gap: 4px; }
.coin-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 14px 5px 6px; border-radius: 99px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 19px; font-weight: 800;
}
.coin-pill svg { width: 28px; height: 28px; }
.coin-pill.bump { animation: bump .45s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* ---------- logó, kezdőképernyők ---------- */

.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.hero h1 { margin: 6px 0 0; font-size: 40px; font-weight: 900; letter-spacing: -.5px; }
.hero p { margin: 0; font-size: 17px; }
.logo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-radius: 26px; background: linear-gradient(180deg, #3a6ee6, #2246be); box-shadow: 0 10px 30px rgba(34, 70, 190, .3); }
.logo i { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 13px; background: #fff; color: #223e8c; font-style: normal; font-size: 32px; font-weight: 900; }
.logo i.hl { background: #ffcf40; color: #784600; }

#screen-welcome { justify-content: center; align-items: center; gap: 34px; padding-left: 20px; padding-right: 20px; }
.card {
  width: min(100%, 420px); background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 22px; display: flex; flex-direction: column; gap: 14px;
}
.card-title { font-size: 21px; font-weight: 800; text-align: center; }
.text-input {
  width: 100%; font: inherit; font-size: 20px; font-weight: 700; color: var(--ink);
  padding: 13px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg2); outline: none;
  -webkit-user-select: text; user-select: text;
}
.text-input:focus { border-color: var(--accent); }

.home-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 0 20px 30px; overflow-y: auto;
}
.home-body .hero { margin-bottom: 18px; }
.record { display: flex; align-items: center; gap: 6px; font-size: 18px; color: var(--muted); }
.record svg { width: 20px; height: 20px; color: var(--muted); }
.record b { color: var(--ink); }

.player-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 99px; background: var(--bg2); min-width: 0; max-width: 46%; }
.player-chip .pname { font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip .chev { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.4; flex: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 900; font-size: 18px; flex: none; }

/* ---------- gombok ---------- */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 10px 20px; border-radius: 16px;
  font-size: 19px; font-weight: 800; transition: transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-2); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-gray { background: var(--bg2); color: var(--ink); }
.btn-big { min-height: 60px; font-size: 22px; }
.btn-play { width: min(100%, 360px); min-height: 84px; flex-direction: column; gap: 0; border-radius: 22px; }
.play-label { font-size: 28px; font-weight: 900; }
.play-sub { font-size: 16px; font-weight: 700; opacity: .85; }
.btn-daily { width: min(100%, 360px); min-height: 70px; justify-content: flex-start; border-radius: 20px; gap: 14px; }
.btn-daily svg { width: 32px; height: 32px; flex: none; }
.btn-daily > span { display: flex; flex-direction: column; text-align: left; }
.daily-label { font-size: 21px; font-weight: 900; }
.daily-date { font-size: 15px; font-weight: 700; opacity: .8; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 18px; font-weight: 800; padding: 8px 10px; }
.link-btn svg { width: 22px; height: 22px; }
.home-links { display: flex; gap: 14px; margin-top: 6px; }

/* ---------- játék fejléc ---------- */

.g-score { text-align: center; font-size: 34px; font-weight: 900; line-height: 1; padding: 6px 0 12px; font-variant-numeric: tabular-nums; }
.g-meta {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px;
  padding: 0 16px 8px; max-width: 600px; width: 100%; margin: 0 auto;
}
.g-meta small { display: block; font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.g-meta b { font-size: 17px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.gm-mid { text-align: center; }
.gm-right { text-align: right; }
.gm-right b { display: inline-flex; align-items: center; gap: 3px; }
.gm-right svg { width: 17px; height: 17px; }
.digits { display: flex; gap: 6px; justify-content: center; font-size: 18px; font-weight: 800; }
.digits span { transition: color .3s, transform .3s; min-width: 9px; text-align: center; }
.digits span.gone { color: var(--dead); text-decoration: line-through; text-decoration-thickness: 2px; }

/* ---------- tábla ---------- */

.board-wrap {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 0 12px;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(180deg, #000 calc(100% - 48px), transparent);
  scrollbar-width: none;
}
.board-wrap::-webkit-scrollbar { display: none; }
.board {
  --cs: 40px;
  display: block; width: calc(var(--cs) * 9 + 4px); margin: 0 auto;
  border: 2px solid var(--frame); border-bottom: 0; border-radius: 3px 3px 0 0;
  padding-bottom: 40px; touch-action: manipulation; cursor: pointer;
}
.row { display: grid; grid-template-columns: repeat(9, var(--cs)); height: var(--cs); transition: height .3s ease, opacity .3s ease; }
.row.collapse { height: 0; opacity: 0; overflow: hidden; }
.cell {
  position: relative; display: grid; place-items: center;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: calc(var(--cs) * .66); font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cell:nth-child(9) { border-right: 0; }
.cell.live { color: var(--ink); }
.cell.live.added { color: var(--added); }
.cell.dead { color: var(--dead); }
.cell.sel, .cell.drag { background: var(--sel); }
.cell.cand::after { content: ''; position: absolute; inset: 3px; border-radius: 7px; background: var(--cand); }
.cell.tapped { animation: tap .18s ease; }
@keyframes tap { 50% { transform: scale(.88); } }
.cell.hint { animation: hint 1.1s ease-in-out infinite; }
@keyframes hint { 0%, 100% { background: transparent; } 50% { background: var(--hint); } }
.cell.shake { animation: shake .35s ease; color: var(--bad); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.cell.hit { animation: hit .45s ease; }
@keyframes hit {
  0% { transform: scale(1); color: var(--accent); background: var(--sel); }
  35% { transform: scale(1.25); color: var(--accent); background: var(--sel); }
  100% { transform: scale(1); }
}
.cell.new { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) backwards; animation-delay: var(--d, 0ms); }
@keyframes pop { from { transform: scale(.2); opacity: 0; } }

/* ---------- alsó gombok ---------- */

.g-bottom {
  flex: none; display: grid; grid-template-columns: repeat(3, 1fr); justify-items: center; align-items: center;
  padding: 10px 20px 18px; max-width: 480px; width: 100%; margin: 0 auto;
}
.fab {
  position: relative; width: 72px; height: 72px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow); color: var(--accent);
  display: grid; place-items: center; transition: transform .1s, opacity .2s;
}
.fab:active { transform: scale(.93); }
.fab > svg { width: 38px; height: 38px; }
.fab#b-undo { width: 58px; height: 58px; }
.fab#b-undo > svg { width: 30px; height: 30px; }
.fab.empty { opacity: .45; }
.badge {
  position: absolute; top: -4px; right: -6px; min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 99px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px; box-shadow: 0 0 0 3px var(--bg);
}
.coin-badge { padding-left: 3px; right: -14px; }
.coin-badge svg { width: 24px; height: 24px; }
.fab.pulse { animation: pulse 1s ease 3; }
@keyframes pulse { 50% { transform: scale(1.12); box-shadow: 0 0 0 10px var(--accent-soft), var(--shadow); } }

/* ---------- effektek ---------- */

#fx, #confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
#fx-text { position: fixed; inset: 0; pointer-events: none; z-index: 41; }
.fx-score, .fx-row, .fx-digit {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-weight: 900; animation: float 1s ease-out forwards;
}
.fx-score { font-size: 24px; color: var(--accent); text-shadow: 0 2px 0 var(--bg); }
.fx-row { font-size: 28px; color: #fff; background: var(--accent); padding: 4px 14px; border-radius: 99px; box-shadow: var(--shadow); animation-duration: 1.3s; }
.fx-digit { font-size: 18px; color: #7a4b00; background: #ffe07a; padding: 4px 12px; border-radius: 99px; box-shadow: var(--shadow); animation-duration: 1.6s; }
@keyframes float {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

.toast {
  position: fixed; left: 50%; bottom: calc(120px + env(safe-area-inset-bottom)); z-index: 45;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: .25s;
  width: max-content; max-width: calc(100% - 32px); text-align: center;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 17px; font-weight: 700;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- napi kihívás ---------- */

.daily-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 16px 24px; max-width: 480px; width: 100%; margin: 0 auto; }
.trophy { display: grid; place-items: center; }
.trophy svg { width: 110px; height: 110px; transition: .4s; }
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-title { text-align: center; font-size: 21px; font-weight: 900; text-transform: capitalize; }
.month-title .muted { font-size: 15px; font-weight: 700; text-transform: none; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.cal-head span { font-size: 14px; font-weight: 800; color: var(--muted); }
.cal-day { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 18px; font-weight: 800; background: var(--bg2); position: relative; }
.cal-day.empty { background: none; }
.cal-day.future { opacity: .35; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.done { background: radial-gradient(circle at 50% 35%, #ffe17a, #f2b51c 70%, #c98a0c); color: #6b3a05; }
.cal-day.sel { background: var(--accent); color: #fff; box-shadow: none; }
.cal-day.sel.done { background: radial-gradient(circle at 50% 35%, #ffe17a, #f2b51c 70%, #c98a0c); color: #6b3a05; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }

/* ---------- felugró ablak ---------- */

.modal {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
  background: rgba(10, 16, 30, .45); animation: fade .2s ease;
}
.modal-card {
  width: min(100%, 440px); max-height: calc(100% - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: flex; flex-direction: column; background: var(--card); border-radius: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: rise .28s cubic-bezier(.3, 1.4, .5, 1);
}
@keyframes rise { from { transform: translateY(30px) scale(.94); opacity: 0; } }
.modal-head { padding: 20px 20px 0; }
.modal-head h2 { margin: 0; text-align: center; font-size: 27px; font-weight: 900; }
.modal-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.modal-body p { margin: 0; text-align: center; font-size: 19px; }
.modal-body .btn { width: 100%; }

.win-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-stat { background: var(--bg2); border-radius: 16px; padding: 10px; text-align: center; font-size: 15px; color: var(--muted); font-weight: 700; }
.big-stat b { display: block; font-size: 30px; color: var(--ink); font-weight: 900; font-variant-numeric: tabular-nums; }
.rewards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.reward { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px 6px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 18px; font-weight: 900; animation: rise .4s ease backwards .3s; }
.reward svg { width: 24px; height: 24px; }
.cup { display: grid; place-items: center; }
.cup svg { width: 90px; height: 90px; animation: rise .5s cubic-bezier(.3, 1.6, .5, 1); }

.row-set, .modal-body > .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 18px; min-height: 40px; }
.switch { width: 54px; height: 32px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg2); }
.seg button { padding: 10px 4px; border-radius: 11px; font-size: 16px; font-weight: 800; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--card); color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }

.plist { display: flex; flex-direction: column; gap: 8px; }
.pitem { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--bg2); font-size: 19px; font-weight: 800; cursor: pointer; }
.pitem.cur { box-shadow: inset 0 0 0 2px var(--accent); }
.pitem .pmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.pitem .pmeta small { font-size: 14px; color: var(--muted); font-weight: 700; }
.pdel { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--bad); font-size: 22px; flex: none; }
.pdel.confirm { width: auto; padding: 0 12px; border-radius: 12px; font-size: 15px; background: var(--bad); color: #fff; }
.add-row { display: flex; gap: 8px; }
.add-row .btn { width: auto; min-width: 56px; font-size: 26px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--bg2); border-radius: 16px; padding: 12px; text-align: center; font-size: 14px; color: var(--muted); font-weight: 700; }
.stat b { display: block; font-size: 26px; color: var(--accent); font-weight: 900; }

/* szabályok */
.rule-lead { font-weight: 900; font-size: 19px !important; }
.rule-examples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rule-examples figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rule-examples figcaption { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.mini i { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; font-style: normal; font-size: 18px; font-weight: 800; background: var(--bg2); color: var(--muted); }
.mini i.on { background: var(--accent); color: #fff; }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 16px; line-height: 1.35; font-weight: 600; }
.rules b { font-weight: 900; }

#update-bar {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 99px;
  background: var(--ink); color: var(--bg); font-size: 16px; font-weight: 800; box-shadow: var(--shadow); white-space: nowrap;
}
#update-bar button { background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 99px; font-weight: 900; }

@media (max-height: 700px) {
  .g-score { font-size: 28px; padding-bottom: 6px; }
  .topbar { height: 52px; }
  .fab { width: 62px; height: 62px; }
  .fab#b-undo { width: 52px; height: 52px; }
}

/* belépőkód, ranglista */
.code-box { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: 16px; background: var(--bg2); text-align: center; }
.code-box b { font-size: 26px; font-weight: 900; letter-spacing: 2px; font-variant-numeric: tabular-nums; -webkit-user-select: text; user-select: text; }
.code-box small { font-size: 14px; line-height: 1.3; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.code-input { text-align: center; font-size: 26px; letter-spacing: 3px; text-transform: uppercase; }
.form-err { color: var(--bad); font-size: 16px !important; }
.link-btn.center { align-self: center; }
#screen-welcome .link-btn { margin-top: -18px; }
.seg.two { grid-template-columns: 1fr 1fr; }
.board-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.board-list > p { padding: 20px 0; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 14px; background: var(--bg2); }
.lb-row.me { box-shadow: inset 0 0 0 2px var(--accent); }
.lb-rank { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 16px; color: var(--muted); flex: none; }
.lb-rank.top1 { background: #ffd451; color: #7a4b00; }
.lb-rank.top2 { background: #d9dee6; color: #4a5260; }
.lb-rank.top3 { background: #f0b78a; color: #6b3a12; }
.lb-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 18px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { font-size: 13px; color: var(--muted); font-weight: 700; }
.lb-score { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
