/* Landscape (2026-11-17, the owner: "è possibile giocare sia in verticale che orizzontale per ios e android?").
   src/orient.js puts the class `land` on <html> when a phone or a tablet is held sideways, and on a computer in a window wider than tall:
   #stage fills the screen and the HUD moves to the edges, so the middle (the hero) stays clear. Upright nothing changes.

     left      life and level, coconut, wallet, carry bar; the main goal and the side mission under them; the elements' chips
               over the bottom row
     right     minimap and gear; the buttons of the places (act, talk, enter, shop, portal) stacked over the portraits
     top       the small chips (magnet, pearls on a trip, chest carried, puzzle hint) in the band between the two corners,
               the boss bar under them
     bottom    Scrigni · Mappa · Negozio (the left column, laid as a row), the dock, the party portraits (a 3 × 2 block)
     sheets    centred, at most 720 px wide, almost the whole height; the map and the level map side by side with their text

   Phones sideways are 360–440 px tall: every place below is counted for 390 (844 × 390) and checked at 360 and 440.
   The portrait rules are spread over five style sheets and the modules' own <style>s, with selectors as heavy as
   `#stage.docked.notools #talkbtn`: the prefix `.land #stage:not(#_)` outweighs all of them (the :not(#_) counts as an id
   and matches always), so these rules win without copying each of theirs.
   --sal / --sar / --sab: the sides of the screen the notch and the home bar take (orient.js fakes them with ?notch). */
:root { --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); }
/* wider than a phone held sideways (21:9 and wider monitors): the frame stops at 2.4 : 1 and stays centred, so the camera
   does not show the island far out to the sides */
.land #stage { width: min(100%, calc(100dvh * 2.4)); }

/* ---- left: life, level, coconut, wallet, carry */
.land #stage:not(#_) #brand { display: none; }
.land #stage:not(#_) #hp { left: calc(var(--sal) + 12px); top: 10px; }
.land #stage:not(#_) #lvl { left: calc(var(--sal) + 156px); top: 8px; }
.land #stage:not(#_) #pack { left: calc(var(--sal) + 12px); top: 36px; }
.land #stage:not(#_) #wallet { left: calc(var(--sal) + 12px); top: 88px; }
.land #stage:not(#_) #carry { left: calc(var(--sal) + 12px); top: 120px; }
/* the goals under them, left-aligned (upright they hang under the minimap) */
.land #stage:not(#_) #mainquest, .land #stage:not(#_) #cavechip { left: calc(var(--sal) + 12px); right: auto; top: 160px; }
.land #stage:not(#_) #quest { left: calc(var(--sal) + 12px); right: auto; top: 232px; }
/* the goal's text on two lines at most, so the side mission's box under it never gets covered (the owner's screenshot,
   2026-11-18: a three-line goal ran over it) */
.land #stage:not(#_) #mainquest span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* pearls full: "Pieno! Torna alla casetta" on one line under the counter, and the goals step down below it (they covered it:
   the owner's screenshot, 2026-11-18) */
.land #stage:not(#_) #carry.full { width: auto; }
.land #stage:not(#_) #carry.full .txt em { white-space: nowrap; }
.land #stage:not(#_):has(> #carry.full) #mainquest, .land #stage:not(#_):has(> #carry.full) #cavechip { top: 196px; }
.land #stage:not(#_):has(> #carry.full) #quest { top: 268px; }
/* the weapons' rings (when the settings show them) over the row on the left; the elements' chips over the dock, left of
   the hero's feet (beside the rings when both show) */
.land #stage:not(#_) #powers { left: calc(var(--sal) + 12px); right: auto; bottom: calc(69px + var(--sab)); justify-content: flex-start; }
.land #stage:not(#_) #elements { left: calc(var(--sal) + 216px); right: auto; bottom: calc(104px + var(--sab)); justify-content: flex-start; }
.land #stage:not(#_):has(> #powers:not([hidden])) #elements { left: calc(var(--sal) + 356px); }

/* ---- top band: the chips, two by two, then the boss bar */
.land #stage:not(#_) #boost { left: calc(var(--sal) + 232px); top: 8px; }
.land #stage:not(#_) #tripboost { left: auto; right: calc(var(--sar) + 160px); top: 8px; }
.land #stage:not(#_) #chestchip { left: calc(var(--sal) + 232px); top: 44px; }
.land #stage:not(#_) #puzzlehint { left: auto; right: calc(var(--sar) + 160px); top: 44px; }
.land #stage:not(#_) #boss { top: 82px; width: min(220px, 40%); }
/* a small phone (iPhone SE, 667 px): the band is ~275 px, the chips go two by two on the other side */
@media (max-width: 720px) {
  .land #stage:not(#_) #puzzlehint { top: 8px; }
  .land #stage:not(#_) #tripboost { top: 44px; }
}
.land #stage:not(#_) #banner { top: 22%; }

/* ---- right: minimap and gear stay in the corner */
.land #stage:not(#_) #mini { right: calc(var(--sar) + 10px); top: 8px; }
.land #stage:not(#_) #gear { right: calc(var(--sar) + 110px); top: 12px; }

/* ---- bottom: Scrigni · Mappa · Negozio as a row on the left, the dock, the party in the right corner */
.land #stage:not(#_) #dockcol { left: calc(var(--sal) + 10px); bottom: calc(8px + var(--sab)); flex-direction: row; gap: 8px; }
.land #stage:not(#_) #dock { left: calc(var(--sal) + 204px); right: calc(var(--sar) + 170px); bottom: calc(8px + var(--sab)); max-width: 440px; }
.land #stage:not(#_) #party { right: calc(var(--sar) + 10px); bottom: calc(8px + var(--sab)); flex-direction: row-reverse; flex-wrap: wrap-reverse; align-content: flex-start; gap: 6px; width: 150px; }
.land #stage:not(#_) #party button { width: 46px; height: 46px; }

/* ---- the buttons of the places: right-aligned over the portraits (two rows of 46 px from 8 px), one row each (upright:
   centred over the dock); the portal keeps its row also when the cave's button shows (upright it moves up) */
@keyframes landpop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: none; opacity: 1; } }
.land #stage:not(#_) #actbtn, .land #stage:not(#_) #talkbtn, .land #stage:not(#_) #cavebtn, .land #stage:not(#_) #smithbtn,
.land #stage:not(#_) #shopbtn, .land #stage:not(#_) #portalbtn { left: auto; right: calc(var(--sar) + 10px); transform: none; transform-origin: 100% 50%; animation-name: landpop; }
.land #stage:not(#_) #actbtn { bottom: calc(112px + var(--sab)); }
.land #stage:not(#_) #talkbtn, .land #stage:not(#_) #cavebtn, .land #stage:not(#_) #smithbtn { bottom: calc(162px + var(--sab)); }
.land #stage:not(#_) #shopbtn, .land #stage:not(#_) #portalbtn, .land #stage:not(#_) #portalbtn.up { bottom: calc(212px + var(--sab)); }

/* ---- the opening of chapter 1: no dock, no column, the hero alone; the buttons start from the bottom */
.land #stage.prologue:not(#_) #actbtn { bottom: calc(14px + var(--sab)); }
.land #stage.prologue:not(#_) #talkbtn, .land #stage.prologue:not(#_) #cavebtn, .land #stage.prologue:not(#_) #smithbtn { bottom: calc(68px + var(--sab)); }
.land #stage.prologue:not(#_) #party { bottom: calc(8px + var(--sab)); }

/* ---- the hint and the short dialogues: bottom left, over the row of buttons (they are short-lived and on top) */
.land #stage:not(#_) #hint { left: calc(var(--sal) + 10px); right: calc(var(--sar) + 250px); bottom: calc(18px + var(--sab)); }
.land #stage.docked:not(#_) #hint { bottom: calc(100px + var(--sab)); }
.land #stage:not(#_) #dialog { left: calc(var(--sal) + 10px); right: calc(var(--sar) + 170px); bottom: calc(8px + var(--sab)); max-width: 560px; }
/* a tablet sideways has the height for it: the dialogue over the dock, as upright, the dock stays in reach */
@media (min-height: 600px) {
  .land #stage:not(#_) #dialog { left: calc(var(--sal) + 204px); bottom: calc(108px + var(--sab)); }
}

/* ---- test tools (?debug) */
.land #stage:not(#_) #devbtn { left: 50%; top: 8px; bottom: auto; transform: translateX(-50%); }
.land #stage:not(#_) #stats { left: calc(var(--sal) + 232px); right: auto; top: 80px; bottom: auto; }
.land #stage.devopen:not(#_) #bar { left: calc(var(--sal) + 10px); right: calc(var(--sar) + 170px); bottom: calc(8px + var(--sab)); }

/* ---- windows of their own: the cistern's lens (the button under the gear, the glass over the left of the HUD, clear of the
   hero), the chapter gate's window (over the dialogue, not behind it), a puzzle's bench (scrolls if taller than the screen) */
.land #stage:not(#_) #lensbtn { left: auto; right: calc(var(--sar) + 106px); top: 80px; }
.land #stage:not(#_) #lensview { left: calc(var(--sal) + 12px); top: 8px; transform: none; width: min(280px, calc(100dvh - 70px)); }
.land #stage:not(#_) #gatewindow { top: 8px; width: min(340px, calc((100dvh - 160px) * 1.58)); }
.land #stage:not(#_) #puzzlebench .card { max-height: calc(100% - 16px); overflow-y: auto; }

/* ---- sheets: centred, at most 720 px, nearly the whole height */
.land #stage:not(#_) .sheet { max-width: min(720px, calc(100% - var(--sal) - var(--sar) - 16px)); max-height: calc(100% - 8px); margin: 0 auto; }
.land #stage:not(#_) #inv .sheet { max-width: min(560px, calc(100% - var(--sal) - var(--sar) - 16px)); }
/* the backpack's pictures: the hero between his six slots and the two faces of the rank keep a phone's size (they grow with
   the width: in a 560 px sheet the hero alone was taller than the screen) */
.land #stage:not(#_) #inv .equip { grid-template-columns: 76px minmax(0, 210px) 76px; justify-content: center; }
.land #stage:not(#_) #inv .rankcard { grid-template-columns: minmax(0, 170px) 64px minmax(0, 170px); justify-content: center; }
.land #stage:not(#_) #inv .rankcard.max { grid-template-columns: minmax(0, 260px); }
/* the island map and the map of the levels: the picture on the left, as tall as the sheet lets it (it stays while the text
   scrolls), the text on the right */
.land #stage:not(#_) #map .sheet, .land #stage:not(#_) #levels .sheet { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto 1fr; align-items: start; column-gap: 14px; max-width: min(960px, calc(100% - var(--sal) - var(--sar) - 16px)); }
.land #stage:not(#_) #map .sheet > header, .land #stage:not(#_) #levels .sheet > header { grid-column: 1 / -1; }
.land #stage:not(#_) #mapcanvas, .land #stage:not(#_) #levelmap { grid-column: 1; grid-row: 2 / 4; position: sticky; top: 0; margin: 6px 0 0; }
.land #stage:not(#_) #mapcanvas, .land #stage:not(#_) #levelmap svg { width: min(calc(100dvh - 104px - var(--sab)), calc(50vw - 60px)); }
.land #stage:not(#_) #maphere { grid-column: 2; grid-row: 2; margin-top: 6px; text-align: left; }
.land #stage:not(#_) #maplegend { grid-column: 2; grid-row: 3; }
.land #stage:not(#_) #map .sheet > :not(header):not(#mapcanvas):not(#maphere):not(#maplegend) { grid-column: 2; } /* the fast travel's rows (waystones.js) */
.land #stage:not(#_) #leveldetail { grid-column: 2; grid-row: 2 / 4; margin-top: 6px; }
