/* ---------------------------------------------------------------------------
   Game window, opened from the desk monitor
--------------------------------------------------------------------------- */
.game-overlay { position: fixed; inset: 0; z-index: 50; }
.game-overlay[hidden] { display: none; }
.game-overlay:focus { outline: none; }
.game-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(16, 12, 24, 0.5), rgba(6, 5, 12, 0.85));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.game-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
}
.game-monitor {
  pointer-events: auto;
  width: min(86vw, calc(78vh * 16 / 9), 980px);
  background: linear-gradient(180deg, #2c2a30, #1d1b20);
  border-radius: 14px;
  padding: 2.2% 2.2% 0;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.game-screen {
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 0 2px #0d0c0f;
  cursor: pointer;
  touch-action: manipulation;
}
.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.game-chin { height: clamp(18px, 3vw, 30px); display: grid; place-items: center; }
.game-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffc27a;
  box-shadow: 0 0 8px #ffc27a;
}
.game-note {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(255, 246, 232, 0.7);
  text-align: center;
  padding: 0 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.game-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 236, 210, 0.22);
  background: rgba(20, 16, 24, 0.45);
  color: #fff6e8;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ready .game-close,
.ready .game-mute,
.ready .game-note { opacity: 1; }
.game-close:focus-visible { outline: 2px solid #ffc27a; outline-offset: 3px; }

/* on-screen controls, shown on touch screens */
.game-pad { display: none; pointer-events: auto; gap: 14px; align-items: center; }
.game-overlay.touch .game-pad { display: flex; }
.game-overlay.touch .game-note { display: none; }
.pad-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 236, 210, 0.25);
  background: rgba(30, 24, 44, 0.7);
  color: #ffe7b0;
  font-size: 20px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.pad-btn.pad-action { width: 66px; height: 66px; margin-left: 18px; font-size: 26px; background: rgba(60, 44, 30, 0.75); }
.pad-btn:active { background: rgba(255, 214, 140, 0.25); }

/* sideways phones: the screen fills the height and the buttons sit at either side */
@media (orientation: landscape) and (max-height: 520px) {
  .game-overlay.touch .game-monitor { width: min(calc((100vh - 36px) * 1.62), 70vw); padding: 1.6% 1.6% 0; }
  .game-overlay.touch .game-chin { height: 14px; }
  .game-overlay.touch .game-pad {
    position: absolute;
    left: max(14px, env(safe-area-inset-left, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    justify-content: space-between;
    pointer-events: none;
  }
  .game-overlay.touch .pad-btn { pointer-events: auto; width: 52px; height: 52px; }
  .game-overlay.touch .pad-btn[data-key="right"] { margin-right: auto; margin-left: 10px; }
  .game-overlay.touch .pad-action { width: 62px; height: 62px; }
}

.game-mute {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(64px + env(safe-area-inset-right, 0px));
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 236, 210, 0.22);
  background: rgba(20, 16, 24, 0.45);
  color: #fff6e8;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.game-mute .off { display: none; }
.muted .game-mute .on { display: none; }
.muted .game-mute .off { display: block; }
.game-mute:focus-visible { outline: 2px solid #ffc27a; outline-offset: 3px; }
.pad-action svg { display: block; margin: auto; }
