/* Block City Ransom - shell styling.
   Everything gameplay-related is drawn on the canvas; this file only handles
   the page chrome, the touch overlay and the boot / rotate prompts. */

:root {
  --btc: #f7931a;
  --ink: #0b0d17;
  --pad: max(10px, env(safe-area-inset-left));
}

/* touch-action is not inherited — every hit target must set it, or a second
   finger on a button while holding the stick can still pinch-zoom the page. */
* {
  box-sizing: border-box;
  touch-action: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#frame {
  position: fixed;
  inset: 0;
  background: #05060c;
  touch-action: none;
}

#screen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- touch UI */

#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  --controls-opacity: 0.72;
}

#touch .pad,
#touch .tbtn { pointer-events: auto; }

#dpad,
#stick,
#btns,
#touch > .btn-start {
  opacity: var(--controls-opacity);
}

/* ---- NES D-pad (default) ------------------------------------------------ */

#dpad {
  position: absolute;
  left: var(--pad);
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(38vw, 188px);
  aspect-ratio: 1;
}

.nes-dpad {
  position: absolute;
  inset: 0;
}

.nes-cross {
  position: absolute;
  inset: 8%;
}

.nes-cross .arm {
  position: absolute;
  background: rgba(55, 58, 72, .88);
  border: 2px solid rgba(255, 255, 255, .28);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .35);
}

.nes-cross .arm.up,
.nes-cross .arm.down {
  left: 32%;
  width: 36%;
  height: 38%;
}

.nes-cross .arm.up { top: 0; border-radius: 10px 10px 4px 4px; }
.nes-cross .arm.down { bottom: 0; border-radius: 4px 4px 10px 10px; }

.nes-cross .arm.left,
.nes-cross .arm.right {
  top: 32%;
  height: 36%;
  width: 38%;
}

.nes-cross .arm.left { left: 0; border-radius: 10px 4px 4px 10px; }
.nes-cross .arm.right { right: 0; border-radius: 4px 10px 10px 4px; }

.nes-cross .hub {
  position: absolute;
  left: 32%;
  top: 32%;
  width: 36%;
  height: 36%;
  background: rgba(55, 58, 72, .95);
  border-radius: 18%;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25);
}

/* Direction chevrons */
.nes-cross .arm::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  opacity: .55;
  border-style: solid;
}
.nes-cross .arm.up::after {
  border-width: 0 7px 10px 7px;
  border-color: transparent transparent rgba(255, 255, 255, .85) transparent;
  margin-top: -2px;
}
.nes-cross .arm.down::after {
  border-width: 10px 7px 0 7px;
  border-color: rgba(255, 255, 255, .85) transparent transparent transparent;
  margin-top: 2px;
}
.nes-cross .arm.left::after {
  border-width: 7px 10px 7px 0;
  border-color: transparent rgba(255, 255, 255, .85) transparent transparent;
  margin-left: -2px;
}
.nes-cross .arm.right::after {
  border-width: 7px 0 7px 10px;
  border-color: transparent transparent transparent rgba(255, 255, 255, .85);
  margin-left: 2px;
}

#dpad.press-up .arm.up,
#dpad.press-down .arm.down,
#dpad.press-left .arm.left,
#dpad.press-right .arm.right {
  background: rgba(247, 147, 26, .78);
  border-color: rgba(255, 255, 255, .65);
}
#dpad.press-up .arm.up::after,
#dpad.press-down .arm.down::after,
#dpad.press-left .arm.left::after,
#dpad.press-right .arm.right::after { opacity: .95; }

/* ---- optional analogue stick ------------------------------------------- */

#stick {
  position: absolute;
  left: var(--pad);
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(36vw, 180px);
  aspect-ratio: 1;
}

.stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .22);
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .10), rgba(255, 255, 255, .03) 70%);
  backdrop-filter: blur(2px);
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  aspect-ratio: 1;
  margin: -21% 0 0 -21%;
  border-radius: 50%;
  background: rgba(247, 147, 26, .55);
  border: 3px solid rgba(255, 255, 255, .55);
  transition: background .12s;
}

#stick.active .stick-knob { background: rgba(247, 147, 26, .9); }

/* Face buttons sit in a wider triangle so thumbs don't mash neighbors.
   Cap with vh so short landscape phones still get fat hit targets. */
#btns {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(58vw, 72vh, 320px);
  aspect-ratio: 1.18;
}

.tbtn {
  position: absolute;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .5);
  background: rgba(20, 24, 44, .55);
  color: #fff;
  font: 700 clamp(11px, 2.9vw, 15px)/1 ui-monospace, monospace;
  letter-spacing: .04em;
  backdrop-filter: blur(2px);
  transition: transform .06s, background .06s;
  -webkit-user-select: none;
  user-select: none;
  /* Stop long-press / double-tap browser UI on the face buttons. */
  -webkit-touch-callout: none;
}

.tbtn:active,
.tbtn.down {
  transform: scale(.94);
  background: rgba(247, 147, 26, .85);
}

/* Classic arcade triangle — sized up, with air between every pair. */
.btn-punch { right: 0;     bottom: 2%;  width: 40%; aspect-ratio: 1; }
.btn-kick  { right: 56%;   bottom: 0;   width: 40%; aspect-ratio: 1; }
.btn-jump  { right: 26%;   bottom: 56%; width: 38%; aspect-ratio: 1;
             background: rgba(60, 90, 200, .5); font-size: clamp(10px, 2.6vw, 14px); }

.btn-start {
  top: max(8px, env(safe-area-inset-top));
  right: var(--pad);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 16px;
  letter-spacing: 0;
}

/* ------------------------------------------------------------ boot overlay */

#boot {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #16203c, #05060c 70%);
  cursor: pointer;
}

#boot.gone { display: none; }

.boot-inner { text-align: center; animation: rise .5s ease-out; }

.boot-logo {
  font-size: clamp(56px, 16vw, 120px);
  color: var(--btc);
  text-shadow: 0 6px 0 #a5600d, 0 0 44px rgba(247, 147, 26, .55);
  line-height: 1;
}

.boot-title {
  margin-top: 14px;
  font-size: clamp(16px, 5vw, 30px);
  font-weight: 800;
  letter-spacing: .16em;
}

.boot-sub {
  margin-top: 12px;
  font-size: clamp(10px, 3vw, 14px);
  color: #8fa0c8;
  animation: blink 1.1s steps(2, end) infinite;
}

@keyframes blink { 50% { opacity: .15; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ----------------------------------------------------------- rotate prompt */

#rotate {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: #05060c;
  color: #8fa0c8;
}

#rotate div {
  font-size: 54px;
  color: var(--btc);
  animation: tip 1.8s ease-in-out infinite;
}
#rotate p { margin: 0; letter-spacing: .1em; font-size: 13px; }

@keyframes tip {
  0%, 60%, 100% { transform: rotate(0deg); }
  80% { transform: rotate(-90deg); }
}

/* Only nag on genuinely narrow, tall screens (phones held upright). */
@media (orientation: portrait) and (max-width: 560px) {
  #rotate { display: flex; }
}
