/*
 * Apaga el incendio - overrides of shared/shell.css only. Flat and calm
 * like the site's everyday games; the forest itself is forest.css.
 */

/* ---- join ---- */
/* Taller than a phone: start at the top, below the fixed top bar, instead
   of centring (which would push the title out of reach). */
#screen-join, #screen-waiting { justify-content: flex-start; padding-top: calc(var(--am-header-clear) + 12px); }
#screen-join > .title, #screen-waiting > .title { margin-top: auto; }
#screen-join > form, #screen-waiting > :last-child { margin-bottom: auto; }
.ff-intro { max-width: 460px; margin: 0; color: var(--purple-dark); font-size: 17px; }
.ff-join { width: min(460px, 100%); }
.ff-label { display: block; font-weight: bold; color: var(--purple-dark); margin: 10px 0 6px; }
.ff-choice-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ff-choice {
  font: inherit; font-size: 16px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--purple); background: #fff; color: var(--purple-dark);
}
.ff-choice[aria-pressed="true"] { background: var(--purple); color: #fff; }
/* A code from the class's link: shown, not editable. */
#f-code[readonly] { background: rgba(255,255,255,.55); color: var(--purple-dark); font-weight: bold; letter-spacing: 3px; cursor: default; }
.ff-desc { margin: 6px 0 0; font-size: 15px; color: var(--purple-dark); opacity: .85; }

.ff-picker[hidden] { display: none; }
#screen-waiting .ff-picker { width: min(460px, 100%); }
.ff-picker-body { display: flex; gap: 10px; align-items: center; }
.ff-preview { position: relative; flex: 0 0 110px; height: 100px; background: rgba(255,255,255,.6); border-radius: 16px; }
.ff-preview .ff { width: 100%; height: 100%; }
.ff-dice { position: absolute; right: -6px; bottom: -6px; font-size: 18px; border: 0; border-radius: 50%; width: 34px; height: 34px; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.15); cursor: pointer; }
.ff-rows { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ff-row { display: flex; gap: 5px; flex-wrap: wrap; }
.ff-swatch { width: 60px; height: 52px; padding: 3px; border-radius: 10px; border: 2px solid transparent; background: rgba(255,255,255,.7); cursor: pointer; }
.ff-swatch[aria-pressed="true"] { border-color: var(--purple); background: #fff; }
.ff-swatch .ff-part { width: 100%; height: 100%; display: block; }

/* ---- waiting ---- */
.ff-code { font-size: 40px; letter-spacing: 6px; color: var(--purple-dark); font-weight: bold; }
.ff-roster { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; }
.ff-roster li { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.6); border-radius: 999px; padding: 2px 12px 2px 4px; color: var(--purple-dark); }
.ff-roster li .ff { width: 40px; height: 36px; }
.ff-roster .race-roster-count { background: none; font-weight: bold; width: 100%; justify-content: center; }
.ff-how { text-align: left; max-width: 420px; color: var(--purple-dark); font-size: 16px; margin: 0; }

/* ---- HUD ---- */
.hud .score::before { content: "🔥 "; }
.hud { gap: 10px; flex-wrap: wrap; }
/* What's left of the forest: a bar with a red line where it is lost. */
.ff-health { display: inline-flex; align-items: center; gap: 5px; flex: 1 1 120px; max-width: 260px; font-size: 15px; }
.ff-health[hidden] { display: none; }
.ff-health-tree { font-size: 18px; line-height: 1; }
.ff-health-bar { position: relative; flex: 1; height: 12px; border-radius: 999px; background: #4a3e3b; box-shadow: 0 0 0 2px #fff; overflow: hidden; }
.ff-health-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: #5fbf62; border-radius: inherit; transition: width .6s ease-out; }
.ff-health-line { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: #e2412f; }
.ff-health.is-low .ff-health-fill { background: #f0a43a; }
.ff-health-pct { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; font-family: var(--am-readable-font); font-size: 14px; }

/* ---- the forest: drawn and sized by forest.js, styled in forest.css ---- */
/* The forest takes every pixel the stage has left; forest.js fits the
   patches into it. */
.ff-forest { width: 100%; flex: 1; min-height: 0; }

/* ---- round banner, countdown ---- */
.ff-banner {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  background: #fff; border-radius: 20px; padding: 14px 26px; box-shadow: 0 6px 0 rgba(0,0,0,.12);
  display: flex; flex-direction: column; gap: 4px; z-index: 5; min-width: 220px;
}
.ff-banner-title { font-size: 26px; color: var(--purple-dark); font-weight: bold; }
.ff-banner-sub { font-size: 16px; color: var(--purple-dark); }
.ff-countdown {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.55); z-index: 50; font-size: 120px; color: var(--purple-dark); text-shadow: 4px 4px 0 #fff;
}

/* The site's feedback button (fixed bottom-left) would sit on the keypad's
   0 on a small phone: hidden while playing, as in carrera and minisudoku. */
body:has(#screen-game:not([hidden])) .am-fb-fab { display: none; }

/* ---- the answer pad ---- */
.pad-area { flex-direction: column; }
.ff-pad { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ff-pad.is-waiting { opacity: .45; pointer-events: none; }
.ff-aim-hint { margin: 0; font-size: 14px; color: var(--purple-dark); opacity: .8; max-width: 320px; }
.ff-qrow { display: flex; align-items: center; gap: 12px; }
.ff-pad .equation { margin: 0; font-size: clamp(32px, 8vw, 54px); }
.ff-pad .answer-display { min-height: 46px; font-size: 30px; }
.ff-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ff-choices .big-button { padding: 12px 0; min-width: 120px; }
.ff-locked { text-align: center; min-height: 160px; display: flex; flex-direction: column; justify-content: center; }
.ff-locked-title { font-size: 30px; color: var(--pink); margin: 0; }

/* ---- the refill puzzle: the pipes ---- */
.ff-puzzle { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.ff-puzzle-head { display: flex; align-items: center; gap: 10px; }
.ff-puzzle-title { margin: 0; font-size: 24px; font-weight: bold; color: var(--purple-dark); }
.ff-puzzle-help {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--green, #3cb54a); color: #fff; font: inherit; font-size: 19px; font-weight: bold;
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
}
.ff-puzzle .ff-desc { margin: 0; max-width: 320px; min-height: 2.6em; }
.ff-puzzle-board { position: relative; }

.ff-pipes {
  --cell: clamp(62px, 17vw, 88px);
  display: grid; grid-template-columns: 22px repeat(var(--cols), var(--cell)) 26px; gap: 3px; align-items: center;
}
.ff-pipe { position: relative; width: var(--cell); height: var(--cell); padding: 0; border: 0; border-radius: 12px; background: #fbf2e2; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(111, 74, 134, .12); }
.ff-pipe-turn { display: block; width: 100%; height: 100%; transition: transform .28s cubic-bezier(.3, 1.4, .5, 1); }
.ff-pipe svg { display: block; width: 100%; height: 100%; }
.ff-pipe-water { stroke: #d9cbb6; transition: stroke .25s ease-out 0s; }
.ff-pipe.is-wet .ff-pipe-water { stroke: var(--water, #45a8e8); transition-delay: var(--wet-delay, 0s); }
.ff-pipe-flow { stroke: #fff; opacity: 0; stroke-dasharray: 5 9; }
.ff-pipe.is-wet .ff-pipe-flow { opacity: .75; transition: opacity .2s var(--wet-delay, 0s); animation: ffPipeFlow .5s linear infinite; }
@keyframes ffPipeFlow { to { stroke-dashoffset: -14; } }
.ff-pipe-end { height: 28px; border-radius: 8px; }
.ff-river.is-on { background: #45a8e8; box-shadow: inset 0 0 0 3px #2f86c8; animation: ffRiver 1.2s ease-in-out infinite alternate; }
@keyframes ffRiver { to { background: #6cc0f2; } }
.ff-tank.is-on { position: relative; height: 44px; background: #fff; border: 3px solid var(--purple); border-radius: 6px 6px 10px 10px; overflow: hidden; }
.ff-tank i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--water, #45a8e8); transition: height .6s ease-out var(--wet-delay, 0s); }
.ff-tank.is-full i { height: 100%; }
/* "Turn this one": after a while without a tap. */
.ff-pipe.is-nudge { animation: ffNudge .8s ease-in-out infinite alternate; }
@keyframes ffNudge { from { box-shadow: 0 0 0 0 rgba(255, 210, 92, .9); } to { box-shadow: 0 0 0 7px rgba(255, 210, 92, .25); } }
/* The demo's hand. */
.ff-hand {
  position: absolute; left: 0; top: 0; width: 40px; height: 48px; margin: -6px 0 0 -14px;
  pointer-events: none; opacity: 0; transform: translateY(26px) scale(.8);
  transition: opacity .35s, transform .35s; z-index: 3;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.2));
}
.ff-hand svg { display: block; width: 100%; height: 100%; }
.ff-hand.is-on { opacity: 1; transform: none; }
.ff-hand.is-tap { animation: ffTap .5s ease-in-out; }
@keyframes ffTap { 40% { transform: translateY(5px) scale(.88); } }
.ff-puzzle-board.is-demo .ff-pipe { cursor: default; }

/* ---- the end ---- */
.ff-end-art { width: 140px; height: 120px; }
.ff-end-art .ff { width: 100%; height: 100%; }
#results-mine { font-size: 17px; }
#results-forest { font-size: 22px; font-weight: bold; }
/* The forest that's left: one little tree per patch, burnt ones black. */
.ff-end-forest { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 420px; }
.ff-end-forest:empty { display: none; }
.ff-end-forest i { width: 12px; height: 15px; background: #4a9b55; clip-path: polygon(50% 0, 100% 75%, 62% 75%, 62% 100%, 38% 100%, 38% 75%, 0 75%); }
.ff-end-forest i.is-ash { background: #4a3e3b; }

/* ---- landscape: the forest fills the left, the pad on the right ---- */
@media (min-width: 640px) and (orientation: landscape) {
  #screen-game.game-screen { max-width: none; --pad-width: 360px; }
}
@media (min-width: 1300px) and (orientation: landscape) {
  #screen-game.game-screen { --pad-width: 400px; }
}

/* Phones held upright: the forest needs every pixel of height it can
   get, so the keypad is always the compact 5-column one (1-5 / 6-9 ⌫
   / 0 OK), three rows instead of four. */
@media (orientation: portrait) and (max-width: 600px) {
  .ff-pad .keypad { grid-template-columns: repeat(5, 1fr); padding: 8px; gap: 6px; }
  .ff-pad .keypad button { width: 48px; height: 44px; }
  .ff-pad .keypad button.wide { grid-column: span 4; width: 100%; }
  .ff-pad .keypad button.del { order: 0; }
  #screen-game .stage-area { gap: 4px; }
  /* One HUD block: score and round, the forest bar under them, the
     stopwatch beside both - two lines instead of three. */
  #screen-game .hud-area { flex-direction: row; align-items: center; gap: 4px 10px; }
  #screen-game .hud { flex: 1; min-width: 0; row-gap: 4px; font-size: 18px; }
  #screen-game .hud-time { flex: none; font-size: 16px; padding: 2px 10px; }
  .ff-health { order: 3; flex-basis: 100%; max-width: none; }
  #screen-game .feedback { min-height: 34px; }
  #screen-game .feedback img { width: 28px; }
  #screen-game .feedback span { font-size: 20px; }
}
/* Short upright phones (iPhone SE and the like): a smaller sum and keys,
   and no "tap a fire" line - with no aim the water still finds a fire. */
@media (orientation: portrait) and (max-width: 600px) and (max-height: 760px) {
  .ff-aim-hint { display: none; }
  .ff-pad .keypad button { height: 40px; }
  .ff-pad .equation { font-size: 30px; }
  .ff-pad .answer-display { min-height: 38px; font-size: 26px; }
  .ff-pipes { --cell: 58px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-screen { grid-template-rows: auto minmax(0, 1fr); gap: 5px; }
  #screen-game .stage-area { gap: 2px; }
  #screen-game .feedback { min-height: 28px; }
  #screen-game .feedback img { width: 24px; }
  #screen-game .feedback span { font-size: 18px; }
  .ff-pad { gap: 3px; }
  .ff-pad .equation { font-size: 30px; }
  .ff-pad .answer-display { min-height: 30px; font-size: 25px; }
  .ff-pad .keypad { grid-template-columns: repeat(5, 1fr); padding: 6px; gap: 5px; }
  .ff-pad .keypad button { width: 44px; height: 36px; }
  .ff-pad .keypad button.wide { grid-column: span 4; width: 100%; }
  .ff-pad .keypad button.del { order: 0; }
  .ff-pipes { --cell: 52px; }
  .ff-puzzle .ff-desc { min-height: 0; font-size: 13px; }
  .ff-puzzle-title { font-size: 18px; }
}
