:root {
  --ink: #f3e3c0;
  --stone: #1b1712;

  /* How much room under the canvas belongs to the controls line rather than to
   * the game. It used to be a flat 70px, which was true while that line was
   * always one row of text; the share buttons sit on the same line and push it
   * onto a second row on a mid-width screen, and a flat number cannot know
   * that. So the line measures itself - js/share.js writes --hint-height - and
   * this asks for whatever it actually needs plus the margin that made the
   * game look centred rather than jammed against the bottom.
   *
   * The floor is the old 70px, so on every screen wide enough to keep the line
   * on one row this is still exactly 70 and the canvas is the size it always
   * was. It only ever gives up more, and only when the line has actually taken
   * more. --hint-height's own fallback is one row, for the moment before the
   * measurement lands and for a browser with no ResizeObserver. */
  --chrome-height: max(70px, calc(var(--hint-height, 22px) + 48px));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0806;
  background-image:
    radial-gradient(ellipse at 50% -10%, #2a1f16 0%, #0a0806 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 2px, transparent 2px 4px);
  color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace;
  overflow: hidden;
}

/* The page heading and the description of the game. Present for search engines
 * and screen readers, taken off screen for everybody else - there is nowhere on
 * a full-bleed game screen to put a paragraph. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Said only when JavaScript is off, when it has the screen to itself. */
.noscript-note {
  max-width: 46ch;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #a58f68;
  text-align: center;
}

#frame {
  position: absolute;
  /* The cookie banner is fixed across the bottom, so the screen the game is
   * centred in is the screen above it - shrinking the canvas alone would only
   * centre a smaller game in the same space and leave the controls line under
   * the bar. --cookies-height is 0 the rest of the time. */
  inset: 0 0 var(--cookies-height, 0px) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

canvas#game {
  display: block;
  /* --chrome-height is the controls line under it - see :root at the top of
   * this file, where it works out to the old flat 70px on any screen that
   * keeps that line on one row. --cookies-height is however tall the cookie
   * banner actually is right now, measured by js/consent.js and 0 once the
   * question has been answered - so the game gives up exactly the room the
   * banner takes and takes it straight back afterwards. */
  width: min(96vw, calc((100vh - var(--chrome-height) - var(--cookies-height, 0px)) * 1.6667));
  height: auto;
  aspect-ratio: 960 / 576;
  image-rendering: pixelated;
  border: 3px solid #4a3a26;
  border-radius: 3px;
  background: #0d0a08;
  box-shadow:
    0 0 0 1px #241a12,
    0 18px 60px rgba(0, 0, 0, .8),
    0 0 90px rgba(255, 150, 40, .07);
}

#hint {
  display: flex;
  align-items: center;
  justify-content: center;
  /* The share row sits on this line rather than under it, which is what keeps
   * it from costing the canvas any height on a screen wide enough to hold both
   * on one row. Where it is not wide enough this wraps - the controls text and
   * the marks taking a row each - and the canvas gives up the difference,
   * because --chrome-height at the top of this file is measured rather than
   * guessed. Without the wrap the marks would simply be pushed off the side. */
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  letter-spacing: .5px;
  color: #6b5b45;
  text-align: center;
  padding: 0 10px;
  user-select: none;
}

/* --------------------------------------------------------- the info button */

#info-btn {
  flex: none;
  width: 22px;
  height: 22px;
  border: 1px solid #5c4930;
  border-radius: 50%;
  background: #17120d;
  color: #a58f68;
  font: bold 13px "Courier New", ui-monospace, monospace;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color .15s, border-color .15s, box-shadow .15s;
}

#info-btn:hover,
#info-btn:focus-visible {
  color: #f3e3c0;
  border-color: #a8804a;
  box-shadow: 0 0 12px rgba(255, 150, 40, .25);
  outline: none;
}

/* ------------------------------------------------------- the share buttons */

/* The row of platform marks beside the ⓘ. They are the same 22px circle as the
 * info button on purpose: this is a game screen, and a strip of full-colour
 * brand badges under it would be the loudest thing on the page by some
 * distance. So they sit in the castle's own palette and only take their own
 * colour when you are on one - which is also the moment the colour is doing
 * something, telling you which platform you are about to open. */

#share {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Both of these are needed because the display rules here and on .share-btn
 * below are more specific than the browser's own `[hidden] { display: none }`,
 * and would quietly win: the row would be up before js/share.js had pointed it
 * anywhere, and the share-sheet button - hidden in the markup and unhidden
 * only where the browser has a sheet - would be on every desktop, doing
 * nothing when pressed. */
#share[hidden] { display: none; }
.share-btn[hidden] { display: none; }

.share-label {
  color: #5a4c3a;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 10.5px;
}

.share-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #4a3a26;
  border-radius: 50%;
  background: #17120d;
  color: #8a7355;
  cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .15s, background .15s;
}

.share-btn svg {
  display: block;
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* The two that are not brand marks - the share sheet and the link - are drawn
 * rather than filled, so they need the opposite treatment. */
.share-btn svg.line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Each platform's own colour, lifted a little off the official one so it still
 * reads against a dark screen. Only ever seen on hover and focus. */
.share-btn[data-share="x"] { --brand: #f3f3f3; }
.share-btn[data-share="bluesky"] { --brand: #4aa3ff; }
.share-btn[data-share="facebook"] { --brand: #4f8dff; }
.share-btn[data-share="reddit"] { --brand: #ff6a33; }
.share-btn[data-share="whatsapp"] { --brand: #3ddc7f; }
.share-btn[data-share="telegram"] { --brand: #45b6ee; }

.share-btn:hover,
.share-btn:focus-visible {
  color: var(--brand, #f3e3c0);
  border-color: currentColor;
  background: #1f180f;
  /* The same warm glow everything else on this screen gets, rather than one in
   * the brand colour - the castle is still the thing lighting this page. */
  box-shadow: 0 0 12px rgba(255, 150, 40, .25);
  outline: none;
}

/* Copied. js/share.js sets this for a moment and then takes it off again; the
 * tick is in the same SVG as the link, so nothing has to be swapped out. */
.share-done-icon { display: none; }

.share-btn[data-copied] { color: #ffd479; border-color: currentColor; }
.share-btn[data-copied] .share-link-icon { display: none; }
.share-btn[data-copied] .share-done-icon { display: block; }

/* Narrow enough that the controls line has already wrapped: the word is the
 * first thing to go, since seven platform marks in a row are not ambiguous. */
@media (max-width: 620px) {
  .share-label { display: none; }
}

/* ------------------------------------------------------- the about overlay */

#about {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

#about.hidden { display: none; }

#about-scrim {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 4, .82);
}

#about-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 30px 34px 26px;
  border: 3px solid #4a3a26;
  border-radius: 3px;
  background: radial-gradient(ellipse at 50% -20%, #241a12 0%, #120e0a 65%);
  box-shadow:
    0 0 0 1px #241a12,
    0 18px 60px rgba(0, 0, 0, .85),
    0 0 90px rgba(255, 150, 40, .06);
  color: #bfae8c;
  font-size: 14px;
  line-height: 1.65;
  outline: none;
}

#about-panel::-webkit-scrollbar { width: 10px; }
#about-panel::-webkit-scrollbar-track { background: #0f0c09; }
#about-panel::-webkit-scrollbar-thumb { background: #3d2f1f; border-radius: 5px; }

#about-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  color: #7d6b4f;
  font: 22px "Courier New", ui-monospace, monospace;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

#about-close:hover,
#about-close:focus-visible {
  color: #f3e3c0;
  border-color: #5c4930;
  outline: none;
}

#about-title {
  margin: 0;
  font-size: 26px;
  letter-spacing: 3px;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(255, 150, 40, .18);
}

.about-lede {
  margin: 10px 0 0;
  color: #9d8f76;
}

.about-block {
  margin-top: 26px;
  border-top: 1px solid #2c2318;
  padding-top: 16px;
}

.about-block h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #d8a75a;
}

.about-block p { margin: 0 0 10px; }
.about-block p:last-child { margin-bottom: 0; }

.about-aside {
  color: #8a7b62;
  font-size: 13px;
}

/* --- controls --- */

.about-keys {
  border-collapse: collapse;
  width: 100%;
  max-width: 470px;
}

.about-keys th {
  text-align: left;
  color: #e8dcc0;
  white-space: nowrap;
  padding: 2px 18px 2px 0;
  vertical-align: top;
}

.about-keys td {
  padding: 2px 0;
  color: #9d8f76;
}

/* --- chests --- */

.about-chests {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin-top: 14px;
}

.about-chests > div {
  flex: 1 1 260px;
  min-width: 0;
}

.about-chests h3 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.about-chests h3.good { color: #ffd479; }
.about-chests h3.bad { color: #d8544a; }

.about-chests ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.about-chests li {
  margin-bottom: 7px;
  font-size: 13px;
  line-height: 1.45;
}

.about-chests li b {
  display: block;
  letter-spacing: 1px;
  color: #e8dcc0;
}

.about-chests li span { color: #8a7b62; }

/* --- traps --- */

.about-refusal {
  font-size: 30px;
  letter-spacing: 4px;
  color: #d8544a;
  margin: 4px 0 12px;
}

.about-dismiss {
  margin: 22px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #5f5140;
}

@media (max-width: 560px) {
  #about-panel { padding: 26px 20px 22px; font-size: 13px; }
  #about-title { font-size: 20px; }
}

/* ------------------------------------------------------ the cookie banner */

/* Up only until the question is answered - js/consent.js clears `hidden` while
 * it is open and sets it again once it is not. It sits over the bottom of the
 * screen rather than in the flow, and publishes its own height as
 * --cookies-height so the frame and the canvas near the top of this file give
 * up exactly that much and no more. */

#cookies {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  border-top: 2px solid #4a3a26;
  background: linear-gradient(180deg, rgba(18, 14, 10, .97) 0%, rgba(10, 8, 6, .99) 100%);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .6);
}

.cookies-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 26px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 20px;
}

.cookies-text {
  flex: 1 1 380px;
  margin: 0;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: #9d8f76;
}

.cookies-text b {
  color: #d8a75a;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 11.5px;
}

.cookies-buttons {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* The two answers are the same size and the same weight on purpose. A Decline
 * dressed as a footnote beside a glowing Accept is not a question. */
.cookies-buttons button {
  min-width: 104px;
  padding: 9px 16px;
  border: 1px solid #5c4930;
  border-radius: 3px;
  background: #17120d;
  color: #e8dcc0;
  font: 12px/1 "Courier New", ui-monospace, monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .15s, background .15s;
}

.cookies-buttons button:hover,
.cookies-buttons button:focus-visible {
  color: #fff4d8;
  border-color: #a8804a;
  background: #1f180f;
  box-shadow: 0 0 12px rgba(255, 150, 40, .22);
  outline: none;
}

.cookies-link {
  font-size: 12px;
  letter-spacing: .5px;
  color: #8a7b62;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cookies-link:hover,
.cookies-link:focus-visible {
  color: #f3e3c0;
  outline: none;
}

/* The banner is fixed to the bottom, so it would sit over the controls line if
 * nothing gave way. What gives way is the canvas: js/consent.js measures the
 * banner and publishes --cookies-height, which the canvas rule near the top of
 * this file subtracts. On a narrow screen the banner wraps and gets taller,
 * and the canvas gets correspondingly smaller, with nothing here to keep in
 * step with it. */

@media (max-width: 700px) {
  .cookies-inner { padding: 12px 14px; gap: 10px 14px; }
  .cookies-text { flex-basis: 100%; font-size: 12px; }
  .cookies-buttons { flex-wrap: wrap; justify-content: center; width: 100%; }
}

/* --------------------------------- the cookie controls in the about overlay */

.about-consent {
  margin: 12px 0 10px;
  color: #d8a75a;
  font-size: 13px;
}

.about-consent-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0;
}

.about-consent-buttons button {
  padding: 7px 14px;
  border: 1px solid #5c4930;
  border-radius: 3px;
  background: #17120d;
  color: #e8dcc0;
  font: 11.5px/1 "Courier New", ui-monospace, monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .15s, background .15s;
}

.about-consent-buttons button:hover:not(:disabled),
.about-consent-buttons button:focus-visible:not(:disabled) {
  color: #fff4d8;
  border-color: #a8804a;
  background: #1f180f;
  box-shadow: 0 0 12px rgba(255, 150, 40, .22);
  outline: none;
}

/* The answer you already gave. Still readable, plainly not a thing to press. */
.about-consent-buttons button:disabled {
  color: #6b5b45;
  border-color: #2c2318;
  background: #100c09;
  cursor: default;
}

.about-consent-buttons a {
  color: #8a7b62;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about-consent-buttons a:hover,
.about-consent-buttons a:focus-visible { color: #f3e3c0; outline: none; }

/* ------------------------------------------------------ the written pages */

/* cookies.html and anything else that is prose rather than a game screen. The
 * game body is a fixed, unscrollable full-bleed screen; a page of text is the
 * opposite of that, so it undoes it. */

/* Both halves, and this is the whole point of the rule: the game locks the
 * page down with `html, body { height: 100%; overflow: hidden }`, and an
 * overflow of hidden on the root element is handed to the viewport itself.
 * Undoing it on the body alone leaves the root still clipping - the page then
 * scrolls to window.scrollTo and not to a finger or a wheel, which looks fine
 * from a script and is completely broken to read. */
html.doc,
body.doc {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

.doc-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 46px 22px 70px;
  color: #bfae8c;
  font-size: 14px;
  line-height: 1.7;
}

.doc-main h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 3px;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(255, 150, 40, .18);
}

.doc-lede {
  margin: 0;
  color: #9d8f76;
}

.doc-back {
  display: inline-block;
  margin-bottom: 22px;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #8a7b62;
  text-decoration: none;
}

.doc-back:hover, .doc-back:focus-visible { color: #f3e3c0; outline: none; }

.doc-block {
  margin-top: 28px;
  border-top: 1px solid #2c2318;
  padding-top: 16px;
}

.doc-block h2 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #d8a75a;
}

.doc-block p { margin: 0 0 12px; }
.doc-block p:last-child { margin-bottom: 0; }

/* Scoped to the page rather than to a block, so the footer and the choice box
 * get them too - a link that styles itself only inside one section is a link
 * that turns up browser-purple somewhere else. */
.doc-main strong { color: #e8dcc0; }

.doc-main code {
  font-family: "Courier New", ui-monospace, monospace;
  color: #e8dcc0;
  background: #17120d;
  border: 1px solid #2c2318;
  border-radius: 2px;
  padding: 0 4px;
}

.doc-main a { color: #d8a75a; text-underline-offset: 3px; }
.doc-main a:hover, .doc-main a:focus-visible { color: #f3e3c0; outline: none; }

.doc-table {
  border-collapse: collapse;
  width: 100%;
  margin: 4px 0 14px;
  font-size: 13px;
}

.doc-table th, .doc-table td {
  text-align: left;
  vertical-align: top;
  padding: 6px 14px 6px 0;
  border-bottom: 1px solid #221b13;
}

.doc-table th { color: #e8dcc0; white-space: nowrap; }
.doc-table td { color: #9d8f76; }

.doc-table--wrap th { white-space: normal; }

.doc-choice {
  border: 2px solid #4a3a26;
  border-radius: 3px;
  background: radial-gradient(ellipse at 50% -40%, #241a12 0%, #120e0a 70%);
  padding: 18px 20px;
  margin-top: 28px;
}

.doc-choice h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #d8a75a;
}

.doc-choice-note {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: #8a7b62;
}

.doc-choice-note + .doc-choice-note { margin-top: 10px; }

.doc-foot {
  margin-top: 34px;
  border-top: 1px solid #2c2318;
  padding-top: 14px;
  font-size: 12px;
  color: #5f5140;
}

.doc-foot code { font-size: 11.5px; }

/* The one link that is not part of the prose - it is a way out, and reads as
 * one rather than as another thing in the sentence. */
.doc-main a.doc-back { color: #8a7b62; text-decoration: none; }
.doc-main a.doc-back:hover, .doc-main a.doc-back:focus-visible { color: #f3e3c0; }

@media (max-width: 560px) {
  .doc-main { padding: 30px 16px 50px; font-size: 13px; }
  .doc-main h1 { font-size: 20px; }
}
