/* Shared game styles: every spel-*.html page loads this after style.css (game shell, 3D HUD, adventure kit, Dog Watcher/Lyktvakten panels shared with other games).
   Split out of css/style.css so pages do not download rules they cannot use; tests/css-scope.test.js checks the scope. */

/* Game shell -------------------------------------------------------------- */
.game-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.game-top h1 { font-size: 1.8rem; margin: 0; }
.game-top .spacer { flex: 1; }
.hud { display: flex; gap: 10px; flex-wrap: wrap; }
.hud .badge { background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 900; box-shadow: var(--shadow-press); }
.canvas-wrap { position: relative; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); background: #bfe7ff; }
.canvas-wrap canvas { display: block; width: 100%; height: auto; touch-action: none; }
.lane-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }

/* Memory ------------------------------------------------------------------ */
.memory-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 640px; margin: 0 auto; }
.mcard { display: block; aspect-ratio: 6 / 5; border: 0; padding: 0; background: transparent; cursor: pointer; font: inherit; }
/* 2D "flip": the back squeezes to zero width, then the front grows back (no 3D layers needed). */
.mcard .face { position: absolute; inset: 0; border-radius: 16px; display: grid; place-items: center; font-weight: 900; box-shadow: var(--shadow); overflow: hidden; transition: transform .16s ease-in; }
.mcard .back { background: var(--ink); transform: scaleX(1); transition-delay: .16s; }
.mcard .front { transform: scaleX(0); transition-delay: 0s; background: #fff; font-size: clamp(1.2rem, 3.6vw, 2rem); color: var(--ink); }
.mcard.open .back, .mcard.matched .back { transform: scaleX(0); transition-delay: 0s; }
.mcard.open .front, .mcard.matched .front { transform: scaleX(1); transition-delay: .16s; transition-timing-function: ease-out; }
.mcard .front.answer { background: #fff3dc; color: var(--coral-dark); font-size: clamp(1.6rem, 5vw, 2.6rem); }
.mcard.matched .front { background: #e6faf3; color: var(--mint-dark); }
.mcard:hover .back { filter: brightness(1.15); }

/* ===================== v0.2 ============================================= */
/* Pause */
.pause-btn { order: 5; }
.game-top .pause-btn { margin-left: 4px; }
/* 3D games */
.g3d-wrap { background: #1f2348; aspect-ratio: 16 / 9; min-height: 360px; }
.g3d-wrap canvas { width: 100% !important; height: 100% !important; }
.g3d-banner { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.94); color: var(--ink); padding: 8px 22px; border-radius: 16px; font-weight: 900; font-size: 1.6rem; box-shadow: 0 6px 0 rgba(0,0,0,.18); pointer-events: none; white-space: nowrap; z-index: 2; }
.g3d-banner:empty { display: none; }
.g3d-side { position: absolute; top: 14px; right: 14px; display: grid; gap: 8px; z-index: 2; max-width: 240px; }
.g3d-side:empty { display: none; }
.g3d-side .panel { background: rgba(255,255,255,.94); border-radius: 14px; padding: 8px 12px; font-weight: 700; font-size: .9rem; box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.g3d-side .panel h4 { margin: 0 0 4px; font-size: .95rem; }
.g3d-side button { font: inherit; }
.g3d-float { position: absolute; transform: translate(-50%, -100%); font-weight: 900; font-size: 1.4rem; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35); pointer-events: none; animation: float-up 0.9s ease-out forwards; z-index: 3; }
.touch-pad { position: absolute; inset: auto 12px 12px 12px; display: none; justify-content: space-between; align-items: end; pointer-events: none; z-index: 2; }
.touch-pad button { pointer-events: auto; border: 0; border-radius: 16px; background: rgba(255,255,255,.75); font-size: 1.3rem; font-weight: 900; color: var(--ink); width: 56px; height: 56px; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-pad .dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px; }
.touch-pad .dpad [data-k=up] { grid-column: 2; }
.touch-pad .dpad [data-k=left] { grid-column: 1; grid-row: 2; }
.touch-pad .dpad [data-k=down] { grid-column: 2; grid-row: 2; }
.touch-pad .dpad [data-k=right] { grid-column: 3; grid-row: 2; }
.touch-pad .jump { width: 92px; height: 92px; border-radius: 50%; background: rgba(255,201,60,.9); }
@media (pointer: coarse) {
  .touch-pad { display: flex; }
}
.g3d-help { margin-top: 10px; }
.build-menu { display: grid; gap: 6px; }
.build-menu button { display: flex; justify-content: space-between; gap: 10px; border: 0; background: #f4f0ff; border-radius: 10px; padding: 6px 10px; font-weight: 800; cursor: pointer; color: var(--ink); }
.build-menu button[disabled] { opacity: .45; cursor: not-allowed; }
.board-list { margin: 6px 0 0; padding-left: 1.4em; text-align: left; }
.g3d-wrap .overlay { z-index: 4; }
.g3d-wrap .overlay .card { max-height: calc(100% - 24px); overflow: auto; }

/* ---- v0.3: transfer, 100-question test ---- */
.g3d-view { position: absolute; top: 14px; left: 14px; z-index: 2; background: rgba(255,255,255,.92); }
.g3d-view[aria-pressed="true"] { background: var(--sun); }

/* ---- v0.4: adventure games (Talbergets tempel, Lyktvakten) ---- */
.adv-wrap { touch-action: none; user-select: none; -webkit-user-select: none; }
.adv-wrap .touch-pad { display: none !important; }
.adv-stick-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 70%; z-index: 2; touch-action: none; }
.adv-stick { position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; background: rgba(255,255,255,.22); border: 3px solid rgba(255,255,255,.7); box-shadow: 0 4px 0 rgba(0,0,0,.18); pointer-events: none; }
.adv-stick i { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: 0 4px 0 rgba(0,0,0,.2); transform: translate(-50%,-50%); }
.adv-btns { position: absolute; right: 14px; bottom: 14px; z-index: 3; display: grid; grid-template-columns: auto auto; grid-template-areas: "focus item" "lamp action"; gap: 10px; align-items: end; justify-items: end; }
.adv-btn { position: relative; border: 0; border-radius: 22px; background: rgba(255,255,255,.93); color: var(--ink); font: inherit; font-weight: 900; display: grid; place-items: center; gap: 0; width: 76px; height: 76px; padding: 4px; box-shadow: 0 5px 0 rgba(0,0,0,.25); cursor: pointer; touch-action: none; }
.adv-btn .ic { font-size: 1.7rem; line-height: 1; }
.adv-btn .lb { font-size: .72rem; line-height: 1.1; }
.adv-btn kbd { position: absolute; top: -6px; right: -6px; font-size: .62rem; padding: 1px 5px; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: none; }
.adv-btn.down { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.adv-btn[disabled] { opacity: .45; }
.adv-btn[hidden] { display: none; }
.adv-btn.glow { animation: adv-glow 1s ease-in-out infinite alternate; }
.adv-action { grid-area: action; width: 104px; height: 104px; border-radius: 50%; background: #ffc93c; }
.adv-action .ic { font-size: 2.3rem; }
.adv-action .lb { font-size: .85rem; }
.adv-focus { grid-area: focus; background: #e9e2ff; }
.adv-item { grid-area: item; background: #c9f4e6; }
.adv-lamp { grid-area: lamp; background: #fff1c2; }
.adv-ring { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3; display: grid; gap: 8px; justify-items: center; pointer-events: auto; }
.adv-ring[hidden] { display: none; }
.adv-ring .q { background: #1f2348; color: #fff; font-weight: 900; font-size: 1.7rem; padding: 6px 22px; border-radius: 16px; box-shadow: 0 5px 0 rgba(0,0,0,.25); text-align: center; }
.adv-ring .opts { display: flex; gap: 10px; }
.adv-ring .opt { position: relative; min-width: 76px; height: 70px; border: 0; border-radius: 18px; font: inherit; font-size: 1.7rem; font-weight: 900; color: var(--ink); background: #fff; box-shadow: 0 6px 0 #c9bfe9; cursor: pointer; touch-action: none; }
.adv-ring .opt:nth-child(1) { background: #ffe1db; box-shadow: 0 6px 0 #f2a597; }
.adv-ring .opt:nth-child(2) { background: #dff1ff; box-shadow: 0 6px 0 #98c9ef; }
.adv-ring .opt:nth-child(3) { background: #fff3c9; box-shadow: 0 6px 0 #ecd279; }
.adv-ring .opt:nth-child(4) { background: #d8f7ec; box-shadow: 0 6px 0 #8fdcc1; }
.adv-explain { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(1); z-index: 4; background: #fff; border-radius: 20px; padding: 14px 20px; display: grid; gap: 6px; justify-items: center; box-shadow: 0 8px 0 rgba(0,0,0,.2); transition: opacity .35s, transform .35s; pointer-events: none; max-width: 80%; }
.adv-explain.out { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
.adv-explain .dots { display: grid; gap: 4px; }
.adv-title { position: absolute; left: 50%; top: 28%; transform: translate(-50%, -50%); z-index: 3; text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35); pointer-events: none; transition: opacity .45s; }
.adv-title.out { opacity: 0; }
.adv-hud { position: absolute; top: 12px; left: 12px; z-index: 2; display: flex; gap: 8px; flex-wrap: wrap; max-width: 56%; pointer-events: none; }
.adv-hud .hearts i.off { background: #d8d3e8; }
.adv-hud .meter { width: 90px; height: 12px; border-radius: 7px; background: #e8e3f5; overflow: hidden; }
.adv-hud .meter.lamp b { background: linear-gradient(90deg, #ffd65a, #fff1a8); }
.adv-hud .night { background: #2b2f63; color: #fff; }
.adv-map { position: absolute; top: 12px; right: 12px; z-index: 2; width: 132px; height: 132px; border-radius: 18px; background: rgba(31,35,72,.82); box-shadow: 0 4px 0 rgba(0,0,0,.2); cursor: pointer; }
.adv-map canvas { width: 100%; height: 100%; display: block; border-radius: 18px; }
.adv-sign { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 2; background: rgba(255,255,255,.95); border-radius: 16px; padding: 6px 18px; font-weight: 900; font-size: 1.2rem; text-align: center; box-shadow: 0 5px 0 rgba(0,0,0,.18); pointer-events: none; max-width: 46%; }
.adv-sign:empty { display: none; }
.adv-fade { position: absolute; inset: 0; z-index: 3; background: #1f2348; opacity: 0; pointer-events: none; transition: opacity .35s; }
.adv-fade.on { opacity: 1; }
.adv-dark { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .5s; background: radial-gradient(circle at 50% 58%, rgba(14,12,40,.55) 0, rgba(14,12,40,.93) 30%); }
.adv-dark.on { opacity: 1; }
.adv-dark.lamp { background: radial-gradient(circle at 50% 58%, rgba(255,214,120,.08) 0, rgba(255,214,120,0) 22%, rgba(14,12,40,.55) 42%, rgba(14,12,40,.86) 70%); }
.adv-card { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; background: rgba(31,35,72,.35); padding: 12px; }
.adv-card[hidden] { display: none; }
.adv-card h2 { margin: 0 0 8px; }
@media (prefers-reduced-motion: reduce) {
  .adv-dark { transition: none; }
}
.adv-bench { display: grid; gap: 8px; text-align: left; }
.adv-bench .rec { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; background: #f6f2ff; border-radius: 14px; padding: 8px 12px; }
.adv-bench .rec small { color: var(--ink-soft); }
.adv-bench .grid-art { display: inline-grid; gap: 2px; margin-top: 4px; }
@media (max-width: 760px) {
  .adv-btn { width: 62px; height: 62px; border-radius: 18px; }
  .adv-action { width: 86px; height: 86px; }
  .adv-ring .opt { min-width: 60px; height: 58px; font-size: 1.35rem; }
  .adv-ring .q { font-size: 1.3rem; }
  .adv-map { width: 96px; height: 96px; }
  .adv-sign { font-size: .95rem; max-width: 60%; }
}
.adv-sign:not(.on) { display: none; }
.adv-hud .gems { gap: 4px; }
.adv-hud .gem { display: inline-block; width: 14px; height: 14px; transform: rotate(45deg); border-radius: 3px; box-shadow: inset 0 0 0 2px rgba(31,35,72,.25); }
.adv-hud .chip.hint { display: block; font-size: .85rem; font-weight: 800; white-space: normal; max-width: 340px; background: #1f2348; color: #fff; }
.adv-hud .key.red { filter: hue-rotate(-40deg) saturate(2); }
.adv-hud .key.blue { filter: hue-rotate(170deg) saturate(1.6); }
.adv-shell .g3d-help { margin-top: 8px; }
@media (max-width: 700px) {
  .adv-map { width: 96px; height: 96px; }
  .adv-hud .chip.hint { max-width: 220px; font-size: .75rem; }
  .adv-sign { max-width: 70%; font-size: 1rem; }
}
/* Shared adventure style: chunky pop-ups */
.adv-pop { position: absolute; z-index: 4; transform: translate(-50%, -50%); font-weight: 900; font-size: 1.9rem; color: #ffe08a; -webkit-text-stroke: 2px #1f2348; paint-order: stroke fill; text-shadow: 0 4px 0 rgba(31,35,72,.55); pointer-events: none; animation: adv-pop 1.05s ease-out forwards; white-space: nowrap; }
.adv-pop.info { color: #fff; font-size: 1.4rem; }
.adv-pop.soft { color: #c9f4e6; font-size: 1.3rem; }
@media (prefers-reduced-motion: reduce) {
  .adv-pop { animation-duration: .01s; animation-delay: .8s; }
}
.adv-panel { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(31,35,72,.45); }
.adv-panel[hidden] { display: none; }
.adv-panel .adv-bench { background: #fff; border-radius: 24px; padding: 16px 18px; box-shadow: 0 8px 0 rgba(0,0,0,.25); width: min(560px, 92%); max-height: 92%; overflow: auto; }
.adv-panel h3 { margin: 0 0 4px; }
.adv-panel h3 small { font-weight: 700; color: var(--ink-soft); }
.adv-bench .rec { border: 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left; grid-template-columns: 1fr auto auto; box-shadow: 0 4px 0 #d9d0f5; }
.adv-bench .rec:hover, .adv-bench .rec:focus-visible { background: #ece5ff; }
.adv-bench .arr { display: grid; gap: 2px; }
.adv-bench .rc { font-weight: 900; font-size: .85rem; white-space: nowrap; }
.adv-hud .chip:not(.night) .moons i { background: #e2dcf2; }
.adv-hud .moons i.on { background: #ffe08a; }
.adv-hud .meter.xp b { background: linear-gradient(90deg, #8e6cf0, #ff8fb1); }
.adv-hud .meter { width: 64px; }
/* Tassrusch: number pad + stage progress */
.adv-pad { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 4; background: rgba(255,255,255,.97); border-radius: 24px; padding: 10px 12px 12px; box-shadow: 0 8px 0 rgba(0,0,0,.25); display: grid; gap: 8px; justify-items: center; width: min(320px, 92%); }
.adv-pad[hidden] { display: none; }
.adv-pad .q { background: #1f2348; color: #fff; font-weight: 900; font-size: 1.8rem; padding: 4px 20px; border-radius: 14px; text-align: center; }
.adv-pad .val { min-width: 120px; min-height: 44px; font-size: 2rem; font-weight: 900; text-align: center; border-radius: 12px; background: #f6f2ff; box-shadow: inset 0 3px 0 rgba(0,0,0,.08); padding: 0 12px; }
.adv-pad .keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
.adv-pad .keys button:active { transform: translateY(3px); box-shadow: 0 1px 0 #ecd279; }
.adv-pad .keys .ok { background: #2ec4a0; color: #fff; box-shadow: 0 4px 0 #1f8f74; }
.adv-progress { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); width: min(340px, 40%); height: 14px; z-index: 2; border-radius: 8px; background: rgba(255,255,255,.85); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.adv-progress[hidden] { display: none; }
.adv-progress .me { background: #ff6b57; z-index: 1; }
.adv-progress .ghost { background: #8e6cf0; opacity: .75; }
.adv-progress .ghost[hidden] { display: none; }
.adv-hud .chip.boost { background: #ffc93c; animation: adv-glow .5s ease-in-out infinite alternate; }
.adv-hud .chip.paw .meter b { background: linear-gradient(90deg, #ff6b57, #ffc93c); }

/* ---------------------------------------------------------- Dog Watcher --- */
/* Dog Watcher 3D: soft pastel HUD on top of the scene */
.g3d-wrap.dw3d { background: #cfeeff; aspect-ratio: 16 / 10; min-height: 420px; }
.adv-drop { grid-area: drop; background: #ffd9e4; }
.adv-call { grid-area: call; background: #d7f0ff; }
.dw-tasks { list-style: none; margin: 0; padding: 8px 10px; background: rgba(255,255,255,.93); border-radius: 16px; box-shadow: 0 3px 0 rgba(31,35,72,.12); display: grid; gap: 4px; font-size: .85rem; font-weight: 800; }
.dw-tasks[hidden] { display: none; }
.dw-ask-card { background: #fff; border-radius: 26px; padding: 16px 18px; width: min(420px, 94%); max-height: 94%; overflow: auto; text-align: center; box-shadow: 0 8px 0 rgba(31,35,72,.22); }
@media (max-width: 760px) {
  .g3d-wrap.dw3d { aspect-ratio: auto; width: 100%; min-height: 440px; height: min(140vw, 76vh); }
  .dw-tasks { font-size: .75rem; padding: 6px 8px; }
}

/* ===================== v0.4.1: phones first ============================== */
@media (max-width: 760px), (max-height: 500px) {
  .game-top { flex-wrap: nowrap; gap: 6px; margin-bottom: 6px; min-height: 48px; }
  .game-top h1 { font-size: 1.1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .game-top .spacer { flex: 1 1 0; min-width: 0; }
  .game-top .hud { flex-wrap: nowrap; gap: 4px; }
  .game-top .hud .badge { padding: 4px 9px; font-size: .85rem; white-space: nowrap; }
  .g3d-wrap, .g3d-wrap.dw3d { aspect-ratio: auto; min-height: 0; width: 100%; height: calc(100svh - 62px); border-radius: 16px; }
  .canvas-wrap { touch-action: none; overscroll-behavior: contain; }
  .canvas-wrap .overlay .card { padding: 16px 14px 0; max-width: min(440px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto; }
  .canvas-wrap .overlay .card .gs-go { position: sticky; bottom: 0; margin: 12px -14px 0; padding: 10px 14px 14px; background: linear-gradient(rgba(255,255,255,0), #fff 30%); }
  .canvas-wrap .overlay .card .btn-row { padding-bottom: 14px; }
  .g3d-help { font-size: .85rem; }
  .canvas-wrap:has(> canvas):not(.g3d-wrap) { display: flex; align-items: center; justify-content: center; }
  .canvas-wrap:has(> canvas):not(.g3d-wrap) > canvas { width: auto; height: auto; max-width: 100%; max-height: calc(100svh - 62px); }
  .canvas-wrap .overlay { overscroll-behavior: contain; }
  /* While playing, the game takes over the whole screen (safe areas respected). */
  body.game-play { overflow: hidden; overscroll-behavior: none; }
  body.game-play .game-shell .game-top { padding: 4px 8px 2px; margin: 0; }
  body.game-play .game-shell > .canvas-wrap { flex: 1 1 auto; height: auto; min-height: 0; border-radius: 0; box-shadow: none; }
  body.game-play .game-shell > .canvas-wrap:not(.g3d-wrap) > canvas { max-height: 100%; }
  body.game-play .game-shell > :not(.game-top):not(.canvas-wrap) { display: none; }
  body.game-play .site-header, body.game-play .site-footer, body.game-play .skip-link { visibility: hidden; }
  .adv-btn, .adv-ring .opt, .dw-opts .opt, .touch-pad button { touch-action: manipulation; }
  .adv-btns { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .g3d-wrap, .g3d-wrap.dw3d { height: calc(100svh - 54px); }
  .game-top { min-height: 44px; margin-bottom: 4px; }
  .adv-btn { width: 56px; height: 56px; border-radius: 16px; }
  .adv-action { width: 80px; height: 80px; }
  .adv-map { width: 80px; height: 80px; }
}
@media (max-width: 640px), (max-height: 500px) {
  /* Game start / end cards: smaller mascot so the buttons fit. */
  .canvas-wrap .overlay .card > div[style*="width"]:first-child { width: 72px !important; }
  .canvas-wrap .overlay .card h2 { font-size: 1.3rem; }
  .canvas-wrap .overlay .card p { margin: 6px 0; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .canvas-wrap .overlay .card > div[style*="width"]:first-child { display: none; }
}
@media (max-width: 760px), (max-height: 500px) {
  .canvas-wrap .overlay { place-items: start center; padding-top: 8px; }
  .canvas-wrap .overlay .card { max-height: min(calc(100% - 16px), calc(100svh - 76px)); }
}
@media (max-width: 760px), (max-height: 500px) {
  .g3d-wrap.dw3d:not(.playing) .dw-evening { display: none !important; }
}
@media (max-width: 760px), (max-height: 500px) {
  /* Slim play bar: back, scores (scroll if many), pause. */
  body.game-play .game-top h1, body.game-play .game-top .spacer { display: none; }
  body.game-play .game-top .hud { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  body.game-play .game-top .hud::-webkit-scrollbar { display: none; }
  .game-top .pause-btn, .game-top > a.btn { flex: 0 0 auto; }
  body.game-play .game-shell > .canvas-wrap[style*="min-height"] { min-height: 0 !important; overflow: auto; }
  /* Compact in-game HUD. */
  .adv-hud { top: 8px; left: 8px; gap: 4px; max-width: 58%; }
  .adv-hud .chip { font-size: .74rem; padding: 3px 8px; border-radius: 11px; gap: 4px; box-shadow: 0 2px 0 rgba(0,0,0,.16); }
  .adv-hud .chip.hint { max-width: 100%; font-size: .72rem; }
  .adv-hud .hearts i { width: 12px; height: 11px; }
  .adv-hud .meter { width: 56px; height: 9px; }
  .adv-map { width: 84px; height: 84px; top: 8px; right: 8px; border-radius: 14px; }
  .g3d-side { top: 8px; right: 8px; max-width: 46%; gap: 4px; }
  .g3d-side .panel { font-size: .74rem; padding: 5px 8px; border-radius: 11px; }
  .g3d-side .panel h4 { font-size: .8rem; }
  .build-menu button { padding: 4px 8px; min-height: 44px; align-items: center; }
  .g3d-view { top: 8px; left: 8px; }
  .g3d-banner { font-size: 1.15rem; padding: 5px 14px; top: 8px; }
  .touch-pad { inset: auto max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
}
@media (max-width: 760px), (max-height: 500px) {
  .g3d-side { max-height: calc(100% - 150px); overflow-y: auto; overscroll-behavior: contain; }
  .g3d-wrap:has(.g3d-view) .g3d-banner { top: 56px; }
  .g3d-banner small { font-size: .7rem; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .g3d-side { max-width: 32%; max-height: calc(100% - 110px); }
  .g3d-wrap:has(.g3d-view) .g3d-banner { top: 8px; }
  .adv-hud { max-width: 50%; }
  .touch-pad .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px); }
  .touch-pad button { width: 48px; height: 48px; }
  .touch-pad .jump { width: 76px; height: 76px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .adv-hud { gap: 3px; }
  .adv-hud .chip { font-size: .68rem; padding: 2px 7px; }
  .adv-hud .meter { width: 44px; height: 8px; }
  .adv-hud .chip.hint { font-size: .68rem; padding: 3px 8px; max-width: 300px; }
}
@media (max-width: 760px), (max-height: 500px) {
  .adv-hud:not(.open) .chip.extra { display: none; }
  .adv-hud .chip .moons { display: none; }
  .adv-hud .chip small { font-size: .62rem; }
  .adv-hud .chip.hint.old { display: none; }
}
/* Island side panel: the toggle reads as a heading on desktop; on phones the list folds behind it. */
.side-toggle { all: unset; cursor: default; font: inherit; font-weight: 800; }
.side-toggle span { display: none; }
@media (max-width: 760px), (max-height: 500px) {
  .side-toggle { cursor: pointer; display: flex; justify-content: space-between; gap: 6px; min-height: 44px; align-items: center; width: 100%; box-sizing: border-box; }
  .side-toggle span { display: inline; }
  .g3d-side .panel:not(.open) .build-menu { display: none; }
  .g3d-side .panel h4:has(.side-toggle) { margin: -5px 0; }
  .g3d-side .build-menu button.locked { display: none; }
  .g3d-side .side-info h4 { display: inline; font-size: .74rem; margin-right: 4px; }
  .g3d-side .side-income { font-size: .7rem; }
  .g3d-side .side-tip { font-size: .7rem; }
}
@media (max-width: 760px) and (orientation: portrait) {
  .memory-board { gap: 8px; }
  .mcard { aspect-ratio: 4 / 5; }
  .mcard .front { font-size: 1.15rem; }
  .mcard .front.answer { font-size: 1.7rem; }
  .canvas-wrap:has(> .memory-board) { padding: 10px !important; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .memory-board { grid-template-columns: repeat(8, 1fr) !important; max-width: none; gap: 6px; }
  .mcard { aspect-ratio: 4 / 5; }
  .canvas-wrap:has(> .memory-board) { padding: 8px !important; }
}

/* ===================== v0.4.2: desktop fit + Helskärm ===================== */
.game-top .fs-btn { order: 6; white-space: nowrap; }
.game-shell.is-full { display: flex; flex-direction: column; width: 100%; height: 100%; max-width: none; margin: 0; background: var(--paper);
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
body.game-max { overflow: hidden; }
body.game-max .game-shell { position: fixed; inset: 0; z-index: 70; }
.game-shell.is-full .game-top { margin-bottom: 6px; flex-wrap: nowrap; }
.game-shell.is-full > .canvas-wrap { flex: 1 1 auto; min-height: 0 !important; height: auto !important; max-height: none; aspect-ratio: auto !important; width: 100%; }
.game-shell.is-full > .canvas-wrap:has(> canvas):not(.g3d-wrap) { display: flex; align-items: center; justify-content: center; }
.game-shell.is-full > .canvas-wrap:has(> canvas):not(.g3d-wrap) > canvas { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.game-shell.is-full > .canvas-wrap[style*="min-height"] { overflow: auto; }
.game-shell.is-full > :not(.game-top):not(.canvas-wrap) { display: none; }
@media (min-width: 761px) and (min-height: 501px) {
  .g3d-wrap, .g3d-wrap.dw3d { aspect-ratio: auto; min-height: 340px; height: min(calc(100vh - 210px), 760px); }
  .canvas-wrap:has(> canvas):not(.g3d-wrap) { display: flex; align-items: center; justify-content: center; }
  .canvas-wrap:has(> canvas):not(.g3d-wrap) > canvas { width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 210px); }
  .canvas-wrap[style*="min-height"] { min-height: min(640px, calc(100vh - 210px)) !important; }
  .game-shell:not(.is-full) .canvas-wrap .overlay .card { max-height: calc(100% - 20px); }
}
@media (min-width: 761px) and (min-height: 501px) {
  .canvas-wrap .overlay .card { max-width: min(760px, calc(100% - 32px)); overflow: auto; }
  /* Cards with an extra panel (dog names, tower upgrades) put it in a second column. */
  .canvas-wrap .overlay .card:has(> .dw-names, > #shop) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); column-gap: 22px; max-width: min(1000px, calc(100% - 32px)); align-content: start; }
  .canvas-wrap .overlay .card:has(> .dw-names, > #shop) > :not(.dw-names):not(#shop) { grid-column: 1; }
  .canvas-wrap .overlay .card > .dw-names, .canvas-wrap .overlay .card > #shop { grid-column: 2; grid-row: 1 / span 9; align-self: center; margin-top: 0; text-align: left; }
  .canvas-wrap .overlay .card #gsPicker { flex-wrap: wrap; justify-content: center; gap: 6px; }
  .canvas-wrap .overlay .card #gsPicker .chip { min-width: 44px; height: 44px; padding: 0 8px; }
  .canvas-wrap .overlay .card > p.muted { max-width: 560px; margin-left: auto; margin-right: auto; }
}
@media (min-width: 761px) and (max-height: 860px) {
  .canvas-wrap .overlay .card { padding: 14px 20px; }
  .canvas-wrap .overlay .card > div[style*="width"]:first-child { width: 64px !important; }
  .canvas-wrap .overlay .card h2 { font-size: 1.4rem; margin-bottom: 4px; }
  .canvas-wrap .overlay .card p { margin: 6px 0; }
  .canvas-wrap .overlay .card .gs-go { margin-top: 12px !important; }
  .game-top { margin-bottom: 8px; }
  .game-top h1 { font-size: 1.5rem; }
}
@media (max-width: 640px), (max-height: 500px) {
  .game-top .fs-btn { font-size: 0; min-width: 44px; padding: 0 10px; }
  .game-top .fs-btn span { font-size: 1.15rem; }
}
@media (min-width: 761px) and (max-height: 920px) {
  .canvas-wrap .overlay .card > div[style*="width"]:first-child { display: none; }
  .canvas-wrap .overlay .card .toggle-group button, .canvas-wrap .overlay .card #gsPicker button { min-height: 40px; }
  .canvas-wrap .overlay .card p[style*="margin:14px"] { margin: 8px 0 4px !important; }
  .canvas-wrap .overlay .card .gs-go { margin-top: 8px !important; }
  .canvas-wrap .overlay .card h2 { margin-top: 0; }
}
@media (min-width: 761px) and (min-height: 921px) {
  .canvas-wrap .overlay .card > div[style*="width"]:first-child { width: 72px !important; }
}

/* ===================== Ritstudion ===================== */
/* Soft-art HUD: the same round pastel chips and cards as Dog Watcher in every 3D game. */
.g3d-wrap { background: #cfeeff; }
.adv-hud .chip, .g3d-view { border-radius: 999px; box-shadow: 0 3px 0 rgba(31,35,72,.14); }
.adv-hud .chip.hint { border-radius: 16px; background: rgba(255,255,255,.95); color: var(--ink); border-left: 6px solid #9a7cf2; }
.adv-hud .night { background: #3b3f78; }
.adv-sign, .g3d-banner { border-radius: 999px; box-shadow: 0 4px 0 rgba(31,35,72,.14); }
.g3d-side .panel { border-radius: 16px; box-shadow: 0 3px 0 rgba(31,35,72,.12); }
.adv-map { border-radius: 24px; background: rgba(59,63,120,.78); border: 3px solid rgba(255,255,255,.9); box-shadow: 0 3px 0 rgba(31,35,72,.18); }
.adv-ring .q, .adv-pad .q { background: #3b3f78; border-radius: 999px; box-shadow: 0 4px 0 rgba(31,35,72,.22); }
.adv-fade { background: #3b3f78; }

/* ---- Wardrobe v0.6: outfits, rarity and unlock progress (min-figur.html) ---- */
.gs-nudge { margin: 10px auto 0; font-weight: 800; color: var(--plum); }
.gs-crystals { font-weight: 800; color: var(--ink-soft); margin: 8px 0 0; }

/* ---------------------------------------------------------------- Spela med kompisar (multiplayer, flag-gated) --- */
.mp-status { font-weight: 700; font-size: 14px; }

/* ---- Äventyrslandet: the platform game (spel-aventyrslandet.html, internal id "platform") ---- */
.adv-roll { grid-area: roll; background: #ffe3ec; }
.adv-jump { grid-area: jump; width: 100px; height: 100px; border-radius: 50%; background: #ffd166; font-size: 1.1rem; }
.adv-water { grid-area: water; background: #c9f1ff; }
.adv-water[disabled] { opacity: .45; }
@media (max-width: 760px), (max-height: 500px) {
  .adv-jump { width: 82px; height: 82px; }
}

/* ---- Stjärnfärden (spel-stjarnfarden.html) ---- */
.adv-charge { grid-area: charge; width: 96px; height: 96px; border-radius: 50%; background: #ffd166; }
.adv-capsule { grid-area: capsule; background: #ffe3f3; }
@media (max-width: 760px), (max-height: 500px) {
  .adv-charge { width: 78px; height: 78px; }
}
.adv-fire { grid-area: fire; background: #fff1b8; }
