@font-face {
  font-family: "Nunito";
  src: url("assets/fonts/Nunito.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: block;
}

@font-face {
  font-family: "PressStart";
  src: url("assets/fonts/PressStart2P.woff2") format("woff2");
  font-display: block;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #120c09;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0 0 46px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #000;
}

/* On-screen controls: only shown on touch devices. */
#touch { display: none; }

body.touch #stage {
  align-items: flex-start;
  padding-top: env(safe-area-inset-top);
}

body.touch #touch {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42vh;
  pointer-events: none;
}

#touch button {
  pointer-events: auto;
  position: absolute;
  border: 2px solid rgba(232, 184, 74, 0.55);
  background: rgba(20, 12, 24, 0.38);
  color: rgba(243, 234, 216, 0.9);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  font: 14px "PressStart", monospace;
  border-radius: 10px;
  padding: 0;
}

#touch button.down-state { background: rgba(232, 184, 74, 0.55); color: #140d0a; }

.dpad {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: calc(50px + env(safe-area-inset-bottom));
  width: 156px;
  height: 156px;
}

.dpad button { width: 52px; height: 52px; }
.dpad .up { left: 52px; top: 0; }
.dpad .down { left: 52px; top: 104px; }
.dpad .left { left: 0; top: 52px; }
.dpad .right { left: 104px; top: 52px; }

.ab {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(62px + env(safe-area-inset-bottom));
  width: 150px;
  height: 120px;
}

.ab button { width: 64px; height: 64px; border-radius: 50%; }
.ab .a { right: 0; top: 0; background: rgba(192, 40, 45, 0.42); }
.ab .b { left: 0; top: 48px; }

#touch .menu {
  left: 50%;
  transform: translateX(-50%);
  top: 10px;
  width: 92px;
  height: 34px;
  font-size: 10px;
}

/* End-of-game reward card (HTML so the code can be selected and copied). */
#reward {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 6, 20, 0.96);
  font-family: "PressStart", monospace;
  -webkit-user-select: text; user-select: text;
  padding: 16px;
}
#reward[hidden] { display: none; }
#reward .card {
  width: min(460px, 100%);
  background: #1e1428; color: #f3ead8;
  border: 3px solid #e8b84a; box-shadow: 0 0 0 3px #140d0a, 0 0 40px rgba(232, 184, 74, 0.35);
  padding: 22px 18px; text-align: center; line-height: 1.7; font-size: 11px;
}
#reward .crown { color: #e8b84a; font-size: 34px; line-height: 1; }
#reward h2 { color: #e8b84a; font-size: 15px; margin: 12px 0; }
#reward b { color: #e8b84a; }
#reward-code {
  margin: 16px auto 8px; padding: 14px 8px; font-size: 20px; letter-spacing: 2px;
  background: #0a0614; border: 2px dashed #a050d8; color: #fff; word-break: break-all;
}
#reward .small { font-size: 9px; color: #c8a46a; min-height: 1em; }
#reward .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
#reward button, #reward a {
  font-family: inherit; font-size: 11px; padding: 10px 14px; cursor: pointer;
  background: #c0282d; color: #fff; border: 2px solid #140d0a; text-decoration: none;
}
#reward a { background: #e8b84a; color: #140d0a; }
#reward button.ghost { background: transparent; color: #c8a46a; border-color: #5a4a6a; margin-top: 4px; }

/* Link back to the shop, under the game. */
#home-link {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 20;
  font: 10px "PressStart", monospace; color: #140d0a; background: #e8b84a;
  border: 2px solid #140d0a; box-shadow: 0 0 0 2px #e8b84a;
  padding: 7px 12px; text-decoration: none; white-space: nowrap;
}
#home-link:hover { background: #fff0a0; }
body.touch #stage { bottom: 0; }
body.touch #home-link { font-size: 8px; padding: 6px 9px; bottom: calc(10px + env(safe-area-inset-bottom)); }

/* Embedded on the Sidequests page: the page has its own links, so fill the frame. */
body.embedded #home-link { display: none; }
body.embedded #stage { bottom: 0; }
/* (not in the desktop app, which is "embedded" too: a Steam Deck needs the controller) */
body.embedded:not(.desktop).touch #touch { display: none; }

/* Phone turned sideways: the game fills the screen and the controller floats over it. */
@media (orientation: landscape) {
  body.touch #stage { align-items: center; padding-top: 0; }
  body.touch #touch { top: 0; height: auto; }
  body.touch .dpad { bottom: calc(14px + env(safe-area-inset-bottom)); left: max(10px, env(safe-area-inset-left)); transform: scale(0.85); transform-origin: bottom left; }
  body.touch .ab { bottom: calc(18px + env(safe-area-inset-bottom)); right: max(10px, env(safe-area-inset-right)); transform: scale(0.85); transform-origin: bottom right; }
  /* top-right corner (usually in the side margin) rather than over the centered message/banner windows */
  body.touch #touch .menu { top: calc(8px + env(safe-area-inset-top)); bottom: auto; left: auto; right: max(8px, env(safe-area-inset-right)); transform: none; width: 84px; opacity: 0.8; }
  body.touch #home-link { display: none; }
}
