/* Малки умници – стилове
   Идеята: всичко, което се натиска, изглежда като дървено/пластмасово блокче
   с по-тъмна „основа“ отдолу, която изчезва при натискане. */

:root {
  --sky: #BFE3F5;
  --sky-soft: #E6F4FB;
  --ink: #1F3552;
  --ink-soft: #52698A;
  --sun: #FFC93C;
  --sun-deep: #D99A00;
  --leaf: #3DBE7A;
  --leaf-deep: #238A55;
  --berry: #E8457A;
  --paper: #FFFFFF;
  --line: #CFE3EE;
  --pad-blue: #2E86C1; /* за играта Симон – --sky е твърде бледо за пул */

  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Trebuchet MS", system-ui, sans-serif;
  --r-lg: 22px;
  --r-md: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--sky-soft);
  touch-action: manipulation;
}

a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }

:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; border-radius: 8px; }

h1, h2 { line-height: 1.15; margin: 0 0 .5em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); }
h2 { font-size: 1.3rem; }

.muted { color: var(--ink-soft); margin: 0; }
.small { font-size: .875rem; }

/* ---------- Блокчета (бутони) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 1.4em;
  font: inherit; font-weight: 800; text-decoration: none;
  color: var(--ink); border: 0; border-radius: var(--r-md); cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn-sun   { background: var(--sun);   box-shadow: 0 5px 0 var(--sun-deep); }
.btn-plain { background: var(--paper); box-shadow: 0 5px 0 var(--line), inset 0 0 0 2px var(--line); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--sun-deep); }
.btn-plain:active { box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--line); }
.btn-wide { width: 100%; margin-top: .5rem; }

.link-btn {
  font: inherit; font-weight: 700; color: var(--ink); background: none; border: 0;
  padding: .4em .2em; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn.danger { color: var(--berry); }

/* ---------- Родителска част ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(.8rem, env(safe-area-inset-top)) 1.2rem .8rem;
  background: var(--sky);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; text-decoration: none; }
.brand-mark { font-size: 1.5rem; }
.topnav { display: flex; align-items: center; gap: .75rem; }
.topnav form { margin: 0; }
.who { font-weight: 700; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 980px; margin: 0 auto; padding: 1.5rem 1.2rem max(3rem, env(safe-area-inset-bottom)); }

.panel {
  background: var(--paper); border-radius: var(--r-lg);
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: 0 6px 0 var(--line);
}
.panel + .panel { margin-top: 1.5rem; }
.narrow { max-width: 460px; margin: 0 auto; }

.flash { padding: .8rem 1rem; border-radius: var(--r-md); font-weight: 700; margin: 0 0 1rem; }
.flash-ok  { background: #DFF5E9; color: var(--leaf-deep); }
.flash-err { background: #FCE3EC; color: #A4244F; }

/* Формуляри */
.field { display: block; margin: 0 0 1.1rem; border: 0; padding: 0; }
.field > span, .field > legend { display: block; font-weight: 700; margin-bottom: .35rem; padding: 0; }
.field input, .field select {
  width: 100%; min-height: 50px; padding: .6rem .9rem;
  font: inherit; color: var(--ink); background: var(--sky-soft);
  border: 2px solid var(--line); border-radius: var(--r-md);
}
.field input:focus, .field select:focus { border-color: var(--ink); outline: none; }
.err { display: block; color: #A4244F; font-style: normal; font-weight: 700; font-size: .9rem; margin-top: .3rem; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 2px dashed var(--line); }

/* ---------- Профил: табове ---------- */
.tabs { display: flex; gap: .3rem; margin: 0 0 1.3rem; border-bottom: 2px solid var(--line); }
.tab-btn {
  flex: 1; min-width: 0; padding: .6rem .3rem; margin-bottom: -2px;
  font: inherit; font-weight: 700; font-size: .85rem; line-height: 1.2; text-align: center;
  color: var(--ink-soft); background: none; border: 0; border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab-btn[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--sun-deep); }
.tab-panel[hidden] { display: none; }

/* ---------- Профил: 2FA ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0 0 1rem; padding: .5rem 1rem; border-radius: 999px; font-weight: 800;
}
.status-on { background: #DFF5E9; color: var(--leaf-deep); }
details { margin-top: 1rem; }
details summary { cursor: pointer; font-weight: 700; padding: .4rem 0; }
details form { margin-top: .75rem; }
.qr-box { display: grid; place-items: center; margin: 1rem 0; padding: 1rem; background: var(--paper); border-radius: var(--r-md); }
code { background: var(--sky-soft); padding: .15em .4em; border-radius: 6px; font-size: .95em; word-break: break-all; }
.recovery-box {
  margin-bottom: 1.2rem; padding: 1rem 1.2rem; background: #FFF6DF;
  border: 2px solid var(--sun-deep); border-radius: var(--r-md);
}
.recovery-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem;
  margin: .6rem 0 0; padding: 0; list-style: none; font-family: ui-monospace, monospace; font-weight: 700;
}
.recovery-list li { background: var(--paper); padding: .4rem .6rem; border-radius: 8px; text-align: center; }

.avatar-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: .5rem; }
.avatar-pick input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-pick span {
  display: grid; place-items: center; aspect-ratio: 1; font-size: 1.9rem;
  background: var(--sky-soft); border-radius: var(--r-md); cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--line);
}
.avatar-pick input:checked + span { background: var(--sun); box-shadow: 0 4px 0 var(--sun-deep); }
.avatar-pick input:focus-visible + span { outline: 4px solid var(--ink); outline-offset: 2px; }

/* Начална страница */
.hero { max-width: 640px; margin: 2rem auto; text-align: center; }
.hero .lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 36em; margin: 0 auto 1.8rem; }
.hero .actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.hero-cards { display: grid; grid-template-columns: repeat(2, 76px); gap: 10px; justify-content: center; margin-bottom: 1.8rem; }
.mini-card {
  display: grid; place-items: center; height: 76px; font-size: 2.6rem;
  background: var(--paper); border-radius: 14px; box-shadow: inset 0 0 0 3px var(--leaf), 0 5px 0 var(--line);
}
.mini-card.is-back {
  background: var(--sun) radial-gradient(rgba(255,255,255,.45) 18%, transparent 21%) 0 0 / 19px 19px;
  box-shadow: 0 5px 0 var(--sun-deep);
}

/* Табло */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
.empty { text-align: center; }
.empty-mark { font-size: 3.5rem; margin: 0; }

.kids { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.kid { background: var(--paper); border-radius: var(--r-lg); padding: 1.25rem; box-shadow: 0 6px 0 var(--line); }
.kid-id { display: flex; align-items: center; gap: .9rem; }
.kid-id h2 { margin: 0; }
.kid-id > div { flex: 1; min-width: 0; }
.avatar {
  display: grid; place-items: center; width: 60px; height: 60px; flex: none;
  font-size: 2.2rem; background: var(--sky); border-radius: 18px;
}
.avatar.big { width: 84px; height: 84px; font-size: 3.2rem; border-radius: 24px; background: var(--paper); box-shadow: 0 5px 0 var(--sky-deep, #8CCBEA); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; text-decoration: none; background: var(--sky-soft); }

.kid-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: .8rem; margin: 1.1rem 0; }
.kid-game {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem .9rem; background: var(--sky-soft); border-radius: var(--r-md);
}
.level-dots { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.game-name { font-weight: 800; width: 100%; margin-bottom: 2px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--leaf); }
.btn-play { min-height: 48px; }

.kid-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.kid-stats div { text-align: center; }
.kid-stats dt { font-size: .8rem; color: var(--ink-soft); }
.kid-stats dd { margin: 0; font-weight: 800; font-size: 1.15rem; }

.recent { margin-top: 1rem; }
.recent summary { cursor: pointer; font-weight: 700; padding: .4rem 0; }
.recent table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: .5rem 0; }
.recent th, .recent td { text-align: left; padding: .4rem .3rem; border-bottom: 1px solid var(--line); }
.recent th { font-weight: 700; color: var(--ink-soft); }

/* ---------- Игра ---------- */
body.play {
  height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--sky);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html:has(body.play) { height: 100%; }

.game {
  position: fixed; inset: 0;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.screen { height: 100%; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* Избор на тема */
/* .game вече е с padding за safe-area – тук го компенсираме с отрицателен margin,
   за да опре topbar-ът в истинския ръб на екрана и да изглежда точно като в dashboard.php */
#screen-pick > .topbar, #screen-lobby > .topbar {
  flex: none;
  margin: calc(-1 * max(12px, env(safe-area-inset-top)))
          calc(-1 * max(12px, env(safe-area-inset-right)))
          0
          calc(-1 * max(12px, env(safe-area-inset-left)));
}
.pick-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(14px, 3vh, 28px);
}
.pick-head { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.hello { margin: 0; font-size: clamp(1.4rem, 4.5vw, 2rem); font-weight: 800; }

.pick-group { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.pick-label { margin: 0; font-size: clamp(.95rem, 2.6vw, 1.15rem); font-weight: 700; color: var(--ink-soft); }

.themes { display: grid; grid-template-columns: repeat(2, auto); gap: clamp(12px, 2.5vmin, 22px); }
@media (min-aspect-ratio: 4/3) { .themes { grid-template-columns: repeat(4, auto); } }
.theme-btn {
  --t: clamp(96px, min(34vw, 24vh), 170px);
  width: var(--t); height: var(--t); padding: 0; border: 0; cursor: pointer;
  background: var(--paper); border-radius: calc(var(--t) * .2);
  box-shadow: 0 8px 0 #8CCBEA;
  transition: transform .08s, box-shadow .08s;
}
.theme-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #8CCBEA; }
.theme-icon { font-size: calc(var(--t) * .55); line-height: 1; }

.levels { display: flex; gap: clamp(6px, 2vw, 10px); flex-wrap: wrap; justify-content: center; }
.level-btn {
  width: clamp(40px, 12.5vw, 54px); height: clamp(40px, 12.5vw, 54px); border: 0; border-radius: 50%; cursor: pointer;
  font: inherit; font-size: 1.35rem; font-weight: 800; color: var(--ink);
  background: var(--paper); box-shadow: 0 4px 0 #8CCBEA;
}
.level-btn[aria-pressed="true"] { background: var(--leaf); color: var(--paper); box-shadow: 0 4px 0 var(--leaf-deep); }
.level-btn:disabled { opacity: .55; cursor: default; font-size: 1.1rem; }

.pick-foot { display: flex; gap: 10px; }
.chip {
  display: inline-grid; place-items: center; min-width: 48px; height: 48px; padding: 0 .9rem;
  font: inherit; font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none;
  background: rgba(255,255,255,.7); border: 0; border-radius: 16px; cursor: pointer;
}
.parent-link { font-size: .9rem; color: var(--ink-soft); }

/* Дъска */
.board-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.chip.level-tag { cursor: default; font-size: .95rem; white-space: nowrap; }
.found { --n: 4; display: flex; gap: 4px; flex: 1; min-width: 0; justify-content: center; }
.slot {
  --d: min(30px, calc((100vw - 170px) / var(--n) - 4px));
  display: grid; place-items: center; width: var(--d); height: var(--d); font-size: calc(var(--d) * .62); flex: none;
  border-radius: 50%; background: rgba(255,255,255,.55);
}
.slot.on { background: var(--paper); animation: pop .35s ease-out; }

/* overflow-y: auto е предпазна мрежа – ако някога картите излязат по-едри,
   отколкото мястото позволява, екранът да позволи скрол вместо картите
   да се препокрият визуално с .choices под тях. */
.board-area { flex: 1; min-height: 0; display: flex; overflow-y: auto; }
.board {
  --s: 100px; --gap: 12px;
  margin: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap);
}

/* Симон: 4 големи пула в 2x2 */
.board.simon-board {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: clamp(10px, 3vmin, 18px); width: min(88vw, 420px); aspect-ratio: 1;
}
.board.simon-board.shake { animation: shake .4s; }
.pad {
  border: 0; border-radius: var(--r-lg); cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: grid; place-items: center; font-size: clamp(2rem, 10vmin, 3.4rem);
  filter: brightness(.82); box-shadow: inset 0 -8px 0 rgba(0,0,0,.15);
  transition: filter .1s, transform .08s;
}
.pad:active { transform: scale(.96); }
.pad.lit { filter: brightness(1.15); box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.pad-face { filter: drop-shadow(0 2px 0 rgba(0,0,0,.2)); }
.pad-red    { background: var(--berry); }
.pad-green  { background: var(--leaf); }
.pad-yellow { background: var(--sun); }
.pad-blue   { background: var(--pad-blue); }

.card {
  width: var(--s); height: var(--s); padding: 0; border: 0; background: none;
  perspective: 900px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  border-radius: calc(var(--s) * .16);
}
.card-inner {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .38s cubic-bezier(.3, 1.35, .5, 1);
}
.card.open .card-inner { transform: rotateY(180deg); }
.card:not(.open):active .card-inner { transform: scale(.94); }

.face {
  position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: calc(var(--s) * .16);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.back {
  background: var(--sun) radial-gradient(rgba(255,255,255,.45) 17%, transparent 20%) 0 0 / calc(var(--s) * .25) calc(var(--s) * .25);
  box-shadow: inset 0 calc(var(--s) * -.07) 0 var(--sun-deep);
}
.front {
  transform: rotateY(180deg);
  background: var(--paper);
  font-size: calc(var(--s) * .58); line-height: 1;
  box-shadow: inset 0 calc(var(--s) * -.07) 0 var(--line);
}
.card.done .front {
  box-shadow: inset 0 0 0 calc(var(--s) * .05) var(--leaf), inset 0 calc(var(--s) * -.07) 0 #BDE8D0;
}
.card.done { animation: pop .45s ease-out; }

/* Какво изчезна?: избираеми отговори */
.choices { flex: none; padding: 10px 0 4px; }
.choices-label { margin: 0 0 .6rem; text-align: center; font-weight: 700; color: var(--ink-soft); }
.choices-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.choice-btn {
  width: clamp(44px, 16vw, 64px); height: clamp(44px, 16vw, 64px);
  padding: 0; border: 0; border-radius: 18px; cursor: pointer;
  background: var(--paper); box-shadow: 0 5px 0 var(--line);
  display: grid; place-items: center; font-size: clamp(1.4rem, 7vw, 2rem);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.choice-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.choice-btn.wrong { animation: shake .4s; opacity: .35; box-shadow: none; }
.choice-btn:disabled { cursor: default; }

/* Кое не е на място?: 4 плочки в 2x2, преизползва мрежата на Симон */
.board.oddone-board {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: clamp(10px, 3vmin, 18px); width: min(88vw, 420px); aspect-ratio: 1;
}
.oddone-tile {
  border: 0; border-radius: var(--r-lg); cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: var(--paper); box-shadow: 0 5px 0 var(--line);
  display: grid; place-items: center; font-size: clamp(2.2rem, 11vmin, 3.6rem);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.oddone-tile:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.oddone-tile.wrong { animation: shake .4s; opacity: .35; box-shadow: none; }
.oddone-tile:disabled { cursor: default; }

/* Намери сянката / Сортиране: влачими плочки */
.board.shadow-board, .board.sort-board {
  display: flex; flex-direction: column; gap: clamp(16px, 4vh, 28px);
  width: 100%; max-width: 460px; margin: auto; padding: 0 4px;
}
/* min-height пази реда от свиване до 0, докато последната плочка се влачи
   (иначе редът отдолу скача нагоре точно когато детето пуска пръст) */
.shadow-row, .sort-pool { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 72px; }
.shadow-tile {
  width: clamp(48px, 17vw, 72px); height: clamp(48px, 17vw, 72px);
  padding: 0; border: 0; border-radius: 16px; cursor: grab;
  background: var(--paper); box-shadow: 0 4px 0 var(--line); touch-action: none;
  display: grid; place-items: center; font-size: clamp(1.6rem, 7.5vw, 2.3rem);
  -webkit-tap-highlight-color: transparent;
}
.shadow-tile.dragging { cursor: grabbing; box-shadow: 0 10px 18px rgba(31, 53, 82, .3); z-index: 50; }
.shadow-slot {
  width: clamp(48px, 17vw, 72px); height: clamp(48px, 17vw, 72px); border-radius: 16px;
  background: var(--sky-soft); display: grid; place-items: center;
  font-size: clamp(1.6rem, 7.5vw, 2.3rem); border: 3px dashed var(--line);
}
.shadow-slot .silhouette { filter: brightness(0); opacity: .5; }
.shadow-slot.drag-over { border-color: var(--sun-deep); background: #FFF6DF; }
.shadow-slot.filled { border-style: solid; border-color: var(--leaf); background: #DFF5E9; }

.sort-baskets { display: flex; gap: 14px; justify-content: center; }
.sort-basket {
  flex: 1; max-width: 170px; min-height: 100px; border-radius: 20px;
  background: var(--sky-soft); border: 3px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  font-weight: 700; color: var(--ink-soft); padding: .6rem; text-align: center;
}
.sort-basket .basket-icon { font-size: clamp(1.6rem, 8vw, 2.2rem); }
.sort-basket.drag-over { border-style: solid; border-color: var(--sun-deep); background: #FFF6DF; }

/* ---------- Дуел ---------- */
.duel-lobby { justify-content: flex-start; overflow-y: auto; padding: 8px 0; }
.duel-group { width: min(100%, 440px); }
.duel-group[hidden], .duel-empty[hidden], .duel-question[hidden], .err[hidden] { display: none; }
.duel-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.duel-empty { text-align: center; }
.duel-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--paper); border-radius: var(--r-md); box-shadow: 0 3px 0 var(--line);
}
.duel-row .avatar { width: 44px; height: 44px; font-size: 1.6rem; border-radius: 12px; }
.duel-name { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--line); }
.duel-row.online .duel-dot { background: var(--leaf); }
.duel-row.busy .duel-dot { background: var(--sun-deep); }
.duel-go { min-height: 44px; padding: 0 1rem; font-size: 1.2rem; }
.duel-modal-icon { font-size: 3rem; margin: 0; line-height: 1.1; }

.duel-scores { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.3rem; }
.duel-score { display: flex; align-items: center; gap: 6px; }
.duel-score .avatar { width: 40px; height: 40px; font-size: 1.5rem; border-radius: 12px; background: var(--paper); }
.duel-vs { color: var(--ink-soft); }
.duel-stage {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.duel-countdown { margin: 0; font-size: clamp(4rem, 26vw, 8rem); font-weight: 800; line-height: 1; animation: pop .3s ease-out; }
.duel-countdown.ready { font-size: clamp(1.6rem, 7vw, 2.4rem); text-align: center; }
.duel-question { width: min(100%, 460px); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.duel-timer { width: 100%; height: 10px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.6); }
.duel-timer span { display: block; height: 100%; width: 100%; background: var(--leaf); transition: width .1s linear; }
.duel-prompt {
  margin: 0; text-align: center; font-weight: 800; line-height: 1.35;
  font-size: clamp(1.3rem, 6vw, 2rem); white-space: pre-line; overflow-wrap: anywhere;
}
.duel-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.duel-opt {
  min-height: clamp(60px, 16vw, 80px); padding: .5rem; border: 0; border-radius: var(--r-lg); cursor: pointer;
  font: inherit; font-weight: 800; font-size: clamp(1.2rem, 6vw, 1.9rem); color: var(--ink);
  background: var(--paper); box-shadow: 0 5px 0 var(--line); overflow-wrap: anywhere;
  transition: transform .08s, box-shadow .08s;
}
.duel-opt:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.duel-opt:disabled { cursor: default; }
.duel-opt.picked { outline: 4px solid var(--ink); outline-offset: -4px; }
.duel-opt.right { background: #DFF5E9; box-shadow: 0 5px 0 var(--leaf); }
.duel-opt.wrong { background: #FCE3EC; box-shadow: 0 5px 0 var(--berry); }
.duel-status { margin: 0; min-height: 1.5em; text-align: center; font-weight: 700; color: var(--ink-soft); }
.duel-final { margin: 0 0 .4rem; font-size: 1.6rem; font-weight: 800; }

.kid-game-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.duel-record { font-weight: 700; color: var(--ink-soft); }
.duel-record > span { white-space: nowrap; }

/* Приятели (родителска страница) */
.friend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.friend-list li { display: flex; align-items: center; gap: .75rem; }
.friend-list .avatar { width: 44px; height: 44px; font-size: 1.6rem; border-radius: 12px; }
.friend-list form { margin: 0; }
.friend-name { flex: 1; min-width: 0; font-weight: 700; }
.invite-code { display: flex; align-items: center; gap: .75rem; margin: .6rem 0; }
.invite-meta { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; min-width: 0; }
.invite-code code { font-size: 1.4rem; letter-spacing: .15em; padding: .3em .6em; }
.invite-code form { margin: 0 0 0 auto; }

/* Победа */
.win {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 5;
  background: rgba(31, 53, 82, .45);
}
.win[hidden] { display: none; }
.win-box {
  text-align: center; padding: 1.6rem 1.8rem 2rem; background: var(--paper);
  border-radius: 28px; box-shadow: 0 8px 0 #8CCBEA; animation: pop .4s ease-out;
}
.win-emoji { font-size: 4rem; margin: 0; line-height: 1.1; }
.win-title { font-size: 2.2rem; font-weight: 800; margin: .2rem 0 1.2rem; }
.win-actions { display: flex; gap: 14px; justify-content: center; }
.block-btn {
  width: 84px; height: 84px; border: 0; border-radius: 22px; cursor: pointer;
  font-size: 2.3rem; background: var(--sky-soft); box-shadow: 0 6px 0 #8CCBEA;
  transition: transform .08s, box-shadow .08s;
}
.block-btn.go { background: var(--leaf); box-shadow: 0 6px 0 var(--leaf-deep); }
.block-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #8CCBEA; }
.block-btn[hidden] { display: none; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.confetti .bit { position: absolute; top: -50px; animation: fall 2.6s ease-in forwards; }

/* Родителски код за изход по средата на рунд */
.pin-gate {
  position: fixed; inset: 0; z-index: 7; display: grid; place-items: center;
  background: rgba(31, 53, 82, .55); padding: 1rem;
}
.pin-gate[hidden] { display: none; }
.pin-box {
  width: min(320px, 100%); text-align: center; padding: 1.6rem 1.6rem 1.8rem;
  background: var(--paper); border-radius: 28px; box-shadow: 0 8px 0 #8CCBEA; animation: pop .3s ease-out;
}
.pin-title { font-weight: 800; font-size: 1.15rem; margin: 0 0 .4rem; }
.pin-input {
  width: 100%; margin-top: 1rem; padding: .7rem; text-align: center;
  font: inherit; font-size: 2rem; font-weight: 800; letter-spacing: .5em;
  color: var(--ink); background: var(--sky-soft); border: 2px solid var(--line); border-radius: var(--r-md);
}
.pin-input:focus { border-color: var(--ink); outline: none; }
.pin-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1.2rem; }

@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake {
  10%, 90% { transform: translateX(-2%); }
  20%, 80% { transform: translateX(4%); }
  30%, 50%, 70% { transform: translateX(-8%); }
  40%, 60% { transform: translateX(8%); }
}
@keyframes fall {
  to { transform: translate(var(--drift, 0), 110vh) rotate(540deg); opacity: .9; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.panel form + .muted { margin-top: 1.2rem; }
