/* EncaixaCaixa — tema e layout. Mobile em retrato primeiro: HUD, mensagem,
   tabuleiro (área restante) e controles em faixas próprias do grid, sem
   nada sobreposto ao tabuleiro. Paisagem e desktop largo usam colunas. */
:root {
  --ec-ink: #f3f7f4;
  --ec-muted: #b7cbd0;
  --ec-panel: #11303a;
  --ec-panel-2: #18414d;
  --ec-line: #6fb3c055;
  --ec-accent: #ffcc33;
  --ec-good: #39c486;
  --ec-danger: #ff8a8e;
  --ec-btn: 56px;
}
body::before {
  background: radial-gradient(ellipse at 18% 12%, #427c7c55, transparent 48%),
    radial-gradient(ellipse at 86% 65%, #edb04b13, transparent 50%),
    linear-gradient(145deg, #173a46, #091d29 75%);
}

/* ---------- título ---------- */
#screen-title.screen .title-logo { width: min(100%, 380px); max-height: none; aspect-ratio: 40 / 21; }
@media (min-width: 760px) { #screen-title.screen .title-logo { width: 100%; max-width: 480px; } }
#gamepad-status { font-size: .7rem; margin: 0; }
.ec-progress { margin: 2px 0 0; min-height: 1.3em; color: var(--ec-muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.ec-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 390px); }
.ec-menu-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 0; min-height: 52px; padding: 6px 4px; box-sizing: border-box;
  border: 1px solid var(--ec-line); border-radius: 10px; background: linear-gradient(180deg, #19414d, #10303a);
  color: var(--ec-ink); font: 600 .76rem/1.15 system-ui, sans-serif; cursor: pointer;
}
.ec-menu-btn:hover { border-color: #a6e3ee99; }
.ec-menu-btn:focus-visible { outline: 2px solid var(--ec-accent); outline-offset: 2px; }
.ec-menu-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: #9fe6d0; }

/* Materiais do armazém: esmalte azul, metal claro e luz quente. A arte fica
   apenas nas capas; a partida continua leve, desenhada em Canvas 2D. */
#screen-title .game-title-art {
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 18px 60px #0006, 0 0 0 1px #bceee62b;
}
#screen-title #btn-start {
  background: linear-gradient(180deg, #ffe78a, #ffca3e 58%, #eea525);
  color: #243440; border: 1px solid #fff0b0;
  box-shadow: inset 0 2px 0 #fff7d0, 0 4px 0 #8e5d1f, 0 9px 24px #0004;
  text-shadow: 0 1px #fff6; letter-spacing: .03em;
}
.ec-menu-btn, .ec-action, .ec-icon-btn, .ec-zoom button, .ec-level {
  box-shadow: inset 0 1px 0 #d5fff71c, 0 3px 0 #071f2a, 0 5px 12px #0002;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.ec-menu-btn, .ec-action { background: linear-gradient(155deg, #285360, #14333f); }
.ec-menu-btn svg { color: #a8ebed; filter: drop-shadow(0 2px 2px #0004); }
.ec-menu-btn:active, .ec-action:active:not(:disabled) { box-shadow: inset 0 2px 5px #061c2666; }
@media (hover: hover) and (pointer: fine) {
  .ec-action:hover:not(:disabled), .ec-level:hover:not(.is-locked), .ec-icon-btn:hover {
    border-color: #b6eee2aa; background: #2b5965;
  }
}

/* ---------- partida: grid em retrato ---------- */
/* A .screen compartilhada limita 480 px; a partida usa a largura toda. */
#screen-play.screen { max-width: none; width: 100%; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); }
#screen-play.screen { animation: ec-play-in .2s ease; }
@keyframes ec-play-in { from { opacity: 0; } to { opacity: 1; } }
#game-frame.game-frame {
  display: grid; box-sizing: border-box; width: 100%; max-width: 680px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "hud" "msg" "board" "zoom" "controls";
  gap: 6px; padding: 6px 8px 8px;
  background: transparent;
  /* Só o tabuleiro e o D-pad bloqueiam gestos do navegador. */
  touch-action: manipulation;
}
/* contain:size — o tamanho do bitmap nunca infla as linhas do grid. */
#game { grid-area: board; width: 100%; height: 100%; min-height: 0; contain: size; touch-action: none; outline: none; border-radius: 16px; box-shadow: 0 10px 26px #0004, 0 0 0 1px #a9ded02b; }
#game:focus-visible { outline: 2px solid var(--ec-accent); outline-offset: 2px; }

.ec-hud {
  grid-area: hud; display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 10px; border: 1px solid var(--ec-line); border-radius: 12px; background: #0d262fcc;
  font-variant-numeric: tabular-nums;
}
.ec-hud-level { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.ec-hud-level strong { font-size: .95rem; color: var(--ec-accent); white-space: nowrap; }
.ec-hud-level small { color: var(--ec-muted); font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec-hud { background: linear-gradient(135deg, #244d59ee, #102c38ee); border-top-color: #99c8c366; box-shadow: inset 0 1px 0 #ffffff0d, 0 5px 16px #0002; }
.ec-hud-level strong { text-shadow: 0 2px 3px #0005; }
.ec-stat { display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.ec-stat span { color: var(--ec-muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; }
.ec-stat b { font-size: 1.02rem; color: var(--ec-ink); }
.ec-stat-short { display: none; }
@media (max-width: 400px) {
  .ec-stat { min-width: 40px; }
  .ec-stat-long { display: none; }
  .ec-stat-short { display: inline; }
}
.ec-icon-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--ec-line); border-radius: 10px; background: var(--ec-panel-2); color: var(--ec-ink); cursor: pointer; }
.ec-icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ec-icon-btn:focus-visible { outline: 2px solid var(--ec-accent); outline-offset: 2px; }

.ec-msg { grid-area: msg; display: flex; align-items: center; justify-content: center; min-height: 40px; }
.ec-toast {
  margin: 0; max-width: 100%; padding: 6px 12px; box-sizing: border-box; border-radius: 10px;
  border: 1px solid #ffffff2a; background: #102c36; color: var(--ec-ink); font-size: .8rem; line-height: 1.3; text-align: center;
}
.ec-toast[hidden] { display: none; }
.ec-toast.is-tutorial { border-color: #9fe6d080; background: #12403c; }
.ec-toast.is-hint { border-color: #ffcc3399; background: #3a3210; color: #fff3c4; }
.ec-toast.is-danger { border-color: #ff8a8e99; background: #45181d; color: #ffe1e2; }

.ec-zoom { grid-area: zoom; display: none; justify-content: center; gap: 8px; }
.ec-zoom.is-visible { display: flex; }
.ec-zoom button { display: grid; place-items: center; width: 48px; height: 44px; border: 1px solid var(--ec-line); border-radius: 10px; background: var(--ec-panel); color: var(--ec-ink); font: 700 1.3rem system-ui; cursor: pointer; }
.ec-zoom svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.ec-controls { grid-area: controls; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ec-actions { display: grid; grid-template-columns: repeat(2, minmax(64px, 1fr)); gap: 8px; flex: 1 1 auto; max-width: 220px; }
.ec-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; min-width: 44px; padding: 4px; box-sizing: border-box;
  border: 1px solid var(--ec-line); border-radius: 12px; background: linear-gradient(180deg, #1a4450, #11313b);
  color: var(--ec-ink); font: 600 .7rem system-ui, sans-serif; cursor: pointer; touch-action: manipulation;
}
.ec-action svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ec-action:disabled { opacity: .42; cursor: default; }
.ec-action:focus-visible { outline: 2px solid var(--ec-accent); outline-offset: 2px; }
.ec-action-hint { color: #fff1b8; }
.ec-action.is-suggested:not(:disabled) { border-color: var(--ec-danger); box-shadow: 0 0 0 2px #ff8a8e55; }

.ec-dpad {
  flex: none; display: grid; gap: 4px;
  grid-template-columns: repeat(3, var(--ec-btn)); grid-template-rows: repeat(3, var(--ec-btn));
  grid-template-areas: ". up ." "left . right" ". down .";
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  position: relative;
}
.ec-dpad::before {
  content: ''; grid-column: 2; grid-row: 2; place-self: center;
  width: 40%; height: 40%; border: 2px solid #efc96277; border-radius: 5px;
  background: #e9bb4d22; transform: rotate(45deg); pointer-events: none;
}
.ec-dir {
  display: grid; place-items: center; width: var(--ec-btn); height: var(--ec-btn); padding: 0;
  border: 1px solid #9fe6d066; border-radius: 14px; background: linear-gradient(180deg, #23606c, #164550);
  color: #ffffff; cursor: pointer; touch-action: none;
  box-shadow: inset 0 2px 0 #a8e8e344, 0 4px 0 #071e2a, 0 7px 14px #0005;
}
.ec-dir svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ec-dir.is-pressed, .ec-dir:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a2a32; background: #2d7482; }
.ec-dir:focus-visible { outline: 2px solid var(--ec-accent); outline-offset: 2px; }
.ec-dir-up { grid-area: up; } .ec-dir-down { grid-area: down; } .ec-dir-left { grid-area: left; } .ec-dir-right { grid-area: right; }

/* Telas estreitas (320 px): compacta, mantendo alvos ≥ 44 px. */
@media (max-width: 359px) {
  :root { --ec-btn: 50px; }
  #game-frame.game-frame { gap: 5px; padding: 4px 6px 6px; }
  .ec-actions { gap: 6px; }
  .ec-action span { font-size: .62rem; }
}
/* Telas baixas em retrato: D-pad e mensagem menores. */
@media (max-height: 640px) and (orientation: portrait) {
  :root { --ec-btn: 48px; }
  .ec-action { min-height: 46px; }
  .ec-action span { display: none; }
  .ec-msg { min-height: 34px; }
}

/* ---------- paisagem (celular deitado) ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --ec-btn: 46px; }
  /* HUD, mensagem e ações na coluna esquerda: o tabuleiro fica com a altura toda. */
  #game-frame.game-frame {
    max-width: none;
    grid-template-columns: 136px minmax(0, 1fr) auto;
    /* A última linha absorve a sobra: mensagem longa rola, nada transborda. */
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "hud board dpad" "actions board dpad" "msg board zoom";
    gap: 4px 8px;
    padding: 4px max(8px, env(safe-area-inset-right, 0px)) 4px max(8px, env(safe-area-inset-left, 0px));
  }
  .ec-hud { flex-wrap: wrap; gap: 2px 4px; padding: 4px; justify-content: space-between; }
  .ec-hud-level { flex-basis: calc(100% - 50px); }
  .ec-hud-level strong { font-size: .82rem; }
  .ec-stat { min-width: 0; }
  .ec-stat-long { display: none; }
  .ec-stat-short { display: inline; }
  .ec-stat b { font-size: .85rem; }
  .ec-msg { min-height: 0; align-items: flex-start; overflow-y: auto; }
  .ec-controls { display: contents; }
  .ec-actions { grid-area: actions; align-self: start; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; gap: 4px; }
  .ec-action { min-height: 46px; }
  .ec-action span { display: none; }
  .ec-dpad { grid-area: dpad; align-self: center; }
  .ec-zoom { grid-area: zoom; flex-wrap: wrap; }
  .ec-zoom button { width: 44px; }
  .ec-msg { min-height: 30px; }
  .ec-toast { padding: 4px 10px; font-size: .74rem; }
  .ec-hud { padding: 3px 6px 3px 10px; }
}

/* ---------- desktop largo: painel lateral ---------- */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) and (min-height: 561px) {
  :root { --ec-btn: 60px; }
  #game-frame.game-frame {
    max-width: 1280px;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    grid-template-areas: "board hud" "board msg" "board controls" "board zoom" "board .";
    gap: 12px; padding: 16px 20px 12px;
  }
  #game { grid-row: 1 / -1; }
  .ec-hud { flex-wrap: wrap; }
  .ec-msg { min-height: 64px; }
  .ec-controls { flex-direction: column; gap: 16px; }
  .ec-actions { max-width: none; width: 100%; }
}

/* ---------- diálogos ---------- */
.ec-dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-sizing: border-box;
  padding: 16px; border: 1px solid #9fe6d055; border-radius: 16px; background: #0f2a33; color: var(--ec-ink);
  box-shadow: 0 25px 80px #000a; overflow: auto; text-align: left;
}
.ec-dialog::backdrop { background: #050d14c4; }
.ec-dialog { background: linear-gradient(145deg, #204752, #0d2733 70%); border-top-color: #b5e6d499; }
.ec-dialog h2 { margin: 0; font-size: 1.15rem; color: var(--ec-accent); }
.ec-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; position: sticky; top: -16px; padding-top: 2px; background: #0f2a33; z-index: 1; }
.ec-dialog-close { width: 44px; height: 44px; border: 1px solid var(--ec-line); border-radius: 10px; background: var(--ec-panel-2); color: var(--ec-ink); font-size: 1.5rem; cursor: pointer; }
.ec-dialog-note { margin: 8px 0; color: var(--ec-muted); font-size: .84rem; line-height: 1.5; }
.ec-muted { font-size: .76rem; opacity: .85; }
.ec-dialog .btn { width: 100%; margin-top: 10px; }
.ec-dialog :focus-visible { outline: 2px solid var(--ec-accent); outline-offset: 2px; }

.ec-chapter { margin: 10px 0 14px; }
.ec-chapter h3 { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 6px; font-size: .86rem; color: #cfeee6; }
.ec-chapter h3 small { color: var(--ec-accent); font-weight: 600; white-space: nowrap; }
.ec-level-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ec-level {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; min-width: 44px; border: 1px solid var(--ec-line); border-radius: 10px;
  background: #16404b; color: var(--ec-ink); cursor: pointer; font: 700 1rem system-ui;
}
.ec-level.is-done { background: #1d4f43; border-color: #39c48677; }
.ec-level.is-locked { background: #0c1f26; color: #6f8a92; cursor: not-allowed; }
.ec-level-stars { font-size: .66rem; letter-spacing: 1px; color: var(--ec-accent); }
.ec-level-stars i { font-style: normal; color: #ffffff33; }
.ec-locked-note { min-height: 1.4em; color: #ffd9a8; }

.ec-daily-date { margin: 4px 0; font-weight: 700; color: #cfeee6; text-transform: capitalize; }
.ec-daily-best { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 1px solid var(--ec-line); border-radius: 12px; background: #0b2229; }
.ec-daily-best strong { color: var(--ec-accent); font-size: 1.3rem; letter-spacing: 2px; }
.ec-daily-best small { color: var(--ec-muted); }

.ec-setting { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 2px; border-bottom: 1px solid #ffffff12; font-size: .9rem; cursor: pointer; }
.ec-setting input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ec-good); flex: none; }
.ec-setting-range { flex-direction: column; align-items: stretch; gap: 6px; }
.ec-setting-range input { width: 100%; min-height: 32px; accent-color: var(--ec-good); }
.ec-confirm { width: min(360px, calc(100vw - 30px)); text-align: center; }
.ec-confirm-actions { display: flex; gap: 8px; margin-top: 12px; }
.ec-confirm-actions > * { flex: 1; margin: 0 !important; }

/* ---------- resultado (véu translúcido compartilhado preservado) ---------- */
.ec-result-title { margin: 0; font-size: 1.9rem; color: var(--ec-accent); }
.ec-result-level { margin: 2px 0 0; color: var(--ec-muted); font-size: .9rem; }
.ec-stars { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.ec-star { font-size: 2.6rem; line-height: 1; color: #ffffff2b; text-shadow: 0 2px 0 #0006; }
.ec-star.is-on { color: var(--ec-accent); animation: ec-star-in .45s ease both; animation-delay: calc(var(--i) * 120ms); }
@keyframes ec-star-in { from { transform: scale(.3) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.ec-result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 360px); }
.ec-result-stats div { display: flex; flex-direction: column; padding: 8px 4px; border: 1px solid #ffffff22; border-radius: 12px; background: #0b222acc; }
.ec-result-stats b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ec-result-stats span { color: var(--ec-muted); font-size: .7rem; }
.ec-result-par { max-width: 360px; margin: 6px auto 0; color: #d9ecef; font-size: .8rem; line-height: 1.45; }
.ec-result-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: min(100%, 360px); }
.ec-result-more [hidden] { display: none; }
.ec-result-more:has(> [hidden]) { grid-template-columns: 1fr; }

@media (prefers-reduced-motion: reduce) {
  .ec-menu-btn, .ec-action, .ec-icon-btn, .ec-zoom button, .ec-level { transition: none; }
  .ec-star.is-on { animation: none; }
  .ec-dir.is-pressed, .ec-dir:active { transform: none; }
}
/* Toque: sem anel de foco visual (regra da série), foco funcional preservado. */
.ec-collection-link { border: 0; background: none; color: #ffe28c; font: 700 .82rem system-ui; min-height: 44px; cursor: pointer; }
.ec-msg { position: relative; min-height: 64px; }
.ec-msg:has(.ec-celebration:not([hidden])) > .ec-toast { visibility: hidden; }
.ec-celebration { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; pointer-events: none; border: 1px solid #69ffe578; border-radius: 16px; background: linear-gradient(115deg,#153f50f5,#17483ff5); box-shadow: inset 0 0 18px #44ffd622,0 0 14px #2ce5d322; overflow: hidden; }
.ec-celebration[hidden] { display: none; }
.ec-celebration canvas { width: 64px; height: 64px; flex: none; }
.ec-celebration div { display: flex; flex-direction: column; gap: 3px; min-width: 0; text-align: left; }
.ec-celebration small { color: #b0ffea; font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; }
.ec-celebration strong { color: #fff5c1; font-size: .96rem; }
.ec-celebration i { color: #ffe379; font-size: 2rem; font-style: normal; animation: ec-reward-spark 1s ease-in-out 3; }
.ec-celebration.is-achievement { border-color: #ffd76b; background: linear-gradient(115deg,#21466b,#544223); box-shadow: inset 0 0 20px #ffdf4922,0 0 16px #ffcc3344; }
@keyframes ec-reward-spark { 50% { transform: rotate(40deg) scale(1.3); filter: drop-shadow(0 0 7px #ffea8e); } }
.ec-celebration.is-still i { animation: none; }
#ec-result-reward { position: relative; height: 70px; width: min(100%,360px); }
#ec-result-reward:not(:has(.ec-celebration:not([hidden]))) { display: none; }
#screen-result { gap: 8px; }
#screen-result.screen { padding-top: 84px; }
#screen-result .series-badge, #screen-result #btn-share, #screen-result #btn-copy { display: none !important; }
.ec-result-title { font-size: 1.5rem; }
.ec-result-details { max-width: 360px; font-size: .75rem; color: var(--ec-muted); }
.ec-result-details summary { min-height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ec-result-details summary::after { content: '⌄'; padding-left: 6px; }
.ec-next-goal { display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; width: min(100%,360px); padding: 10px 12px; box-sizing: border-box; background: #163e4acc; border: 1px solid #91d7d833; border-radius: 12px; text-align: left; }
.ec-next-goal span { grid-column: 1 / -1; font-size: .75rem; color: #e4f5e9; }
.ec-next-goal progress, .ec-badge progress { width: 100%; height: 8px; align-self: center; accent-color: #ffcc33; }
.ec-next-goal progress, .ec-badge progress { appearance: none; border: 0; border-radius: 6px; overflow: hidden; background: #ffffff1a; }
.ec-next-goal progress::-webkit-progress-bar, .ec-badge progress::-webkit-progress-bar { background: #ffffff1a; }
.ec-next-goal progress::-webkit-progress-value, .ec-badge progress::-webkit-progress-value { background: linear-gradient(90deg,#53dfc2,#ffe16d); }
.ec-next-goal progress::-moz-progress-bar, .ec-badge progress::-moz-progress-bar { background: #ffe16d; }
.ec-next-goal b { font-size: .7rem; color: #ffe58f; }
.ec-result-more { display: flex; justify-content: center; width: auto; gap: 10px; }
.ec-result-more .ec-menu-btn { width: 44px; min-height: 44px; font-size: 1.6rem; }
.ec-result-card { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#screen-result > .actions { display: none; }
#screen-result .ec-result-more { width: min(100%,360px); order: initial; margin-top: 6px; }
#screen-result .ec-result-more #btn-again { flex: 1; width: auto; min-width: 0; min-height: 48px; padding: 10px; margin: 0; font-size: .85rem; letter-spacing: .02em; }
.ec-result-details .record-note { margin: 6px auto; font-size: .75rem; }
#screen-result .actions { order: 1; margin-top: 0; }
#screen-result .ec-result-more { order: 2; }
#screen-result .actions #btn-again { min-height: 48px; }
.ec-achievements { width: min(520px,calc(100vw - 28px)); }
.ec-achievements > div:last-child { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.ec-badge { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; border: 1px solid #6fb3c044; border-radius: 14px; background: #12333e; }
.ec-badge i { font-style: normal; font-size: 1.8rem; color: #83b3bc; }
.ec-badge strong { font-size: .8rem; }
.ec-badge small { font-size: .7rem; color: #c7dedc; }
.ec-badge.is-earned { background: linear-gradient(135deg,#3d513c,#3c3928); border-color: #ffce5477; }
.ec-badge.is-earned i { color: #ffe480; text-shadow: 0 0 12px #ffcd3e88; }
@media (max-height: 600px) {
  .ec-msg { min-height: 48px; }
  .ec-celebration canvas { width: 46px; height: 46px; }
  .ec-celebration strong { font-size: .8rem; }
  #screen-result { gap: 4px; }
  #ec-result-reward { height: 48px; }
  .ec-star { font-size: 2rem; }
  .ec-next-goal { padding: 6px 10px; }
  .ec-result-stats div { padding: 4px; }
}
@media (max-height: 640px) and (orientation: portrait) {
  .ec-msg { min-height: 34px; }
  .ec-msg .ec-celebration canvas { width: 34px; height: 34px; }
  .ec-msg .ec-celebration small { font-size: .52rem; }
  .ec-msg .ec-celebration strong { font-size: .75rem; }
  .ec-msg .ec-celebration div { gap: 0; }
}
@media (orientation: landscape) and (max-height: 560px) {
  #screen-result.screen { max-width: 850px; padding-top: 60px; justify-content: center; }
  .ec-result-card { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: auto auto auto auto auto; gap: 4px 18px; align-items: center; justify-items: center; }
  #ec-result-title { grid-column: 1; grid-row: 1; }
  #ec-result-level { grid-column: 1; grid-row: 2; }
  #ec-result-stars { grid-column: 1; grid-row: 3; margin: 0; }
  #ec-result-reward { grid-column: 1; grid-row: 4 / 6; height: 64px; }
  #ec-result-stats { grid-column: 2; grid-row: 1; }
  #ec-next-goal { grid-column: 2; grid-row: 2 / 4; }
  #ec-result-details { grid-column: 2; grid-row: 4; max-height: 70px; overflow: auto; }
  #screen-result .ec-result-more { grid-column: 2; grid-row: 5; margin: 0; }
}
@media (min-width: 680px) and (max-height: 600px) {
  .ec-msg .ec-celebration { flex-wrap: wrap; align-content: center; gap: 2px; }
  .ec-msg .ec-celebration div { text-align: center; padding: 2px; }
  .ec-msg .ec-celebration i { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ec-celebration i, #screen-play.screen { animation: none; } }
.ec-reduced #screen-play.screen { animation: none; }
.ec-reduced .ec-star.is-on, .ec-reduced .ec-celebration i { animation: none; }
.ec-msg:has(.ec-toast:is(.is-danger,.is-hint):not([hidden])) .ec-celebration { visibility: hidden; }
.ec-msg:has(.ec-toast:is(.is-danger,.is-hint):not([hidden])) > .ec-toast { visibility: visible; }
@media (hover: none) and (pointer: coarse) {
  .ec-collection-link:focus { outline: none; }
  .ec-menu-btn:focus, .ec-action:focus, .ec-dir:focus, .ec-icon-btn:focus, .ec-level:focus, .ec-zoom button:focus, .ec-dialog-close:focus, #game:focus { outline: none; }
}
