:root {
  --paper: #fdf6e3;
  --ink: #1f1b24;
  --panel: #ffffff;
  --line: #1f1b24;
  --blue: #c2473a;  /* the game's accent colour (buttons); new_game.py --accent */
  --title: #f2c14e;  /* big title fill; new_game.py --title-color */
  --green: #2f9e44;
  --red: #e2574c;
  --gold: #f5b622;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 18px;
}
/* page = header, game, status; the game takes all the room that is left (16:9) */
.wrap { height: 100vh; display: flex; flex-direction: column; padding: 8px 12px; }
.top { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 24px; margin: 0 0 8px; }
.stage-box { flex: 1 1 auto; min-height: 0; container-type: size; display: flex; justify-content: center; }
h1 { font-family: "Fredoka", "Nunito", system-ui, sans-serif; font-size: 34px; margin: 0; color: var(--title); -webkit-text-stroke: 1.5px var(--ink); }
/* Ata7 Games label: logo + name in the header (a "◀ all games" link inside the catalogue),
   "presents" on the title card, "a game by" at the end */
.brand { display: flex; align-items: center; gap: 8px; margin-right: -10px; font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 18px; color: #1d5fae; text-decoration: none; }
.brand img { width: 40px; height: auto; display: block; }
.brand[href] { padding: 2px 12px 2px 8px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; }
.brand[href]:hover { background: #e9f5ff; }
.brand .back { font-size: 14px; }
.brand.solo .back { display: none; }
.presents { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 2px; font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 17px; color: #1d5fae; }
.presents img { width: 34px; height: auto; }
.presents.madeby { margin: 12px 0 0; font-size: 15px; opacity: 0.85; }
.presents.madeby img { width: 28px; }
.sub { margin: 0; font-size: 17px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sub .gap { width: 12px; }
.keys { display: inline-flex; gap: 4px; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border-radius: 8px;
  border: 3px solid var(--line);
  border-bottom-width: 6px;
  background: #fff;
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 700;
  font-size: 20px;
}
kbd.wide { padding: 0 12px; font-size: 17px; }
kbd.act { background: #ffd23f; }
.stage { position: relative; width: min(100cqw, 100cqh * 16 / 9); align-self: flex-start; }
.stage:fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1f1b24;
}
.stage:fullscreen canvas { width: min(100vw, calc(100vh * 16 / 9)); border: 0; border-radius: 0; }
.stage:fullscreen .overlay { border-radius: 0; }
canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  display: block;
  border-radius: 14px;
  border: 4px solid var(--line);
  background: #fdf6e3;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 27, 36, 0.35);
  border-radius: 14px;
}
.overlay.hidden { display: none; }
.card {
  background: var(--panel);
  border: 4px solid var(--line);
  border-radius: 24px;
  padding: 20px 28px;
  max-width: 900px;
  margin: 0 16px;
  text-align: center;
}
.card h2 { font-family: "Fredoka", system-ui, sans-serif; font-size: 50px; margin: 0 0 6px; color: var(--title); -webkit-text-stroke: 2px var(--ink); }
.card p { margin: 0 0 14px; font-size: 21px; }
.card p.small { margin: 16px 0 8px; font-size: 17px; font-weight: 700; opacity: 0.7; }
.card em { font-style: normal; opacity: 0.6; }
.card .stats { font-size: 30px; font-weight: 700; }
.card .row { display: flex; gap: 12px; justify-content: center; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; align-items: flex-end; margin: 6px 0 18px; }
.legend div { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 18px; font-weight: 700; line-height: 1.15; }
.chapters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
/* the chapter-pages switch on the title card, like the catalogue card's option box */
.opt.pagesopt { display: inline-flex; align-items: flex-start; gap: 10px; margin: 12px auto 0; padding: 8px 14px; max-width: 520px;
  border: 3px dashed var(--line); border-radius: 14px; background: #fffaf0; text-align: left; cursor: pointer;
  font-size: 17px; font-weight: 700; line-height: 1.25; -webkit-tap-highlight-color: transparent; }
.opt.pagesopt input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: #2f9e44; cursor: pointer; }
.opt.pagesopt small { display: block; font-size: 14px; font-weight: 400; opacity: 0.75; }
.pick { margin-top: 6px; font-size: 16px; font-weight: 700; opacity: 0.75; }
.pick[open] { opacity: 1; }
.pick summary { cursor: pointer; list-style: none; }
.pick summary::before { content: "▸ "; }
.pick[open] summary::before { content: "▾ "; }
.btn {
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 10px 24px;
  cursor: pointer;
  color: #fff;
}
.btn.green { background: var(--green); }
.btn.big { font-size: 28px; padding: 14px 46px; }
.btn.mini { font-size: 16px; padding: 6px 14px; background: var(--blue); }
.btn.chap { font-size: 17px; padding: 8px 16px; background: #fff; color: var(--ink); }
.btn.chap .ic { margin-right: 6px; }
.btn:focus-visible { outline: 4px solid #ffb703; outline-offset: 2px; }
.status { flex: none; font-size: 17px; font-weight: 700; margin: 6px 0 0; min-height: 1.4em; }
/* touch screens: ◀ ▶ bottom-left, big jump button bottom-right and the yellow 👐 "open / use"
   button next to it (it glows when there is something to open); hidden on book pages and menus */
.touch {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
@media (pointer: coarse) { .touch { display: block; } }
body.touch-mode .touch { display: block; }
.touch.off { display: none !important; }
/* left-handed (Topach's Settings tab; assets/ata7.js sets html.ata7-left): the buttons mirrored, the arrows on the right
   and the action buttons on the left; the pad and each button flip back, so ◀ stays left of ▶ and every sign reads right */
html.ata7-left .touch, html.ata7-left .touch .dpad, html.ata7-left .touch > .tbtn { scale: -1 1; }
.tbtn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 4px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
}
.tbtn.pressed { transform: scale(0.9); filter: brightness(0.92); }
.tbtn[hidden] { display: none; }
.dpad { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: 14px; width: 150px; height: 70px; }
.tbtn.arrow { width: 66px; height: 66px; border-radius: 16px; font-size: 26px; }
.tbtn.a-left { left: 0; top: 0; }
.tbtn.a-right { right: 0; top: 0; }
.tbtn.jump { right: max(14px, env(safe-area-inset-right)); bottom: 18px; width: 84px; height: 84px; background: rgba(47, 158, 68, 0.85); color: #fff; font-size: 42px; }
.tbtn.act { right: calc(max(14px, env(safe-area-inset-right)) + 98px); bottom: 26px; width: 72px; height: 72px; background: rgba(255, 210, 63, 0.6); font-size: 34px; flex-direction: column; gap: 1px; }
.tbtn.act.ready { background: #ffd23f; animation: actpulse 0.8s ease-in-out infinite alternate; }
@keyframes actpulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .tbtn.act.ready { animation: none; } }
.tbtn small { font-size: 13px; line-height: 1; }
/* only the buttons a moment needs: no ⇧ → 👐 moves to the corner; flying (.fly): ◀ ▼ ▶ and ⇧ is "up" */
.touch.nojump .tbtn.act { right: max(14px, env(safe-area-inset-right)); width: 84px; height: 84px; bottom: 18px; }
.tbtn.a-down { left: 75px; top: 0; }
.touch.fly .dpad { width: 216px; }
.touch.fly .tbtn.a-right { right: auto; left: 150px; }
.legend { --legend-h: 130px; }
.legend img { image-rendering: pixelated; height: calc(var(--legend-h) * var(--rel, 1)); width: auto; } /* --rel: the sprite's real height / the hero's, so a little brother stays little */
/* the phone is held upright: "⛶ Tam ekran" (script in index.html) turns the game sideways. Android: real full
   screen + the screen locked sideways. iPhone (web pages can't go full screen or rotate the screen there):
   body.turned draws the page turned 90°, upright when the phone is held sideways, even with rotation lock on. */
.rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 600px) {
  .rotate {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--blue);
    color: #fff;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 28px;
    text-align: center;
  }
  .rotate p { margin: 0; }
  .rotate .rot-icon { font-size: 80px; }
  body.turned .rotate, body.turned #fullBtn { display: none; } /* drawn turned = full screen isn't possible here */
  body.turned .wrap {
    position: fixed; top: 0; left: 100vw;
    width: 100vh; width: 100dvh; height: 100vw;
    transform: rotate(90deg); transform-origin: top left;
  }
}
/* phones and tablets have no keyboard: hide the key help, no double-tap zoom */
@media (pointer: coarse) {
  .keyhelp, .status { display: none; }
  body { touch-action: manipulation; }
}
/* short screens (a phone held sideways): small header, compact cards */
@media (max-height: 520px), (orientation: portrait) and (pointer: coarse) and (max-width: 600px) {
  .wrap { padding: 4px max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)); }
  .top { margin: 0 0 4px; gap: 4px 12px; }
  h1 { font-size: 20px; -webkit-text-stroke-width: 1px; }
  .brand { font-size: 14px; gap: 5px; margin-right: -4px; }
  .brand img { width: 26px; }
  .presents { font-size: 13px; gap: 5px; }
  .presents img { width: 22px; }
  .presents.madeby { margin-top: 6px; }
  .btn.mini { font-size: 13px; padding: 4px 10px; }
  .status { display: none; }
  .card { padding: 8px 16px; border-radius: 18px; }
  .card h2 { font-size: 26px; margin: 0 0 4px; }
  .card p { font-size: 15px; margin: 0 0 6px; }
  .card p.small { margin: 6px 0 4px; font-size: 13px; }
  .card .stats { font-size: 20px; }
  .legend { gap: 8px; margin: 2px 0 8px; }
  .legend div { font-size: 12px; gap: 2px; }
  .legend { --legend-h: 40px; }
  .btn.big { font-size: 20px; padding: 8px 28px; }
  .btn.chap { font-size: 13px; padding: 5px 10px; }
  .chapters { gap: 5px; margin-top: 4px; }
  .opt.pagesopt { margin: 6px auto 0; padding: 4px 10px; gap: 8px; font-size: 13px; }
  .opt.pagesopt input { width: 20px; height: 20px; }
  .opt.pagesopt small { font-size: 11px; }
  canvas { border-width: 3px; border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
/* short landscape phones: smaller buttons so they hide less of the floor */
@media (max-height: 430px) {
  .dpad { width: 120px; height: 56px; bottom: 10px; }
  .tbtn.arrow { width: 54px; height: 54px; font-size: 22px; }
  .tbtn.a-down { left: 60px; }
  .touch.fly .dpad { width: 174px; }
  .touch.fly .tbtn.a-right { left: 120px; }
  .tbtn.jump { width: 68px; height: 68px; bottom: 12px; font-size: 34px; }
  .tbtn.act { width: 60px; height: 60px; bottom: 16px; right: calc(max(14px, env(safe-area-inset-right)) + 80px); font-size: 28px; }
  .touch.nojump .tbtn.act { width: 68px; height: 68px; bottom: 12px; }
}
/* the child's pause (index.html #pauseStage, #pausedOv): a round ⏸ at the right, under the chapter label and beside the
   captions (they end at x 870 of 960), the picture dimmed behind ▶ */
.pausebtn { position: absolute; top: 15%; right: 1.6%; width: clamp(38px, 5.4cqw, 56px); height: clamp(38px, 5.4cqw, 56px);
  border-radius: 50%; border: 3px solid var(--ink); background: #fff8ea; color: var(--ink); font-size: clamp(16px, 2.4cqw, 24px);
  line-height: 1; padding: 0; cursor: pointer; opacity: 0.88; z-index: 3; }
.pausebtn[hidden] { display: none; }
.overlay.paused { background: rgba(13, 11, 24, 0.5); z-index: 4; }
/* the chapter list open: the character pictures make room, so the card still fits without scrolling */
.card:has(.pick[open]) .legend { display: none; }

/* the ▲ button pulses at the shelf post (Rusty climbs up with it) */
.tbtn.pulse { animation: tbtnPulse 1.1s ease-in-out infinite; }
@keyframes tbtnPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 236, 196, 0.0); } 50% { transform: scale(1.12); box-shadow: 0 0 0 8px rgba(255, 236, 196, 0.45); } }
