/* Handheld-console styling: a full-bleed pixel screen with translucent controls
   laid over the bottom of it, the way a phone emulator looks. */

:root {
  --shell: #0b0f0a;
  --ink: #10240f;
  --paper: #f8f8e8;
  --line: #303830;
  --accent: #6ab04c;
  --accent-dim: #4a8a3c;
  --danger: #c85858;
  --control: rgba(232, 240, 224, 0.34);
  --control-edge: rgba(16, 24, 16, 0.35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--shell);
  color: var(--paper);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #050704;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0d1a0c;
  touch-action: none;
}

/* ---------------------------------------------------------------- controls */

/* Every size here is in vw or fixed pixels, never vmax.
   vmax on a portrait phone is the *height*, so sizing a horizontal control row
   from it made the buttons grow with the length of the screen — which is how
   the A button, the one that picks up every relic, came to sit 66 pixels off
   the right edge of a 360px phone. */
.controls {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0 max(12px, 3vw) calc(max(10px, 1.6vh) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: max(8px, 1.2vh);
  pointer-events: none;
  z-index: 5;
}

/* The thumbs get the full width to themselves. */
.pad-row {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.controls button {
  pointer-events: auto;
  border: 2px solid var(--control-edge);
  background: var(--control);
  color: rgba(12, 20, 12, 0.75);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: transform 60ms ease, background-color 60ms ease;
}

.controls button:active,
.controls button.held {
  background: rgba(255, 255, 255, 0.62);
  transform: scale(0.94);
}

/* D-pad: a plus shape built from a 3x3 grid. */
.dpad {
  /* Sized so one arm is never under ~42px: the pad is three arms across, and
     a 92px pad meant 31px arms, which is smaller than a thumb. */
  --pad: clamp(126px, 32vw, 144px);
  width: var(--pad);
  height: var(--pad);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  flex: none;
}

.dpad-btn {
  border-radius: 4px;
}

.dpad-btn.up {
  grid-area: 1 / 2;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.dpad-btn.left {
  grid-area: 2 / 1;
  border-right: none;
  border-radius: 8px 0 0 8px;
}
.dpad-btn.centre {
  grid-area: 2 / 2;
  border-width: 0;
  border-radius: 0;
  pointer-events: none;
}
.dpad-btn.right {
  grid-area: 2 / 3;
  border-left: none;
  border-radius: 0 8px 8px 0;
}
.dpad-btn.down {
  grid-area: 3 / 2;
  border-top: none;
  border-radius: 0 0 8px 8px;
}

.dpad-btn.up::after,
.dpad-btn.down::after,
.dpad-btn.left::after,
.dpad-btn.right::after {
  content: "";
  display: block;
  margin: auto;
  width: 0;
  height: 0;
  border: clamp(6px, 2.2vw, 11px) solid transparent;
}
.dpad-btn.up::after {
  border-bottom-color: rgba(12, 20, 12, 0.55);
  margin-bottom: 2px;
}
.dpad-btn.down::after {
  border-top-color: rgba(12, 20, 12, 0.55);
  margin-top: 2px;
}
.dpad-btn.left::after {
  border-right-color: rgba(12, 20, 12, 0.55);
  margin-right: 2px;
}
.dpad-btn.right::after {
  border-left-color: rgba(12, 20, 12, 0.55);
  margin-left: 2px;
}

.system {
  display: flex;
  gap: clamp(10px, 3vw, 20px);
}

.system-btn {
  border-radius: 999px;
  padding: 11px clamp(16px, 4vw, 26px);
  font-size: clamp(10px, 2.6vw, 13px);
  letter-spacing: 0.06em;
}

.face {
  display: flex;
  align-items: flex-end;
  gap: clamp(10px, 3vw, 22px);
  flex: none;
}

.face-btn {
  width: clamp(50px, 15vw, 68px);
  height: clamp(50px, 15vw, 68px);
  border-radius: 50%;
  font-size: clamp(13px, 4vw, 20px);
}

.face-btn.b {
  margin-bottom: clamp(12px, 4vw, 28px);
}

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 4vmin;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(28, 46, 24, 0.9), rgba(5, 7, 4, 0.97)),
    #050704;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: min(560px, 100%);
  background: #101a0e;
  border: 3px solid var(--accent-dim);
  border-radius: 10px;
  box-shadow: 0 0 0 3px #050704, 0 18px 50px rgba(0, 0, 0, 0.6);
  padding: clamp(16px, 3vmin, 28px);
  margin: auto;
}

.panel-head h1 {
  margin: 0 0 6px;
  font-size: clamp(26px, 6vmin, 44px);
  letter-spacing: 0.14em;
  color: var(--accent);
  text-shadow: 0 3px 0 #050704;
}

.tagline {
  margin: 0 0 20px;
  font-size: clamp(12px, 1.7vmax, 14px);
  line-height: 1.55;
  color: #b8c8ac;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fae7f;
}

#place-input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--paper);
  background: #060a05;
  border: 2px solid #2f4a2a;
  border-radius: 6px;
}

#place-input:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: #7d8f73;
}

.hint code,
.note code {
  background: #060a05;
  padding: 1px 4px;
  border-radius: 3px;
  color: #a8c898;
}

/* ------------------------------------------------------ the one big button */

/* The loudest thing on the screen, because it is the only thing the game is
   actually for. Everything else on the title screen is a way of not doing it. */

.play-here {
  margin-bottom: 18px;
}

.play-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  font: inherit;
  text-align: left;
  color: #071006;
  background: linear-gradient(180deg, #7dc659, var(--accent));
  border: 0;
  border-radius: 10px;
  box-shadow: 0 3px 0 #2f5c22;
  cursor: pointer;
  transition: filter 120ms ease, transform 60ms ease, box-shadow 60ms ease;
}

.play-btn:hover:not([disabled]),
.play-btn:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.play-btn:active:not([disabled]) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #2f5c22;
}

.play-btn[disabled] {
  cursor: progress;
  filter: saturate(0.4) brightness(0.8);
}

.play-btn-text {
  display: block;
}

.play-btn-text b {
  display: block;
  font-size: clamp(15px, 4vw, 18px);
  letter-spacing: 0.08em;
}

.play-btn-text small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: #163a0d;
}

.play-btn .locate-pin {
  border-color: #0d2408;
  width: 14px;
  height: 14px;
}

/* One line, not a bordered block with a paragraph in it: the toggle is a
   preference, and it was taking up more of the screen than the game. */
.race-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: #b8c8ac;
  cursor: pointer;
}

.race-line input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  flex: none;
}

.race-line b {
  display: block;
  font-weight: 400;
}

.race-line small {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  color: #7d8f73;
}

/* --------------------------------------------------------- folded away bits */

.fold {
  border-top: 1px solid #23331f;
  padding: 12px 0;
}

.fold > summary {
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #9db08f;
  list-style-position: inside;
}

.fold > summary:hover {
  color: #c8d8bc;
}

.fold[open] > summary {
  margin-bottom: 14px;
  color: #c8d8bc;
}

/* A map pin, drawn rather than shipped as an icon. */
.locate-pin {
  flex: none;
  position: relative;
  width: 12px;
  height: 12px;
  border: 3px solid var(--accent);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.locate-btn[disabled] .locate-pin {
  animation: pulse 900ms ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.locate-status {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: #7d8f73;
  min-height: 1em;
}

.locate-status.is-error {
  color: #e8a0a0;
}

.presets {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}

.presets legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fae7f;
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.preset {
  text-align: left;
  padding: 9px 11px;
  font: inherit;
  font-size: 12px;
  color: var(--paper);
  background: #16240f;
  border: 2px solid #2f4a2a;
  border-radius: 6px;
  cursor: pointer;
}

.preset:hover,
.preset:focus-visible {
  border-color: var(--accent);
  background: #1d3014;
  outline: none;
}

.preset b {
  display: block;
  margin-bottom: 3px;
  font-weight: 700;
}

.preset span {
  color: #8b9d80;
  font-size: 11px;
  line-height: 1.4;
}

.advanced {
  margin-bottom: 18px;
  font-size: 13px;
  color: #b8c8ac;
}

.advanced summary {
  cursor: pointer;
  padding: 6px 0;
  color: #8fae7f;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* A slider the ground is deciding instead of you. Faded rather than hidden, so
   it is clear what is not being asked rather than looking like it moved. */
.row.inactive {
  opacity: 0.45;
}

.row-note {
  margin: 4px 0 2px;
  font-size: 0.82rem;
  line-height: 1.4;
  opacity: 0.72;
}

.row output {
  min-width: 2.5em;
  text-align: right;
  color: var(--accent);
}

.note {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: #7d8f73;
}

/* Says where a level's terrain comes from. Quiet when the answer is "real
   imagery", clearly flagged when it is not, because a generated level looks
   exactly as convincing as a real one. */
.source-note {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-radius: 6px;
  border: 2px solid transparent;
}

.source-note.is-invented {
  color: #f0dca8;
  background: rgba(200, 160, 60, 0.12);
  border-color: #8a6f28;
}

.start-btn {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #06120a;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  box-shadow: 0 4px 0 #2f6a26;
  cursor: pointer;
}

.start-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #2f6a26;
}

.start-btn[disabled] {
  opacity: 0.55;
  cursor: progress;
}

.error {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #ffd8d8;
  background: rgba(200, 88, 88, 0.16);
  border: 2px solid var(--danger);
  border-radius: 6px;
}

.panel-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #24361f;
  font-size: 11px;
  color: #6f8166;
  text-align: center;
}

/* ---------------------------------------------------------------- loading  */

.loader {
  text-align: center;
  max-width: 420px;
}

.loader-art {
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  background:
    linear-gradient(#f8e058 0 0) 28px 20px / 16px 32px no-repeat,
    linear-gradient(#f8e058 0 0) 20px 28px / 32px 16px no-repeat,
    #6ab04c;
  border: 4px solid #2f6a26;
  border-radius: 8px;
  animation: bob 900ms ease-in-out infinite alternate;
}

@keyframes bob {
  from {
    transform: translateY(-4px) rotate(-3deg);
  }
  to {
    transform: translateY(4px) rotate(3deg);
  }
}

#loading-text {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.loader-sub {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: #7d8f73;
}

@media (prefers-reduced-motion: reduce) {
  .loader-art {
    animation: none;
  }
  .controls button {
    transition: none;
  }
}

/* ------------------------------------------------------------------ racing */

.race {
  border: 1px solid rgba(140, 200, 120, 0.22);
  border-radius: 8px;
  padding: 12px;
  background: rgba(20, 40, 24, 0.35);
  display: grid;
  gap: 12px;
}

.race-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.race-toggle input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #6ab04c;
  flex: none;
}

.race-toggle b {
  display: block;
  font-size: 0.95rem;
}

.race-toggle small {
  display: block;
  margin-top: 3px;
  color: #9db08f;
  line-height: 1.45;
}

/* Hidden rather than disabled when racing is off: an empty name box beside an
   unticked box is a question nobody has been asked. */
.race-name[hidden] {
  display: none;
}

.race-name input {
  text-transform: uppercase;
}

/* ------------------------------------------------------------- language */

/* Top right of the panel, above the title: a control you use once and then
   never look for again, so it gets the corner rather than a row of its own. */
.langbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -6px;
}

.langbar select {
  padding: 4px 8px;
  border: 1px solid rgba(160, 200, 140, 0.3);
  border-radius: 6px;
  background: rgba(20, 32, 22, 0.8);
  color: #9db08f;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.langbar select:hover,
.langbar select:focus-visible {
  border-color: rgba(160, 200, 140, 0.7);
  color: #c8d8bc;
}

/* --------------------------------------------------------- today's place */

.daily {
  margin-bottom: 18px;
}

.daily-btn {
  width: 100%;
  display: block;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid rgba(240, 192, 64, 0.45);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(240, 192, 64, 0.16), rgba(240, 192, 64, 0.06));
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.daily-btn:hover,
.daily-btn:focus-visible {
  border-color: rgba(240, 192, 64, 0.9);
  background: linear-gradient(180deg, rgba(240, 192, 64, 0.26), rgba(240, 192, 64, 0.1));
}

.daily-tag {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: #f0c040;
}

.daily-btn b {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.daily-note {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  color: #9db08f;
}

/* ------------------------------------------------------- an unfinished run */

/* Green rather than the daily's gold. Two big offers stacked in the same colour
   read as one control with two halves, and these do quite different things. */

.resume {
  margin-bottom: 18px;
}

.resume-btn {
  width: 100%;
  display: block;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid rgba(140, 200, 120, 0.45);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(140, 200, 120, 0.16), rgba(140, 200, 120, 0.06));
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.resume-btn:hover,
.resume-btn:focus-visible {
  border-color: rgba(140, 200, 120, 0.9);
  background: linear-gradient(180deg, rgba(140, 200, 120, 0.26), rgba(140, 200, 120, 0.1));
}

.resume-tag {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: #8cc878;
}

.resume-btn b {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.resume-note {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  color: #9db08f;
}

/* Deliberately small and plain: throwing the run away is the rarer choice, and
   it is the one that cannot be undone. */
.resume-drop {
  display: block;
  margin: 8px auto 0;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: #7c8b72;
  font: inherit;
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
}

.resume-drop:hover,
.resume-drop:focus-visible {
  color: #c8d8bc;
}

/* ---------------------------------------------------------------- sharing */

/* The postcard is the point of the screen, so it gets the room and everything
   else is sized around whatever is left. */
.share-panel {
  width: min(420px, 100%);
  margin: auto;
  padding: clamp(14px, 3vmin, 22px);
  background: #101a0e;
  border: 3px solid var(--accent-dim);
  border-radius: 10px;
  box-shadow: 0 0 0 3px #050704, 0 18px 50px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.share-panel h2 {
  margin: 0 0 12px;
  font-size: clamp(18px, 4vmin, 24px);
  letter-spacing: 0.16em;
  color: #f0c040;
  text-shadow: 0 2px 0 #050704;
}

.share-card img {
  display: block;
  width: 100%;
  max-width: 270px;
  margin: 0 auto;
  /* The card is pixel art scaled by a whole number; letting the browser
     smooth it undoes the entire reason it is drawn that way. */
  image-rendering: pixelated;
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.share-text {
  margin: 14px 0 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cfe0c2;
  background: #0a1208;
  border: 1px solid #2a3a26;
  border-radius: 6px;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.share-btn {
  flex: 1 1 30%;
  padding: 11px 8px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: #16240f;
  border: 2px solid #2f4a2a;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.share-btn:hover,
.share-btn:focus-visible {
  border-color: var(--accent);
  background: #1d3014;
  outline: none;
}

.share-btn.primary {
  flex-basis: 100%;
  color: #12240c;
  background: var(--accent);
  border-color: var(--accent);
}

.share-btn.primary:hover,
.share-btn.primary:focus-visible {
  background: #7cc45a;
}

.share-networks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.share-networks a {
  flex: 1 1 auto;
  padding: 9px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #b8c8ac;
  text-decoration: none;
  background: #0d1509;
  border: 1px solid #26361f;
  border-radius: 6px;
}

.share-networks a:hover,
.share-networks a:focus-visible {
  color: var(--paper);
  border-color: var(--accent);
  outline: none;
}

.share-status {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.76rem;
  color: #f0c040;
}

.share-close {
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  font: inherit;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: #8fae7f;
  background: none;
  border: none;
  cursor: pointer;
}

.share-close:hover,
.share-close:focus-visible {
  color: var(--paper);
  outline: none;
}

/* The joke in the tagline is the name, so it gets to be the loud part. */
.tagline b {
  color: var(--accent);
}

/* ------------------------------------------------------- where it is kept */

.account {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #24331f;
  font-size: 0.78rem;
  color: #9db08f;
}

.account-line {
  margin: 0 0 6px;
}

.account-more summary {
  cursor: pointer;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.account-hint {
  margin: 10px 0;
  line-height: 1.5;
}

.account-code {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.account-code code {
  flex: 1;
  padding: 9px 10px;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  color: #f0c040;
  background: #0a1208;
  border: 1px solid #2a3a26;
  border-radius: 6px;
  /* Long enough to overflow a narrow phone, and a code you cannot read all of
     is a code you cannot write down. */
  overflow-x: auto;
}

.account-code button,
.account-btn {
  padding: 9px 12px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: #16240f;
  border: 2px solid #2f4a2a;
  border-radius: 6px;
  cursor: pointer;
}

.account-btn {
  width: 100%;
  margin-top: 8px;
}

.account-code button:hover,
.account-btn:hover,
.account-code button:focus-visible,
.account-btn:focus-visible {
  border-color: var(--accent);
  background: #1d3014;
  outline: none;
}

.account-status {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: #f0c040;
}

/* The number you stand to lose. Loud on purpose — that is the whole mechanic. */
.daily-streak {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f0a040;
}

.daily-streak[hidden] {
  display: none;
}
