:root {
  --gold: #978667;
  --gold-dark: #7a6b51;
  --sand: #EBD7B2;
  --sand-soft: #f4ead6;
  --cream: #FAF8F5;
  --ink: #24262D;
  --ink-2: #4E5559;
  --muted: #8a8f93;
  --line: #e6e0d6;
  --water: #2f5d62;
  --ok: #3f7d4e;
  --bad: #b5523b;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(36, 38, 45, .12);
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", "Comic Sans MS", cursive;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #e9e4da;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: inherit; }

.shell {
  position: relative;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  background: var(--cream);
  box-shadow: 0 0 40px rgba(0, 0, 0, .08);
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-bottom: calc(84px + var(--safe-b)); }
main.no-tabs { padding-bottom: 24px; }

/* ---------- típus ---------- */
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 1.9rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { line-height: 1.55; margin: 0 0 1em; }
.hand { font-family: var(--hand); font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 20px; }
.stack > * + * { margin-top: 14px; }

/* ---------- gombok ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 14px 20px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: var(--cream);
  font-weight: 700; font-size: 1.02rem; text-decoration: none;
  transition: transform .12s ease, background .2s;
}
.btn:active { transform: scale(.97); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.light { background: var(--cream); color: var(--ink); }
.btn.small { min-height: 42px; padding: 8px 16px; font-size: .9rem; width: auto; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.linkbtn { background: none; border: 0; color: var(--gold-dark); font-weight: 700; cursor: pointer; padding: 8px; text-decoration: underline; }

/* ---------- kezdőlap ---------- */
.hero {
  position: relative; min-height: 62vh; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 28px 22px 26px;
  background: var(--water) center/cover no-repeat;
  border-radius: 0 0 32px 32px; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(36,38,45,.15) 0%, rgba(36,38,45,.25) 40%, rgba(36,38,45,.88) 100%);
}
.hero > * { position: relative; }
.hero .logo { font-family: var(--hand); font-size: 3.4rem; line-height: .9; margin: 0 0 6px; }
.hero .sub { font-weight: 600; opacity: .92; }
.hero .badge {
  position: absolute; top: 18px; left: 18px;
  background: rgba(250,248,245,.92); color: var(--ink);
  padding: 6px 12px; border-radius: 999px; font-size: .75rem; font-weight: 700;
}
.steps { display: grid; gap: 10px; }
.step { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line); }
.step > b { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--sand); color: var(--ink); }

/* ---------- nyelvválasztó ---------- */
.langs { display: flex; gap: 8px; }
.langs button {
  width: 38px; height: 27px; padding: 0; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: none; opacity: .65; transition: opacity .15s, transform .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.langs button[aria-pressed="true"] { opacity: 1; border-color: var(--gold); transform: scale(1.08); }
.langs svg, .langbtn svg, .langrow .flag svg { width: 100%; height: 100%; display: block; }
.langs.on-hero { position: absolute; top: 16px; right: 16px; }
.langs.on-hero button[aria-pressed="true"] { border-color: var(--cream); }
.langbtn { width: 30px; height: 21px; padding: 0; border: 0; border-radius: 4px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3); flex: none; }
.langlist { display: grid; gap: 10px; }
.langrow {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 10px 16px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff; font-weight: 700; font-size: 1.05rem; cursor: pointer; text-align: left;
}
.langrow[aria-pressed="true"] { border-color: var(--gold); background: var(--sand-soft); }
.langrow .flag { width: 42px; height: 28px; border-radius: 5px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.25); flex: none; }

/* ---------- Boby ---------- */
.boby { display: flex; gap: 12px; align-items: flex-end; }
.boby svg { width: 74px; height: 74px; flex: none; }
.bubble {
  position: relative; flex: 1;
  background: #fff; border: 2px solid var(--sand); border-radius: 18px 18px 18px 4px;
  padding: 12px 14px; font-size: .95rem; line-height: 1.45;
}
.bubble .who { font-family: var(--hand); font-size: 1.25rem; color: var(--gold-dark); display: block; margin-bottom: 2px; }

/* ---------- űrlap ---------- */
.field label { display: block; font-weight: 700; margin-bottom: 8px; }
.input {
  width: 100%; min-height: 54px; padding: 12px 16px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff; font-size: 1.05rem;
}
.input:focus { outline: none; border-color: var(--gold); }
.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.avatars button, .choice {
  border: 2px solid var(--line); background: #fff; border-radius: 14px; cursor: pointer;
}
.avatars button { aspect-ratio: 1; font-size: 1.8rem; }
.avatars button[aria-pressed="true"], .choice[aria-pressed="true"] { border-color: var(--gold); background: var(--sand-soft); box-shadow: 0 0 0 3px rgba(151,134,103,.2); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { padding: 14px 12px; text-align: left; }
.choice .ci { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.choice b { display: block; }
.choice span.small { color: var(--ink-2); }
.error { color: var(--bad); font-weight: 600; font-size: .9rem; min-height: 1.2em; }

/* ---------- fejléc a játék közben ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: rgba(250,248,245,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .av { font-size: 1.6rem; }
.topbar .tname { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .score { background: var(--ink); color: var(--cream); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: .9rem; }
.topbar .back { border: 0; background: var(--sand-soft); border-radius: 50%; width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer; }

.letters { display: flex; gap: 6px; justify-content: center; padding: 12px 16px 4px; }
.letters span {
  width: 34px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  border: 2px dashed var(--sand); font-family: var(--hand); font-size: 1.6rem; color: var(--gold-dark); background: #fff;
}
.letters span.got { border-style: solid; border-color: var(--gold); background: var(--sand); color: var(--ink); }

/* ---------- térkép ---------- */
.mapwrap { margin: 12px 16px; border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); background: var(--water); scrollbar-width: none; }
.mapwrap::-webkit-scrollbar { display: none; }
.map { position: relative; width: 820px; aspect-ratio: 2000 / 1093; }
.map img { width: 100%; height: 100%; }
.map svg.route { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: .95rem;
  background: var(--cream); color: var(--ink); border: 4px solid var(--gold);
  box-shadow: 0 3px 10px rgba(0,0,0,.35); cursor: pointer; padding: 0;
}
.pin.done { background: var(--gold); color: #fff; border-color: var(--cream); }
.pin.locked { opacity: .75; filter: grayscale(.5); }
.pin.current { animation: pulse 1.6s infinite; z-index: 2; width: 42px; height: 42px; font-size: 1.1rem; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(235,215,178,.9), 0 3px 10px rgba(0,0,0,.35); }
  70% { box-shadow: 0 0 0 16px rgba(235,215,178,0), 0 3px 10px rgba(0,0,0,.35); }
  100% { box-shadow: 0 0 0 0 rgba(235,215,178,0), 0 3px 10px rgba(0,0,0,.35); }
}
.maphint { text-align: center; font-size: .78rem; color: var(--muted); margin-top: -4px; }

.next-card { margin: 4px 16px 16px; background: var(--ink); color: var(--cream); border-radius: var(--radius); padding: 18px; }
.next-card h2 { margin: 4px 0 8px; }
.next-card p { color: #d9d4ca; font-size: .92rem; }

.stlist { list-style: none; margin: 0; padding: 0 16px 16px; display: grid; gap: 8px; }
.stlist li { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stlist .n { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--sand-soft); flex: none; }
.stlist li.done .n { background: var(--gold); color: #fff; }
.stlist li.current { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(151,134,103,.15); }
.stlist .nm { flex: 1; font-weight: 600; }
.stlist .pts { font-weight: 800; color: var(--gold-dark); }

/* ---------- állomás ---------- */
.st-hero { position: relative; height: 230px; background: var(--water) center/cover no-repeat; }
.st-hero.mapcrop { background-image: url(../img/terkep.jpg); background-size: 520%; }
.st-hero .mk {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%; background: var(--cream); border: 5px solid var(--gold);
  display: grid; place-items: center; font-weight: 800; box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.st-hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 90px; background: linear-gradient(transparent, rgba(36,38,45,.75)); }
.st-hero .ttl { position: absolute; z-index: 1; left: 18px; right: 18px; bottom: 14px; color: #fff; }
.st-hero .ttl h1 { font-size: 1.5rem; margin: 0; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.sand { background: var(--sand-soft); border-color: var(--sand); }
.way { display: flex; gap: 10px; align-items: flex-start; }
.way .wi { font-size: 1.4rem; }

.task-q { font-size: 1.08rem; font-weight: 600; line-height: 1.45; }
.opts { display: grid; gap: 10px; }
.opt {
  width: 100%; text-align: left; padding: 14px 16px; min-height: 54px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.opt[aria-pressed="true"] { border-color: var(--gold); background: var(--sand-soft); }
.opt.right { border-color: var(--ok); background: #e7f2ea; }
.opt.wrong { border-color: var(--bad); background: #f8e7e2; }
.qcount { font-size: .8rem; font-weight: 700; color: var(--gold-dark); }

.range-val { font-size: 3rem; font-weight: 800; text-align: center; line-height: 1; }
.range-val small { font-size: .9rem; font-weight: 600; color: var(--ink-2); display: block; margin-top: 4px; }
input[type=range] { width: 100%; accent-color: var(--gold); height: 34px; }
.stepper { display: flex; gap: 10px; justify-content: center; }
.stepper button { width: 54px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1.3rem; font-weight: 800; cursor: pointer; }

.cipher-msg { font-size: 2.1rem; letter-spacing: 4px; text-align: center; padding: 10px 0; word-break: break-all; }
.keygrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keygrid div { background: var(--sand-soft); border-radius: 12px; padding: 8px 4px; text-align: center; font-weight: 800; }
.keygrid div span { display: block; font-size: 1.5rem; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.mitem { padding: 12px 10px; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; font-size: .9rem; text-align: left; }
.mitem[aria-pressed="true"] { border-color: var(--gold); background: var(--sand-soft); }
.mitem.paired { opacity: .55; border-style: dashed; }
.mitem .tag { float: right; font-weight: 800; color: var(--gold-dark); }
.wrong-flash { animation: shake .4s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.order li .mv button[disabled] { opacity: .3; }

.order { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.order li { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 10px 10px 14px; font-weight: 600; }
.order li .tx { flex: 1; }
.order li .mv { display: flex; flex-direction: column; gap: 4px; }
.order li .mv button { width: 40px; height: 32px; border-radius: 10px; border: 0; background: var(--sand-soft); cursor: pointer; font-weight: 800; }
.order li.right { border-color: var(--ok); }
.order li.wrong { border-color: var(--bad); }
.order li .yr { font-size: .78rem; color: var(--gold-dark); font-weight: 700; display: block; }

.timer { height: 10px; border-radius: 99px; background: var(--sand-soft); overflow: hidden; }
.timer > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--sand)); transition: width 1s linear; }
.timer-n { font-weight: 800; font-size: 1.4rem; text-align: right; }

.slots, .tiles { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.slots span { width: 42px; height: 52px; border-radius: 12px; border: 2px dashed var(--gold); display: grid; place-items: center; font-family: var(--hand); font-size: 2rem; background: #fff; }
.tiles button { width: 46px; height: 54px; border-radius: 12px; border: 0; background: var(--gold); color: #fff; font-family: var(--hand); font-size: 2rem; cursor: pointer; box-shadow: 0 3px 0 var(--gold-dark); }
.tiles button[disabled] { opacity: .2; }

.photo-preview { border-radius: 14px; overflow: hidden; background: var(--sand-soft); aspect-ratio: 4/3; display: grid; place-items: center; color: var(--ink-2); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.hintrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hintbox { background: #fff7e6; border: 1px dashed var(--gold); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }

/* ---------- eredmény modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(36,38,45,.6); display: grid; place-items: end center; padding: 0; }
.modal[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px; background: var(--cream); border-radius: 26px 26px 0 0;
  padding: 24px 20px calc(24px + var(--safe-b)); max-height: 92vh; overflow: auto;
  animation: up .28s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.bigpts { font-size: 3rem; font-weight: 800; text-align: center; line-height: 1; }
.bigletter {
  margin: 8px auto; width: 92px; height: 104px; border-radius: 20px; background: var(--sand);
  display: grid; place-items: center; font-family: var(--hand); font-size: 4.2rem; color: var(--ink);
  border: 3px solid var(--gold); animation: pop .6s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: scale(.2) rotate(-25deg); } to { transform: none; } }

/* ---------- ranglista ---------- */
.tabs { display: flex; background: var(--sand-soft); border-radius: 999px; padding: 4px; gap: 4px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 10px; font-weight: 700; cursor: pointer; font-size: .88rem; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.lb { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lb li { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.lb li.me { border-color: var(--gold); background: var(--sand-soft); }
.lb .rank { width: 30px; text-align: center; font-weight: 800; color: var(--gold-dark); }
.lb .rank.top { font-size: 1.4rem; }
.lb .av { font-size: 1.6rem; }
.lb .who { flex: 1; min-width: 0; }
.lb .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .who span { font-size: .78rem; color: var(--ink-2); }
.lb .sc { font-weight: 800; font-size: 1.1rem; }
.empty { text-align: center; color: var(--ink-2); padding: 30px 10px; }

/* ---------- fotó ---------- */
.cam { position: relative; border-radius: var(--radius); overflow: hidden; background: #111; aspect-ratio: 4/5; }
.cam video, .cam canvas, .cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam video.mirror { transform: scaleX(-1); }
.cam .frame-hint { position: absolute; inset: 10px; border: 3px solid rgba(235,215,178,.85); border-radius: 14px; pointer-events: none; }
.cam .cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #eee; text-align: center; padding: 20px; font-size: .95rem; }
.bgs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.bgs button { flex: none; width: 84px; border: 3px solid transparent; border-radius: 14px; padding: 0; overflow: hidden; background: #fff; cursor: pointer; }
.bgs button img { width: 100%; height: 56px; object-fit: cover; }
.bgs button span { display: block; font-size: .7rem; font-weight: 700; padding: 4px 2px; }
.bgs button[aria-pressed="true"] { border-color: var(--gold); }
.bgs .real { display: grid; place-items: center; height: 56px; font-size: 1.6rem; background: var(--sand-soft); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.result-img { border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; }

/* ---------- kupon ---------- */
.coupon {
  position: relative; overflow: hidden; border-radius: 24px; padding: 26px 22px; color: var(--cream);
  background: radial-gradient(120% 90% at 0% 0%, #3a3d47 0%, var(--ink) 60%);
  border: 3px solid var(--gold); text-align: center;
}
.coupon::before {
  content: ""; position: absolute; inset: -50%;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(235,215,178,.18) 80%, transparent 90%);
  animation: spin 4s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.coupon > * { position: relative; }
.coupon .pct { font-size: 5rem; font-weight: 800; line-height: 1; color: var(--sand); }
.coupon .code { font-family: ui-monospace, Menlo, monospace; font-size: 1.35rem; letter-spacing: 2px; background: rgba(250,248,245,.1); border-radius: 12px; padding: 10px; margin: 14px 0; }
.coupon .clock { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.coupon.redeemed { border-color: var(--muted); filter: grayscale(.8); }
.stamp { display: inline-block; border: 3px solid var(--bad); color: #f2b5a6; padding: 6px 14px; border-radius: 10px; transform: rotate(-6deg); font-weight: 800; letter-spacing: 2px; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; z-index: 30; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(36,38,45,.97); padding: 8px 6px calc(8px + var(--safe-b));
}
.tabbar[hidden] { display: none; }
.tabbar a { text-decoration: none; color: #b9b4aa; font-size: .7rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 12px; }
.tabbar a .ti { font-size: 1.35rem; }
.tabbar a.on { color: var(--sand); background: rgba(235,215,178,.08); }

/* ---------- toast + konfetti ---------- */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--cream); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
.toast[hidden] { display: none; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

@media (min-width: 520px) {
  body { padding: 0; }
  .shell { min-height: 100vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
