/* Хвани фишинга — стилове само за страницата /igra/.
   Общата обвивка (header, footer, .btn, .shell) идва от styles.css.
   Цветовете са custom properties от :root в styles.css — без нови хексове освен
   зеления за „безопасния“ имейл, който липсва в палитрата. */

:root {
  --ok: #1f9d55;
  --ok-soft: #dcf5e6;
  --mark: #f0c600;
}

[hidden] { display: none !important; }

.game { background: linear-gradient(180deg, var(--cream), #ffffff 46%); }

/* ---------- увод ---------- */

.game-intro {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 40px; align-items: center;
}
.game-intro-copy { max-width: 620px; }
.game-intro-art { justify-self: center; }
.game-intro-art img {
  width: 100%; max-width: 330px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.game-intro h1 {
  margin: 0 0 14px;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1.02;
  letter-spacing: -.045em;
  color: var(--navy);
}
.game-lead { margin: 0 0 26px; font-size: 18px; line-height: 1.65; color: var(--muted); }
.game-rules {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  margin: 0 0 30px; padding: 0; list-style: none;
}
.game-rules li {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 16px; font-size: 14px; color: var(--muted);
  box-shadow: var(--shadow-soft);
}
.game-rules strong { color: var(--navy); }

/* Докато играта не е стартирана, се вижда само уводът. */
.game:not(.is-started) .game-hud,
.game:not(.is-started) .mail-brief,
.game:not(.is-started) .game-board,
.game:not(.is-started) .verdict { display: none; }
.game.is-started .game-start { display: none; }

/* ---------- табло ---------- */

.game-hud {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px 22px;
  margin: 34px 0 26px; padding: 16px 22px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
/* Фокусира се програмно, за да не отскача страницата — рамка няма смисъл. */
.game-hud:focus { outline: none; }
.hud-level {
  margin: 0; padding: 7px 14px; border-radius: 999px;
  background: var(--navy); color: #fff;
  font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase;
}
.hud-note {
  margin: 0; padding: 7px 13px; border-radius: 999px;
  background: var(--pink-soft); color: #8c3f5d;
  font-size: 12px; font-weight: 900; letter-spacing: .04em;
}
.hud-count { margin: 0; font-size: 15px; color: var(--muted); }
.hud-count strong { color: var(--navy); font-size: 19px; }
.hud-actions { margin-left: auto; display: flex; gap: 10px; }
.hud-actions .btn { min-height: 44px; font-size: 14px; padding: 0 18px; }

/* ---------- сцена ---------- */

/* Половината знаци се разпознават само с контекст: „не е участвал в тази игра“
   не може да се види в самото писмо. Затова детето го научава преди да го отвори. */
.mail-brief {
  margin: 0 0 26px; padding: 20px 24px;
  background: var(--yellow-soft); border: 1px solid rgba(240, 198, 0, .45);
  border-radius: var(--radius-md);
}
.mail-brief h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 900;
  letter-spacing: .12em; text-transform: uppercase; color: #6c5200;
}
.mail-brief ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.mail-brief li { font-size: 15px; line-height: 1.6; color: var(--ink); }
.brief-note { margin: 12px 0 0; font-size: 13px; color: #8a6a00; font-style: italic; }

.game-board {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 34px; align-items: start;
}
.mail-scene { position: relative; min-height: 540px; }

.envelope {
  position: absolute; left: 50%; top: 150px;
  width: 290px; height: 190px; margin-left: -145px;
  perspective: 900px; pointer-events: none; z-index: 2;
}
.game:not(.is-flying):not(.is-opening) .envelope { opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility .45s; }
.env-body {
  position: absolute; inset: 0; border-radius: 14px;
  background: linear-gradient(160deg, var(--yellow), #ffc93c);
  box-shadow: var(--shadow);
}
.env-body::after {
  content: ""; position: absolute; inset: 0; border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.55) 0 48%, transparent 48%);
  opacity: .5;
}
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 112px;
  background: linear-gradient(180deg, var(--yellow-soft), var(--yellow));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center; transform: rotateX(0deg);
  transition: transform .75s cubic-bezier(.5, -0.2, .3, 1.2);
  z-index: 3;
}
.env-seal {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--pink); color: #fff; font-size: 24px;
  box-shadow: 0 8px 20px rgba(11, 36, 82, .2); z-index: 4;
}
.game.is-flying .envelope { animation: env-fly .95s cubic-bezier(.2, .85, .3, 1) both; }
.game.is-opening .env-flap { transform: rotateX(-172deg); }
.game.is-opening .env-seal { opacity: 0; transform: scale(.4) translateY(-20px); transition: opacity .3s ease, transform .5s ease; }

@keyframes env-fly {
  0%   { transform: translate(-150%, -220%) rotate(-24deg) scale(.45); opacity: 0; }
  60%  { opacity: 1; }
  80%  { transform: translate(0, 10px) rotate(2deg) scale(1.03); }
  100% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
}

/* ---------- писмото ---------- */

.letter {
  position: relative; z-index: 1;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 30px 32px 34px; box-shadow: var(--shadow);
  cursor: pointer; /* всичко в писмото може да се провери */
  opacity: 0; transform: translateY(46px) scale(.9); transform-origin: 50% 100%;
  transition: opacity .5s ease, transform .6s cubic-bezier(.2, .8, .3, 1);
}
.game.is-reading .letter, .game.is-done .letter { opacity: 1; transform: none; }

.letter-head { border-bottom: 1px dashed var(--line); padding-bottom: 16px; margin-bottom: 20px; }
.letter-row { margin: 0 0 7px; font-size: 15px; line-height: 1.5; color: var(--ink); word-break: break-word; }
.letter-label {
  display: inline-block; min-width: 46px;
  font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #93a0b5;
}
.letter-subject { font-size: 18px; font-weight: 800; color: var(--navy); }

.letter-body p { margin: 0 0 15px; font-size: 16px; line-height: 1.75; color: var(--ink); }
.letter-attach {
  margin: 18px 0 0; padding: 12px 14px; font-size: 14px;
  background: #f3f6fa; border: 1px solid var(--line); border-radius: 12px; color: var(--muted);
}
.letter-cta { margin: 20px 0 0; }
/* Стои над писмото: на тъч устройство няма курсор, така че това е единствената
   следа, че в писмото изобщо има какво да се натиска. */
.letter-tip {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 16px; font-size: 14px; font-weight: 700; color: var(--muted);
}
.letter-tip::before {
  content: "👆"; font-size: 17px; line-height: 1;
}

/* Местата нарочно изглеждат като обикновен текст — детето трябва да ги намери,
   а не да кликне подчертаното. Издават се едва след като бъдат открити. */
.spot {
  position: relative;
  font: inherit; color: inherit; background: none; border: 0;
  padding: 0 2px; margin: 0; cursor: pointer; border-radius: 5px;
  text-align: left; line-height: inherit;
}
/* Редът в писмото е висок ~26px — твърде малко за пръста на седемгодишен.
   Прозрачният слой разширява зоната на натискане, без да мести или оцветява
   каквото и да е: вертикалният padding на inline елемент не влияе на реда. */
.spot::before { content: ""; position: absolute; inset: -6px -3px; }
.spot:disabled { cursor: default; }
.spot.is-found {
  background: var(--yellow-soft); color: #5d4600; font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--mark);
}
.spot.is-found::after { content: " ✓"; font-size: .85em; color: #8a6a00; }
.game.is-safe-mail .spot.is-found {
  background: var(--ok-soft); color: #0f5c32; box-shadow: inset 0 -2px 0 var(--ok);
}
.game.is-safe-mail .spot.is-found::after { color: var(--ok); }
/* Проверено, но не знак за измама: сиво, без отметка — детето вижда, че е
   погледнало там, без това да се брои за улика. */
.spot.is-checked {
  background: #eef1f6; color: #55617a;
  box-shadow: inset 0 -2px 0 #c4cdda;
}
.spot.is-checked::after { content: " ?"; font-size: .85em; color: #8e99ad; }
.spot.is-hinted { animation: spot-pulse 1.3s ease 2; border-radius: 6px; }

@keyframes spot-pulse {
  0%, 100% { background: transparent; box-shadow: 0 0 0 0 rgba(243, 154, 183, 0); }
  50% { background: var(--pink-soft); box-shadow: 0 0 0 6px rgba(243, 154, 183, .35); }
}

.spot-cta {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--yellow), #ffbe1a); color: #5d4600;
  font-weight: 900; letter-spacing: .02em;
  box-shadow: 0 12px 26px rgba(255, 190, 26, .35);
}
.spot-cta.is-found { box-shadow: inset 0 -3px 0 var(--mark), 0 12px 26px rgba(255, 190, 26, .3); }
/* Докато текстът се изписва, бутонът още няма надпис — жълтото идва накрая,
   за да не стои празно петно насред писмото. Мястото се пази отсега. */
.game:not(.is-typed) .spot-cta { background: none; box-shadow: none; }
.spot-cta { transition: background .3s ease, box-shadow .3s ease; }

/* Буквите се палят една по една; остават обикновени inline елементи, за да
   може екранният четец пак да чете цели думи. */
.ch { opacity: 0; }
.ch.is-on { opacity: 1; transition: opacity .12s linear; }

/* ---------- обяснението ---------- */

.game-side { position: sticky; top: calc(var(--header-h) + 18px); }
.explain {
  background: var(--navy); color: #fff; border-radius: var(--radius-lg);
  padding: 22px 26px 28px; box-shadow: var(--shadow); min-height: 220px;
}

/* Битко е гласът на обясненията — затова стои над тях, а не вътре в живия
   регион: иначе екранният четец щеше да го чете при всяко ново обяснение. */
.explain-who {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 16px; margin-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}
/* Битко е нарисуван тук, а не изрязан от листа с героите: на 46px изрезката
   носи и опечения в нея текст, който се чете като шум. */
.bitko-mark { width: 46px; height: 46px; flex: 0 0 auto; }
.bm-head { fill: #fff; }
.bm-screen { fill: #071d44; }
.bm-eye { fill: var(--cyan); }
.bm-smile { fill: none; stroke: var(--cyan); stroke-width: 2.2; stroke-linecap: round; }
.bm-ant { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.bm-tip { fill: var(--yellow); }
.explain-who p { display: grid; margin: 0; line-height: 1.25; }
.explain-who strong { font-size: 16px; }
.explain-who span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.explain-empty { margin: 0; font-size: 15px; line-height: 1.7; color: #b8c5dc; }
.explain-kicker {
  margin: 0 0 10px; font-size: 11px; font-weight: 900;
  letter-spacing: .14em; text-transform: uppercase; color: var(--yellow);
}
.game.is-safe-mail .explain-kicker { color: #8ff0b8; }
.explain-card h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.2; letter-spacing: -.02em; }
.explain-card p { margin: 0; font-size: 15px; line-height: 1.7; color: #d7e0ee; }
.explain-villain {
  margin-top: 16px !important; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.14);
  font-size: 13px !important; color: var(--pink) !important; font-weight: 800;
}

/* ---------- присъда ---------- */

.verdict {
  margin-top: 30px; padding: 34px 36px;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.verdict-scene { margin-bottom: 18px; }
.verdict-scene img { width: 100%; max-width: 300px; height: auto; }
.verdict h2 { margin: 0 0 12px; font-size: clamp(26px, 3.4vw, 38px); line-height: 1.1; letter-spacing: -.03em; color: var(--navy); }
.verdict h2:focus-visible { outline: 3px solid var(--cyan); outline-offset: 6px; }
.verdict > p { margin: 0 0 16px; font-size: 16px; line-height: 1.7; color: var(--muted); max-width: 70ch; }
.verdict-praise { font-weight: 800; color: var(--navy) !important; }
.verdict-missed-head { margin: 18px 0 8px; font-size: 14px; font-weight: 900; color: var(--navy); }
#verdict-missed ul { margin: 0 0 20px; padding-left: 20px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.verdict-final {
  margin: 4px 0 22px; padding: 22px 24px;
  background: var(--cyan-soft); border-radius: var(--radius-md);
}
.verdict-final p { margin: 0 0 14px; font-size: 16px; line-height: 1.7; color: #0b4a5a; }
.final-rules { margin: 0 0 20px; padding: 0; list-style: none; display: grid; gap: 12px; }
.final-rules li {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px; background: rgba(255, 255, 255, .72); border-radius: var(--radius-md);
}
.final-icon { font-size: 22px; line-height: 1.2; flex: 0 0 auto; }
.final-copy { font-size: 15px; line-height: 1.6; color: #0b4a5a; }
.final-copy strong { display: block; color: var(--navy); letter-spacing: .06em; font-size: 13px; margin-bottom: 2px; }
.verdict-score { font-weight: 900; font-size: 18px !important; color: var(--navy) !important; }

/* ---------- бележка за родители ---------- */

.game-parents {
  display: block; margin-top: 56px; padding: 28px 30px;
  background: #f3f6fa; border-radius: var(--radius-md); border: 1px solid var(--line);
}
.game-parents h2 { margin: 0 0 10px; font-size: 18px; color: var(--navy); letter-spacing: -.01em; }
.game-parents p { margin: 0; font-size: 15px; line-height: 1.75; color: var(--muted); max-width: 80ch; }

/* ---------- адаптивност ---------- */

@media (max-width: 1040px) {
  .game-board { grid-template-columns: 1fr; gap: 26px; }
  .game-side { position: static; }
  .explain { min-height: 0; }
  .mail-scene { min-height: 0; padding-top: 10px; }
  .envelope { top: 90px; }
}

@media (max-width: 820px) {
  .game-intro { grid-template-columns: 1fr; gap: 28px; }
  .game-intro-art img { max-width: 240px; }
  /* На телефон картината стои между заглавието и имейла — щом мисията започне,
     тя само отдалечава писмото. Битко остава в панела с обясненията. */
  .game.is-started .game-intro-art { display: none; }
  .letter { padding: 26px 24px 28px; }
  .hud-actions { margin-left: 0; width: 100%; }
  .hud-actions .btn { flex: 1; }
  .verdict { padding: 28px 24px; }
}

@media (max-width: 600px) {
  .game-rules { flex-direction: column; align-items: flex-start; }
  .envelope { width: 220px; height: 146px; margin-left: -110px; top: 70px; }
  .env-flap { height: 86px; }
  .letter { padding: 22px 18px 24px; border-radius: var(--radius-md); }
  .letter-label { min-width: 40px; }
  .letter-subject { font-size: 16px; }
  .letter-body p { font-size: 15px; line-height: 1.95; }
  .letter-row { line-height: 1.75; }
  .explain { padding: 18px 20px 24px; }
  .bitko-mark { width: 40px; height: 40px; }
  .verdict-scene img { max-width: 220px; }
  .game-hud { padding: 14px 16px; }
  .mail-brief { padding: 16px 18px; }
  .mail-brief li { font-size: 14px; }
  .spot-cta { width: 100%; padding: 14px 18px; }
  .game-parents { padding: 22px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .game.is-flying .envelope { animation: none; }
  .envelope { display: none; }
  .letter { opacity: 1; transform: none; transition: none; }
  .spot.is-hinted { animation: none; outline: 3px dashed var(--pink); outline-offset: 3px; }
  .ch, .ch.is-on { opacity: 1; transition: none; }
}
