/* On-screen game controller overlay for the Konami-code easter egg.
   All sizes are expressed as calc(var(--n) * fraction), where --n is the
   controller's height in px, set dynamically by crt-easter-egg.js. */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700&display=swap');

#controller-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100001;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: none;
  background: #222;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  opacity: 0.85;
}
#controller-toggle:hover { opacity: 1; }

.controller-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 1rem;
  box-sizing: border-box;
  touch-action: manipulation;
}
/* An author rule setting `display` always beats the UA's [hidden] rule,
   regardless of specificity - so without this, `hidden` never actually
   hides the overlay. */
.controller-overlay[hidden] {
  display: none;
}

#controller-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100002;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: #222;
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.controller {
  position: relative;
  width: calc(var(--n) * 3);
  height: var(--n);
  flex-shrink: 0;
  background-color: #393939;
  background-repeat: repeat;
  /* Slight monochromatic grain via SVG feTurbulence (CSS has no native
     Gaussian-noise primitive). Sits on the base layer only, so opaque
     children (buttons, plaques) paint cleanly over it. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
  border: calc(var(--n) * 0.05) solid #d9d9d9;
  touch-action: none;
  user-select: none;
}

/* --- Shared button reset ------------------------------------------------ */

.dpad, .oval-btn, .round-btn {
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

/* --- D-pad --------------------------------------------------------------- */
/* Bounding square: 0.55n, at 0.17n from left / 0.29n from top of controller.
   The four .dpad buttons ARE the visible arms (black); .dpad-center is a
   purely decorative inert square filling the middle of the cross. */

.dpad { position: absolute; background: #101010; }

.dpad-center {
  left: calc(var(--n) * 0.335);
  top: calc(var(--n) * 0.455);
  width: calc(var(--n) * 0.22);
  height: calc(var(--n) * 0.22);
  pointer-events: none;
}

.dpad-up, .dpad-down {
  left: calc(var(--n) * 0.335);
  width: calc(var(--n) * 0.22);
  height: calc(var(--n) * 0.165);
}
.dpad-up {
  top: calc(var(--n) * 0.29);
}
.dpad-down {
  top: calc(var(--n) * 0.675);
}
.dpad-left, .dpad-right {
  top: calc(var(--n) * 0.455);
  width: calc(var(--n) * 0.165);
  height: calc(var(--n) * 0.22);
}
.dpad-left {
  left: calc(var(--n) * 0.17);
}
.dpad-right {
  left: calc(var(--n) * 0.555);
}

/* --- Select / Start -------------------------------------------------------- */

.plaque-ss {
  position: absolute;
  left: calc(var(--n) * 0.91);
  top: calc(var(--n) * 0.56);
  width: calc(var(--n) * 0.85);
  height: calc(var(--n) * 0.3);
  border-radius: calc(var(--n) * 0.03);
  background: #d9d9d9;
  pointer-events: none;
}

.oval-btn {
  position: absolute;
  top: calc(var(--n) * 0.66);
  width: calc(var(--n) * 0.25);
  height: calc(var(--n) * 0.1);
  border-radius: calc(var(--n) * 0.05);
  background: #393939; /* no noise, per spec */
}
.select-btn { left: calc(var(--n) * 1.03); }
.start-btn  { left: calc(var(--n) * 1.41); }

.label {
  position: absolute;
  color: #db3535;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.label-select, .label-start {
  top: calc(var(--n) * 0.39);
  transform: translateX(-50%);
  font-size: calc(var(--n) * 0.07);
}
.label-select {
  left: calc(var(--n) * 1.155);
}
.label-start {
  left: calc(var(--n) * 1.535);
}

/* --- B / A ----------------------------------------------------------------- */

.plaque {
  position: absolute;
  background: #d9d9d9;
  border-radius: calc(var(--n) * 0.03);
  pointer-events: none;
}
.plaque-b, .plaque-a {
  top: calc(var(--n) * 0.55);
  width: calc(var(--n) * 0.33);
  height: calc(var(--n) * 0.33);
}
.plaque-b {
  left: calc(var(--n) * 1.91);
}
.plaque-a {
  left: calc(var(--n) * 2.31);
}

.round-btn {
  position: absolute;
  top: calc(var(--n) * 0.58);
  width: calc(var(--n) * 0.27);
  height: calc(var(--n) * 0.27);
  border-radius: 50%;
  background: #db3535;
}
.b-btn { left: calc(var(--n) * 1.94); }
.a-btn { left: calc(var(--n) * 2.34); }

.label-b, .label-a {
  top: calc(var(--n) * 0.87);
  font-size: calc(var(--n) * 0.09);
}

.label-b {
  right: calc(var(--n) * 0.76);
}
.label-a {
  right: calc(var(--n) * 0.36);
}
