/* Overlays that sit on top of the canvas, styled as modern pixel art: notched frames drawn by an
   inline SVG nine-slice, chunky bevelled buttons with hard shadows, square controls and dotted
   pixel dividers. Text stays a readable system font. */

:root {
  --ink: #0d0e15;
  --panel: #2a2b38;
  --panel-2: #22232f;
  --bevel: #5a5c74;
  --text-dim: #b7b8c4;
  --green: #3f8f46;
  --green-2: #4aa653;
  --teal: #2b93a8;
  --red: #8f3f3f;
  --gold: #ffd23f;
  --mint: #8cf58c;
}

.overlay {
  position: absolute;
  inset: 0;
  background:
    repeating-conic-gradient(rgba(255, 255, 255, .03) 0 25%, transparent 0 50%) 0 0 / 8px 8px,
    rgba(8, 9, 16, .72);
  display: flex;
  align-items: flex-start;        /* with margin:auto on the panel this centres it, yet lets tall panels scroll */
  justify-content: center;
  padding: 20px;
  line-height: 1.4;
  overflow: auto;
}

/* The frame: outer dark line with cut corners, light bevel, inner dark line, panel fill. A panel
   is a column no taller than the screen: the heading (with the close button) and the foot stay
   put while the middle (.panel-body, see below) scrolls on its own. */
.panel {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  width: min(100%, 520px);
  margin: auto;
  padding: 18px 20px;
  color: #f1f1f1;
  border: 12px solid transparent;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' shape-rendering='crispEdges'%3E%3Cpath fill='%230d0e15' d='M3 0h30v3H3zM0 3h3v30H0zM33 3h3v30h-3zM3 33h30v3H3z'/%3E%3Cpath fill='%235a5c74' d='M3 3h30v3H3zM3 6h3v24H3zM30 6h3v24h-3zM3 30h30v3H3z'/%3E%3Cpath fill='%2318192300' d='M0 0h1v1H0z'/%3E%3Cpath fill='%23181923' d='M6 6h24v3H6zM6 9h3v18H6zM27 9h3v18h-3zM6 27h24v3H6z'/%3E%3Crect x='9' y='9' width='18' height='18' fill='%232a2b38'/%3E%3C/svg%3E") 12 fill stretch;
  filter: drop-shadow(8px 8px 0 rgba(0, 0, 0, .45));
}
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-shrink: 0; }
.panel-foot { flex-shrink: 0; }
/* The scrolling middle of a panel, with a scrollbar in the panel's own style (so a long menu
   reads as one): a dark track and a bevelled thumb, square like everything else here. */
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; margin-right: -12px; padding-right: 12px; scrollbar-width: auto; }
.panel-body::-webkit-scrollbar { width: 12px; height: 12px; display: block; }
.panel-body::-webkit-scrollbar-track { background: var(--ink); border: 2px solid var(--bevel); }
.panel-body::-webkit-scrollbar-thumb { background: var(--bevel); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .2); }
.panel-body::-webkit-scrollbar-thumb:hover { background: #71749a; }
@supports (-moz-appearance: none) { .panel-body { scrollbar-width: thin; scrollbar-color: var(--bevel) var(--ink); } }
/* The mark on every button that plays a rewarded ad: a small screen with a play triangle */
.video-mark {
  display: inline-block;
  width: 16px;
  height: 12px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12' shape-rendering='crispEdges'%3E%3Cpath fill='%230d0e15' d='M0 0h16v12H0z'/%3E%3Cpath fill='%23ffffff' d='M2 2h12v8H2z'/%3E%3Cpath fill='%230d0e15' d='M6 3h1v6H6zM7 4h2v4H7zM9 5h1v2H9z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.panel button.video-btn, .quick.video-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.panel h2 {
  margin: 0;
  flex: 1;
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mint);
  text-shadow: 2px 2px 0 var(--ink);
}
.panel-head .close {
  min-height: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
  font-size: 15px;
  line-height: 1;
  background: #4a4b5e;
}
.panel-head .close:hover:not(:disabled) { background: #7a3f3f; }
.panel .note { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }

/* Buttons: two-tone bevel, hard shadow, presses down. */
.panel button {
  border: 2px solid var(--ink);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: 13px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .22), inset 0 -3px 0 rgba(0, 0, 0, .3), 3px 3px 0 var(--ink);
}
.panel button:hover:not(:disabled) { filter: brightness(1.1); }
.panel button:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .22), inset 0 -3px 0 rgba(0, 0, 0, .3), 1px 1px 0 var(--ink);
}
.panel button:disabled { box-shadow: 3px 3px 0 var(--ink); }
button.secondary { background: #4a4b5e; }
button.danger { background: var(--red); }
button.gem-btn { background: var(--teal); }

/* Dotted pixel dividers */
.divider, .item, .setting, .ach {
  border-top: 0;
  background: repeating-linear-gradient(90deg, var(--bevel) 0 6px, transparent 6px 10px) top / 100% 3px no-repeat;
}


/* Settings rows and pixel controls */
.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 0;
}
.setting label { flex: 1 1 120px; font-weight: 600; }
.setting label .note { margin: 0; font-weight: 400; }
.setting .value { width: 44px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.setting input[type=range] {
  flex: 2 1 140px;
  min-width: 0;
  height: 22px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.setting input[type=range]::-webkit-slider-runnable-track { height: 10px; background: var(--ink); border: 2px solid var(--bevel); }
.setting input[type=range]::-moz-range-track { height: 10px; background: var(--ink); border: 2px solid var(--bevel); }
.setting input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  background: var(--green-2);
  border: 2px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25);
}
.setting input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 0; background: var(--green-2); border: 2px solid var(--ink); }
.setting input[type=checkbox] {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  background: var(--ink);
  border: 3px solid var(--bevel);
  cursor: pointer;
}
.setting input[type=checkbox]:checked { box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 12px var(--green-2); }

/* The save code box: one line of text to copy out or paste in */
.setting.save-code { flex-direction: column; align-items: stretch; gap: 8px; }
.setting.save-code label { flex: none; }
.setting.save-code textarea {
  width: 100%;
  min-height: 52px;
  padding: 6px 8px;
  resize: none;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  color: #f1f1f1;
  background: var(--ink);
  border: 3px solid var(--bevel);
  border-radius: 0;
  word-break: break-all;
}
.setting.save-code textarea:focus { outline: none; border-color: var(--mint); }
.setting.save-code .note { min-height: 1.2em; }

/* The note found in the cavern: a cream sheet with ruled lines, a folded corner and a stamp */
.panel.paper {
  position: relative;
  width: min(100%, 460px);
  padding: 18px 24px 26px;
  border: 4px solid var(--ink);
  border-image: none;
  color: #2b2118;
  background: repeating-linear-gradient(transparent 0 27px, rgba(80, 55, 25, .18) 27px 29px) 0 14px / 100% 100%, #f4ecd3;
  text-align: center;
}
.panel.paper::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 30px;
  height: 30px;
  background: linear-gradient(225deg, #1a1b23 50%, #d9cfae 50%);
  border-left: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
}
.panel.paper h2 { color: #6b4a13; text-shadow: none; }
.paper-line { margin: 10px 0; font-size: 19px; font-style: italic; line-height: 1.5; }
.paper-line.big { font-size: 26px; font-weight: 700; font-style: normal; margin-top: 18px; }
.paper-stamp {
  display: inline-block;
  margin: 18px 0 0;
  padding: 4px 12px;
  border: 3px solid #8f3f3f;
  color: #8f3f3f;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  transform: rotate(-6deg);
}

/* Menu rows: the text keeps the room it needs and the buttons wrap underneath when space is tight. */
.wallet { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.wallet .icon.gem { margin-left: 8px; }
.icon { display: inline-block; width: 12px; height: 12px; flex-shrink: 0; }
.icon.coin { background: #f2c94c; box-shadow: 0 0 0 2px #b9891d; }
.icon.gem { background: #6fe3f2; box-shadow: 0 0 0 2px var(--teal); transform: rotate(45deg) scale(.8); }
.item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 0 10px;
}
.item .item-text { flex: 1 1 200px; min-width: 0; }
.item small { color: var(--text-dim); }
.item button { white-space: nowrap; }
.item-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.item-buttons button { padding: 6px 10px; }
/* The exchange's bundles: equal buttons in a row (two by two on phones), each the amount over
   what it costs or pays, with Sell all across the bottom. The columns may shrink, so the grid
   never grows past the panel. */
.item-buttons.bundles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.item-buttons.bundles button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 7px 6px;
  white-space: normal;
  line-height: 1.2;
}
.item-buttons.bundles button small { font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; color: rgba(255, 255, 255, .85); }
.item-buttons.bundles .all { grid-column: 1 / -1; }
.item-buttons.bundles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 6px; }

/* Shop sections */
.section {
  margin: 14px 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 1px 1px 0 var(--ink);
}
.section small { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px; color: var(--text-dim); text-shadow: none; }

/* Trophies */
.summary { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.ach { display: flex; align-items: center; gap: 10px; padding: 10px 0 8px; opacity: .5; }
.ach.done { opacity: 1; }
.ach > div:nth-child(2) { flex: 1; min-width: 0; }
.ach .mark {
  width: 22px;
  height: 22px;
  background: var(--ink);
  border: 3px solid var(--bevel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.ach.done .mark { background: var(--green-2); border-color: var(--ink); color: #fff; }
.ach .reward { white-space: nowrap; color: #9ff0fa; font-weight: 600; }
.ach small { color: var(--text-dim); }

/* Lock puzzles */
.panel.puzzle { text-align: center; }
.puzzle-grid { display: grid; gap: 8px; justify-content: center; margin: 14px 0; }
.puzzle-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 60px)); }
.puzzle-grid.cols4 { grid-template-columns: repeat(4, minmax(0, 52px)); }
.puzzle-grid.cols5 { grid-template-columns: repeat(5, minmax(0, 46px)); }
.panel .cell.pipe { font-size: 44px; line-height: 1; font-weight: 900; font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; }
.panel .cell {
  height: 52px;
  min-height: 0;
  min-width: 0;
  padding: 0;
  background: #3c3d4d;
  color: #fff;
  font-size: 20px;
}
.puzzle-grid.cols3 .cell { height: 60px; }
.panel .cell.on { background: var(--gold); color: var(--ink); }
.panel .cell.good { background: var(--green-2); }
.panel .cell.lit { background: #6fe3f2; }
.status { margin: 6px 0 0; font-weight: 600; color: var(--text-dim); }

/* Phones, upright or on their side: menus cover the whole screen, keeping out of the notch and the
   home bar. The close button is pinned to the panel's corner, so a long title or a fat wallet wraps
   under the heading instead of pushing it out; settings sliders take a line of their own under
   their label and value; level buttons go three across; the rows of the drill command keep their
   button beside the text. */
@media (max-width: 700px), (max-height: 500px) {
  .overlay {
    position: fixed;
    z-index: 10;
    padding: calc(12px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
  }
  .panel { position: relative; padding: 12px; }
  .panel h2 { font-size: 16px; }
  .panel-head { flex-wrap: wrap; row-gap: 4px; min-height: 36px; padding-right: 48px; }
  .panel:not(.paper) .panel-head .close { position: absolute; top: 12px; right: 12px; }
  .panel-head .wallet { font-size: 14px; }
  .panel-foot { flex-wrap: wrap; }
  .setting input[type=range] { flex: 1 1 100%; order: 3; }
  .setting .value { margin-left: auto; }
  .item .item-text { flex-basis: 150px; }
  .item-buttons.bundles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .puzzle-grid.cols4 { grid-template-columns: repeat(4, minmax(0, 48px)); }
  .puzzle-grid.cols5 { grid-template-columns: repeat(5, minmax(0, 44px)); }
}

/* The flash of light (or of darkness) when the man gets his answer */
.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 12; }
.flash.bright { background: #fff; animation: flash 2.6s ease-out forwards; }
.flash.dark { background: #2a0008; animation: flash 3s ease-out forwards; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* The man's dialogue and the endings */
.ending .panel { text-align: center; }
.ending.lose .panel { filter: drop-shadow(8px 8px 0 rgba(0, 0, 0, .45)) sepia(.5) saturate(.5); }
.ending.win .panel h2 { color: var(--gold); }
.speech { font-size: 16px; line-height: 1.6; margin: 6px 0 10px; }
.speech.big { font-size: 22px; font-weight: 700; margin: 14px 0 18px; }
.ending-foot { justify-content: center; gap: 16px; flex-wrap: wrap; }
.ending-foot button.huge { min-width: 150px; min-height: 60px; font-size: 20px; }
.verse {
  margin: 10px 0;
  padding: 8px 12px;
  text-align: left;
  background: var(--panel-2);
  border-left: 4px solid var(--gold);
  font-style: italic;
}
.verse p { margin: 0 0 4px; }
.verse cite { display: block; font-style: normal; font-weight: 700; color: var(--text-dim); text-align: right; }
.journey { text-align: left; margin: 6px 0; }
.journey .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  background: repeating-linear-gradient(90deg, var(--bevel) 0 6px, transparent 6px 10px) bottom / 100% 2px no-repeat;
}
.journey b { color: var(--mint); white-space: nowrap; }
.credit { margin: 6px 0; }
.credit.title { font-size: 20px; font-weight: 700; color: var(--mint); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 1px; }
.credit.head { margin-top: 14px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.credit.note { font-size: 13px; color: var(--text-dim); }
@media (max-width: 700px) {
  .flash { position: fixed; }
  .ending-foot button.huge { min-width: 120px; }
}

/* Confirmation box */
.panel.confirm { width: min(100%, 420px); text-align: center; }
.confirm-foot { justify-content: center; gap: 16px; }
.confirm-foot button { min-width: 130px; min-height: 46px; }

/* Wider panels for the card grids (shops, building, the camp) */
.panel.wide { width: min(100%, 780px); }

/* Product cards: icon, name, description and the buy button at the bottom, in a grid that
   reflows from three columns on desktop to two (or one) on phones. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 10px;
  margin: 6px 0 4px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--panel-2);
  border: 3px solid var(--bevel);
  box-shadow: 3px 3px 0 var(--ink), inset 0 2px 0 rgba(255, 255, 255, .06);
  min-width: 0;
}
.card.owned { border-color: #2f6a36; }
.card.legend { border-color: #b9891d; box-shadow: 3px 3px 0 var(--ink), inset 0 2px 0 rgba(255, 210, 63, .2); background: linear-gradient(#2b2718, var(--panel-2) 40%); }
.card.legend .card-icon { border-color: #b9891d; }
.card.legend .tag { color: var(--gold); border-color: #b9891d; }
.card.locked { opacity: .62; }
/* The guided start's purchase: the card gets the tutorial's yellow frame and its buy button a
   yellow pixel ring that flashes. */
.card.guide { border-color: #ffe66d; box-shadow: 3px 3px 0 var(--ink), 0 0 12px rgba(255, 230, 109, .35); }
.panel button.guide { outline: 3px solid #ffe66d; outline-offset: 2px; animation: guide-ring .8s steps(1, end) infinite; }
@keyframes guide-ring { 50% { outline-color: rgba(255, 230, 109, .2); } }
@media (prefers-reduced-motion: reduce) { .panel button.guide { animation: none; } }
.card.locked .card-icon .pix { filter: grayscale(1) brightness(.75); }
/* The mission that opens the legendary shelf: a gold-edged note with a progress bar */
.mission {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: var(--ink);
  border: 3px solid #b9891d;
  box-shadow: 3px 3px 0 var(--ink), inset 0 2px 0 rgba(255, 210, 63, .15);
}
.mission strong { font-size: 14px; color: var(--gold); text-transform: uppercase; letter-spacing: .5px; }
.mission small { font-size: 12px; line-height: 1.35; color: var(--text-dim); }
.mission-bar { height: 14px; background: var(--panel-2); border: 2px solid var(--bevel); }
.mission-bar > div { height: 100%; min-width: 2px; background: var(--gold); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .2); }
.mission-count { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-top { display: flex; gap: 10px; align-items: center; }
.card-desc { font-size: 12px; line-height: 1.35; color: var(--text-dim); }
.card-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  border: 2px solid var(--bevel);
}
.card-icon .pix { width: 48px; height: 48px; image-rendering: pixelated; image-rendering: crisp-edges; }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card-text strong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; line-height: 1.25; }
.card-text small { font-size: 12px; line-height: 1.35; color: var(--text-dim); }
.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 1px 5px;
  background: var(--ink);
  color: var(--mint);
  border: 1px solid var(--bevel);
}
.card-foot { margin-top: auto; }
.card-foot button { width: 100%; padding: 6px 8px; }
.item .pix { width: 36px; height: 36px; image-rendering: pixelated; image-rendering: crisp-edges; flex-shrink: 0; }

/* The museum at the top of the trophies: five sets of four relics, the missing ones as silhouettes */
.museum { margin-bottom: 8px; }
.museum-set { padding: 8px 0 6px; background: repeating-linear-gradient(90deg, var(--bevel) 0 6px, transparent 6px 10px) top / 100% 3px no-repeat; }
.museum-title { font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 6px 0; }
.museum-set.done .museum-title { color: var(--mint); }
.museum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.relic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  background: var(--ink);
  border: 2px solid var(--bevel);
  text-align: center;
  opacity: .55;
}
.relic.have { opacity: 1; border-color: #6a5a2a; }
.relic .pix { width: 40px; height: 40px; image-rendering: pixelated; image-rendering: crisp-edges; }
.relic small { font-size: 11px; line-height: 1.2; color: var(--text-dim); }
.relic.have small { color: #f1f1f1; }
@media (max-width: 700px) { .relic .pix { width: 32px; height: 32px; } .relic small { font-size: 10px; } }

/* The daily panel: the streak as seven cells, the quests as rows with a bar, full-width claim buttons */
.streak { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 6px 0 8px; }
.streak-day { padding: 6px 2px; text-align: center; background: var(--panel-2); border: 2px solid var(--bevel); font-size: 10px; line-height: 1.25; color: var(--text-dim); min-width: 0; overflow: hidden; }
.streak-day strong { display: block; font-size: 11px; color: #f1f1f1; }
.streak-day.done { border-color: #2f6a36; background: #1f3a24; }
.streak-day.today { border-color: var(--gold); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(255, 210, 63, .35); }
.streak-day.today strong { color: var(--gold); }
button.full { width: 100%; margin: 2px 0 6px; }
.quest { display: flex; align-items: center; gap: 10px; padding: 10px 0 8px; background: repeating-linear-gradient(90deg, var(--bevel) 0 6px, transparent 6px 10px) top / 100% 3px no-repeat; }
.quest-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.quest-text strong { font-size: 14px; line-height: 1.25; }
.quest-text small { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.quest-bar { height: 8px; background: var(--ink); border: 2px solid var(--bevel); }
.quest-bar > div { height: 100%; background: var(--mint); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3); }
.quest.done { opacity: .6; }
.quest button { flex-shrink: 0; min-width: 84px; }
.quest-buttons { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.quest-buttons button { width: 100%; }
/* The streak's cells: the gem mark before the amount says what the number is; on narrow phones
   the mark goes above it */
.streak-day small { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; }
.streak-day .icon.gem { width: 8px; height: 8px; box-shadow: 0 0 0 1px var(--teal); }
@media (max-width: 480px) { .streak-day small { flex-direction: column; gap: 4px; } }
/* The free-upgrade offer at the top of the shop (portal builds): a teal-edged note with the ad button */
.offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: var(--ink);
  border: 3px solid var(--teal);
  box-shadow: 3px 3px 0 var(--ink), inset 0 2px 0 rgba(111, 227, 242, .15);
}
.offer-text { flex: 1 1 200px; min-width: 0; }
.offer strong { font-size: 14px; color: var(--mint); text-transform: uppercase; letter-spacing: .5px; }
.offer small { font-size: 12px; line-height: 1.35; color: var(--text-dim); }
.offer button { white-space: nowrap; }

/* Lift stops and teleport targets: a grid of level buttons */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.level-grid button { padding: 8px 6px; }
@media (max-width: 700px), (max-height: 500px) {
  .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }   /* three across: half the scrolling */
  .level-grid button { padding: 8px 2px; font-size: 12px; }
}

/* The dialogue box: a narrow speech panel low on the screen, over the running world */
.overlay.dialogue { background: none; align-items: flex-end; padding-bottom: 8%; }
.panel.talk { width: min(100%, 540px); }
.panel.talk h2 { color: #7dd3fc; }
.panel.talk .speech { margin: 4px 0 0; min-height: 3.2em; }

/* The quick bar: the portable shop and the teleporter buttons, bottom-left of the game */
.quick-bar { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 8px; z-index: 7; }
.quick {
  min-height: 0;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  border: 2px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .2), 3px 3px 0 var(--ink);
  opacity: .9;
}
.quick.shop { background: #b7412f; }
.quick.teleport { background: #7c3aed; }
.quick.daily { background: #b9891d; position: relative; }
.quick.boost { background: #c2410c; }
.quick.home { background: #0e7490; }
.quick.video-btn .video-mark { width: 14px; height: 10px; }
.quick:disabled { opacity: .55; }
/* Something waits in the daily panel: a mint dot on the button's corner */
.quick.dot::after { content: ''; position: absolute; top: -5px; right: -5px; width: 10px; height: 10px; background: var(--mint); border: 2px solid var(--ink); }
.quick:hover:not(:disabled) { opacity: 1; filter: brightness(1.1); }
/* Full screen (and a desktop-sized portal frame): the canvas is scaled up, so the quick buttons
   grow with it. --gp is how many screen pixels one game pixel takes (set by Render.resize): three
   on a 1080p screen, where the buttons come out about half as big again as in the page. */
@media (min-width: 701px) and (min-height: 501px) {
  body.fs .quick-bar { left: calc(var(--gp, 2) * 5px); bottom: calc(var(--gp, 2) * 5px); gap: calc(var(--gp, 2) * 4px); }
  body.fs .quick {
    font-size: calc(var(--gp, 2) * 6.5px);
    line-height: 1.15;
    padding: calc(var(--gp, 2) * 4px) calc(var(--gp, 2) * 7px);
    border-width: calc(var(--gp, 2) * 1px);
    box-shadow: inset 0 calc(var(--gp, 2) * 1px) 0 rgba(255, 255, 255, .2), calc(var(--gp, 2) * 1.5px) calc(var(--gp, 2) * 1.5px) 0 var(--ink);
    opacity: 1;
  }
  body.fs .quick.video-btn .video-mark { width: calc(var(--gp, 2) * 7px); height: calc(var(--gp, 2) * 5px); }
  body.fs .quick:disabled { opacity: .55; }
  body.fs .stage:has(.quick-bar:not(.hidden)) .prompt { bottom: calc(var(--gp, 2) * 29px); }
}
/* While the quick bar shows, the prompt sits above it instead of running into it */
.stage:has(.quick-bar:not(.hidden)) .prompt { bottom: 50px; }

@media (max-width: 700px), (max-height: 500px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .card { padding: 8px; gap: 6px; }
  .card-top { gap: 8px; }
  .card-icon { width: 44px; height: 44px; }
  .card-icon .pix { width: 36px; height: 36px; }
  .card-text strong { font-size: 13px; }
  .card-desc { font-size: 11px; }
  .card-foot button { font-size: 12px; padding: 6px 4px; }
  .overlay.dialogue { position: fixed; padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}
/* Phones and other touch screens: bigger quick buttons, easy to hit with a thumb (kept clear of
   the iPhone's notch and home bar); the prompt and the tutorial card move up out of
   their way; every menu button is at least 40px tall, and the keyboard hint goes. */
@media (max-width: 700px), (max-height: 500px), (pointer: coarse) {
  .quick-bar { left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); gap: 10px; }
  .quick { min-height: 38px; padding: 9px 14px; font-size: 13px; }
  .stage:has(.quick-bar:not(.hidden)) .prompt { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .stage:has(.quick-bar:not(.hidden)) .tutorial { bottom: calc(98px + env(safe-area-inset-bottom, 0px)); }
}
@media (pointer: coarse) {
  .panel button { min-height: 40px; }
  .panel-head .close { width: 40px; height: 40px; }
  #fullscreenRow .note { display: none; }
}
