/* Corre, Ferris!: visual "Caderno de adesivos" do laurinha.net.
   Fundo próprio do jogo (cada jogo tem o seu, veja o CLAUDE.md): céu azul com nuvenzinhas. Na jogada, o canvas
   desenha o mesmo céu, com sol e nuvens, sobre a praia (mar, areia, conchinhas). */
:root {
  --fundo: #8fd3ff;
  --nuvem: #c9ecff;
  --fundo-img:
    radial-gradient(circle at 30px 36px, var(--nuvem) 11px, transparent 11.5px),
    radial-gradient(circle at 46px 29px, var(--nuvem) 14px, transparent 14.5px),
    radial-gradient(circle at 61px 37px, var(--nuvem) 10px, transparent 10.5px),
    radial-gradient(circle at 112px 104px, var(--nuvem) 8px, transparent 8.5px),
    radial-gradient(circle at 123px 98px, var(--nuvem) 10px, transparent 10.5px),
    radial-gradient(circle at 134px 105px, var(--nuvem) 7px, transparent 7.5px);
  --fundo-tam: 168px 150px;
  --ink: #3a2a17;
  --paper: #fffdf5;
  --y: #ffd43b;
  --pink: #ff6f91;
  --sky: #4cc3ff;
  --leaf: #4ccf7a;
  --orange: #ff9f1c;
  --display: "Gluten", "Comic Sans MS", cursive;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background-color: var(--fundo);
  background-image: var(--fundo-img);
  background-size: var(--fundo-tam);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.35;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- o jogo ---------- */
.palco { position: fixed; inset: 0; touch-action: none; overflow: hidden; }
.palco canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; gap: 8px; align-items: stretch;
  padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud .esp { flex: 1; pointer-events: none; }
.chip {
  display: grid; align-content: center; justify-items: center;
  min-width: 64px; padding: 2px 12px 4px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
}
.chip .lbl { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; opacity: .7; }
.chip b { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.chip.vidas { display: flex; align-items: center; gap: 2px; padding: 4px 8px; }
.vidas svg { width: 32px; height: 32px; display: block; overflow: visible; }
.vidas path { fill: var(--pink); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; transition: fill .2s ease; }
.vidas .vazio path { fill: #e6ddcc; }
.vidas .perdeu { animation: perdeu .55s ease; }
.vidas .ganhou { animation: ganhou .55s ease; }
@keyframes perdeu {
  0% { transform: scale(1); }
  30% { transform: scale(1.35) rotate(-12deg); }
  60% { transform: scale(.8) rotate(8deg); }
  100% { transform: scale(1); }
}
@keyframes ganhou {
  0% { transform: scale(.4); }
  60% { transform: scale(1.3) rotate(6deg); }
  100% { transform: scale(1); }
}

.icon-btn {
  flex: none; width: 56px; padding: 0;
  display: grid; place-items: center;
  background: var(--y); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--ink);
  touch-action: none;
}
.icon-btn svg { width: 28px; height: 28px; fill: var(--ink); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
/* Som (mudo): no placar e no cabeçalho */
.icon-btn.mudo { background: var(--paper); }
.mudo .off { display: none; }
.mudo[aria-pressed="true"] { background: #ffd6de; }
.mudo[aria-pressed="true"] .on { display: none; }
.mudo[aria-pressed="true"] .off { display: inline; }
@media (max-width: 379px) {
  .hud { gap: 6px; }
  .chip { min-width: 54px; padding: 2px 8px 4px; }
  .vidas svg { width: 27px; height: 27px; }
  .icon-btn { width: 48px; }
}
@media (max-height: 460px) {
  .hud { padding-top: calc(6px + var(--safe-t)); }
  .chip { padding: 1px 10px 2px; }
  .chip .lbl { font-size: 10px; line-height: 1.1; }
  .chip b { font-size: 20px; line-height: 1; }
  .vidas svg { width: 24px; height: 24px; }
  .icon-btn { width: 46px; }
  .icon-btn svg { width: 24px; height: 24px; }
}

/* Mensagem rápida no meio da tela ("Muito bem!", "Coração extra!") */
.toast {
  position: absolute; left: 0; right: 0; top: 30%; z-index: 1;
  text-align: center; pointer-events: none; padding: 0 12px;
  font-family: var(--display); font-weight: 800; font-size: clamp(38px, 11vw, 64px); line-height: 1;
  color: var(--paper); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  opacity: 0;
}
.toast.show { animation: pop 1.2s ease forwards; }
@keyframes pop {
  0%   { opacity: 0; transform: scale(.4) rotate(-8deg); }
  18%  { opacity: 1; transform: scale(1.15) rotate(3deg); }
  30%  { transform: scale(1) rotate(-2deg); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px) rotate(-2deg); }
}

/* ---------- botão Início (adesivo amarelo do site) ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) 18px calc(16px + var(--safe-l));
  background: linear-gradient(rgba(58, 42, 23, .35), rgba(58, 42, 23, 0));
  pointer-events: none;
}
.topbar .home-link, .topbar .mudo { pointer-events: auto; }
.topbar .mudo { width: 46px; height: 46px; }
/* fora da jogada o Som fica no cabeçalho; o placar (por baixo da tela) some para não aparecerem dois botões
   de som nem os pontos atrás do Início */
body:has(#topbar:not(.hidden)) .hud { visibility: hidden; }
.home-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 16px 6px 10px;
  font-family: var(--display); font-weight: 800; font-size: 20px;
  color: #3a2a17; text-decoration: none;
  background: #ffd43b; border: 3px solid #3a2a17; border-radius: 999px;
  box-shadow: 3px 3px 0 #3a2a17;
  transition: transform .12s ease, box-shadow .12s ease;
}
.home-link svg { width: 22px; height: 22px; }
.home-link:hover, .home-link:focus-visible { transform: translate(-1px, -2px); box-shadow: 4px 5px 0 #3a2a17; outline: none; }
.home-link:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #3a2a17; }

/* ---------- telas ----------
   A escolha da personagem (body.menu) é uma página própria, direto no fundo do jogo, sem a partida por trás.
   A pausa e o fim de jogo aparecem por cima do cenário. */
body.menu .palco { visibility: hidden; }
body.menu .screen { background: none; }
body.menu .topbar {
  /* o mesmo fundo da página (alinhado, porque a faixa é fixa no canto), sumindo embaixo para o menu passar por trás */
  background-color: var(--fundo);
  background-image: var(--fundo-img);
  background-size: var(--fundo-tam);
  background-position: 0 0;
  -webkit-mask-image: linear-gradient(#000 70%, transparent);
  mask-image: linear-gradient(#000 70%, transparent);
}
.screen {
  position: fixed; inset: 0; z-index: 5;
  display: grid; justify-items: center; align-items: safe center;
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(76px + var(--safe-t)) 14px calc(20px + var(--safe-b));
  background: rgba(58, 42, 23, .38);
  touch-action: pan-y;
}
.screen-card {
  display: grid; gap: 12px; justify-items: center; text-align: center;
  width: min(420px, 100%);
  padding: 22px 18px;
  color: var(--ink); background: var(--paper);
  border: 4px solid var(--ink); border-radius: 24px; box-shadow: 7px 7px 0 var(--ink);
  transform: rotate(-1deg);
  animation: card-in .25s ease;
}
#scrStart .screen-card { width: min(640px, 100%); gap: 10px; padding-top: 16px; }
@keyframes card-in { from { transform: rotate(-4deg) scale(.92); opacity: 0; } }
.screen-card h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1.05; }
.screen-card p { margin: 0; }
.logo {
  font-size: clamp(46px, 13vw, 64px) !important; line-height: .92 !important;
  color: var(--paper); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-3deg);
}
.logo span { color: #ff8a3d; } /* "Ferris!" na cor do Ferris */
.big { font-size: 21px; font-weight: 900; }
.muted { font-size: 16px; opacity: .75; }
.hello b { font-family: var(--display); font-weight: 800; font-size: 26px; }
.hello span { display: inline-block; font-size: 30px; line-height: 1; vertical-align: -3px; transform: rotate(8deg); }
kbd {
  font-family: inherit; font-size: .9em; padding: 0 6px; border: 2px solid var(--ink); border-radius: 7px; background: var(--y);
}
.kbd-hint { font-size: 14px; opacity: .8; }
@media (hover: none) { .kbd-hint { display: none; } }

.btn {
  display: inline-block; min-width: 200px;
  font-family: var(--display); font-weight: 800; font-size: 24px;
  color: var(--paper); background: var(--pink);
  border: 3px solid var(--ink); border-radius: 14px;
  padding: 6px 22px 8px; box-shadow: 4px 4px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn.play { font-size: clamp(26px, 7.5vw, 32px); min-width: 240px; padding: 8px 24px 10px; }
.btn.small { min-width: 0; font-size: 18px; padding: 4px 14px 6px; }
.btn.alt { background: var(--sky); color: var(--ink); }
.btn:hover, .btn:focus-visible { transform: translate(-1px, -2px); box-shadow: 5px 6px 0 var(--ink); outline: none; }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* Quem vai brincar? 2 × 2 no celular, as quatro lado a lado no tablet e no computador */
.turma { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; padding: 4px 2px 6px; }
@media (min-width: 620px) { .turma { grid-template-columns: repeat(4, 1fr); } }
.amigo {
  display: grid; gap: 4px; justify-items: center;
  padding: 6px 6px 8px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--display); font-weight: 800; font-size: 19px; line-height: 1.1;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.amigo canvas {
  width: 100%; aspect-ratio: 1 / .92; display: block;
  background: var(--tom, #dff3ff); border: 2px solid var(--ink); border-radius: 12px;
}
.amigo[aria-checked="true"] {
  background: var(--y);
  transform: rotate(-2deg) scale(1.05);
  box-shadow: 5px 5px 0 var(--ink);
}
.amigo:focus-visible { outline: 3px dashed var(--pink); outline-offset: 3px; }
/* celular deitado (tela baixa): tudo mais compacto, para o "Jogar!" ficar à vista */
@media (max-height: 500px) {
  .screen { padding-top: calc(58px + var(--safe-t)); padding-bottom: calc(10px + var(--safe-b)); }
  #scrStart .screen-card { gap: 5px; padding: 8px 14px 12px; }
  .logo { font-size: 32px !important; }
  .logo br { display: none; }
  #helloBest { display: none; }
  .big { font-size: 18px; }
  .hello b { font-size: 22px; }
  .amigo { font-size: 16px; padding: 4px 4px 6px; }
  .amigo canvas { aspect-ratio: 1 / .66; }
  .btn.play { padding: 4px 24px 6px; }
  .kbd-hint { display: none; }
}

#overTitle { font-size: clamp(30px, 8.5vw, 38px); }
.over-siri { width: 190px; height: 140px; display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .toast.show { opacity: 1; }
}
