/* TINWING — presentation shell. Just the authentic 160x144 screen, centered on
   a dark backdrop. No fake handheld. Touch controls appear only on phones. */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100dvh;
  background: #0b0d08;
  color: #9bbc0f;
  font-family: "Courier New", monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  touch-action: none;
  /* Everything here is keyboard/touch driven — a mouse cursor sitting over
     the screen is just visual noise the game never asks for. The save
     backup box below is the one real text-editing UI on the page, so it
     gets its own cursor back (see #backup-overlay). */
  cursor: none;
}
/* The one deliberate exception to the page-wide cursor/right-click/drag
   lockdown above and in main.js: this is a real text field for copying
   and pasting a save code, and needs to behave like one. */
#backup-overlay { cursor: auto; }

#shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  /* keep the pad clear of rounded corners / home indicators on phones */
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  gap: 14px;
}

/* A thin frame so the green screen reads as a screen, not a floating rectangle. */
#screenwrap {
  position: relative;
  padding: 3px;
  background: #1a1c14;
  border-radius: 3px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .6);
}
/* When a decorative border is equipped, the border canvas itself is the frame,
   so the wrap drops its own little bezel and the #screen is positioned over the
   border's central window (offsets set by JS in Gfx.fit). */
#screenwrap.bordered { padding: 0; background: transparent; box-shadow: none; }
#screenwrap.bordered #screen { position: absolute; }
#screen {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #9bbc0f;
  /* Size set by JS to an integer multiple of 160x144. */
}
#border {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0d08;
  /* Size set by JS to an integer multiple of 256x224. */
}
#border.hidden { display: none; }

/* Touch controls — hidden unless the device likely has no keyboard. */
#pad { display: none; }
@media (hover: none), (pointer: coarse) {
  #pad {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 12px 40px;
    width: min(94vw, 460px);
    align-items: center;
  }
}
#dpad {
  position: relative;
  width: 132px;
  height: 132px;
  justify-self: start;
}
#dpad .btn { position: absolute; width: 44px; height: 44px; }
#dpad [data-key=up]    { top: 0;   left: 44px; }
#dpad [data-key=left]  { top: 44px; left: 0; }
#dpad [data-key=right] { top: 44px; left: 88px; }
#dpad [data-key=down]  { top: 88px; left: 44px; }
#face {
  justify-self: end;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding-bottom: 10px;
}
#sys {
  grid-column: 1 / 3;
  display: flex;
  gap: 22px;
  justify-content: center;
  transform: rotate(-16deg);
}
.btn {
  background: #2b2b33;
  color: #d7d7c6;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: bold;
  font-size: 16px;
  box-shadow: 0 3px 0 #0c0c10;
  touch-action: none;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0c0c10; }
/* the tracked d-pad drives an .on class instead of :active, so pressed
   directions still light up while a thumb slides across the pad */
#dpad .btn.on { transform: translateY(2px); box-shadow: 0 1px 0 #0c0c10; background: #4a4a58; color: #fff; }
.btn.round { width: 58px; height: 58px; border-radius: 50%; background: #7a1f3d; color: #ffd; }
/* the wing dash gets its own thumb-reachable face button (rather than the
   small rotated #sys row, which reads as a menu button, not an action one) —
   it is the sole on-screen SELECT button now, so #sys carries only START.
   Smaller than B/A so it doesn't compete with them, and a different color so
   it reads as a distinct "special move" at a glance. */
.btn.round.dash { width: 46px; height: 46px; font-size: 9px; background: #234b73; color: #dff2ff; }
.btn.sm { width: 68px; height: 24px; border-radius: 12px; font-size: 11px; background: #444; }
/* a one-time highlight to point out the DASH button the moment the wing
   dash is unlocked */
.btn.hint { animation: btnhint 0.6s ease-in-out 6; }
@keyframes btnhint {
  0%, 100% { background: #444; }
  50% { background: #c9a227; color: #201a00; box-shadow: 0 0 10px #c9a227; }
}

/* Save backup/restore overlay — the one deliberate escape from the canvas
   UI, since a copy/paste code needs real text I/O. */
#backup-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .75);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  padding: 16px;
}
#backup-overlay.hidden { display: none; }
#backup-box {
  background: #1a1c14;
  border: 2px solid #9bbc0f;
  border-radius: 6px;
  padding: 16px;
  width: min(92vw, 420px);
  color: #9bbc0f;
  font-family: "Courier New", monospace;
}
#backup-box h2 { margin: 0 0 8px; font-size: 15px; letter-spacing: 1px; }
#backup-box p { margin: 0 0 10px; font-size: 12px; line-height: 1.4; color: #b7cf7a; }
#backup-text {
  width: 100%;
  background: #0b0d08;
  color: #9bbc0f;
  border: 1px solid #4a5a2a;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  padding: 6px;
  resize: vertical;
}
#backup-msg { min-height: 16px; font-size: 12px; color: #c9a227; margin: 6px 0; }
#backup-btns { display: flex; gap: 8px; justify-content: flex-end; }
#backup-btns button {
  background: #2b2b33;
  color: #d7d7c6;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
#backup-btns button:active { transform: translateY(1px); }
#backup-close { background: #444 !important; }
