/* ==========================================================================
   PIP-OS — games.css
   Mini-game shared styling, hacking grid, lockpick lock, canvas wrappers.
   ========================================================================== */

.game {
  position: absolute;
  inset: 0;
  background: var(--phosphor-deep);
  z-index: 50; /* above .ui (no z-index), below CRT scanlines (90,91) and standby/console */
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  font-family: var(--font-mono);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--phosphor-dim);
  font-size: 16px;
  letter-spacing: 2px;
}
.game-header .title { letter-spacing: 4px; }
.game-header .meta { display: flex; gap: 14px; font-size: 14px; color: var(--phosphor-dim); }
.game-header .eject { font-family: var(--font-pip); cursor: pointer; border: 1px solid var(--phosphor); padding: 2px 10px; }

.game-body {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.game-canvas-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas.game-canvas {
  display: block;
  background: var(--phosphor-deep);
  image-rendering: pixelated;
  border: 1px solid var(--phosphor-dim);
  max-width: 100%;
  max-height: 100%;
}

/* Touch buttons overlay */
.touch-pad {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: none;
  justify-content: space-between;
  pointer-events: none;
}
@media (max-width: 700px), (pointer: coarse) {
  .touch-pad { display: flex; }
}
.touch-pad .group {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.touch-pad button {
  width: 50px;
  height: 50px;
  border: 2px solid var(--phosphor);
  background: rgba(0,0,0,0.5);
  color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: 22px;
  border-radius: 50%;
  user-select: none;
  -webkit-user-select: none;
}

/* Game over overlay */
.game-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.8);
  font-size: 32px;
  text-align: center;
  z-index: 5;
  letter-spacing: 6px;
}
.game-over .sub {
  display: block;
  margin-top: 12px;
  font-size: 16px;
  letter-spacing: 2px;
}

/* ----- Hacking ----------------------------------------------------------- */

.hacking {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 700px) {
  .hacking { grid-template-columns: 1fr; }
}
.hacking .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.15;
  overflow: auto;
  padding-right: 4px;
}
.hacking .col {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-content: start;
}
.hacking .addr { color: var(--phosphor-dim); }
.hacking .row  { white-space: pre; cursor: default; }
.hacking .row .tok {
  cursor: pointer;
  padding: 0 1px;
}
.hacking .row .tok:hover {
  background: var(--phosphor);
  color: var(--phosphor-deep);
  text-shadow: none;
}
.hacking .row .tok.dud { text-decoration: line-through; opacity: 0.4; pointer-events: none; }

.hacking .log {
  border: 1px solid var(--phosphor-dim);
  padding: 8px;
  display: flex;
  flex-direction: column;
}
.hacking .log .head {
  border-bottom: 1px solid var(--phosphor-dim);
  padding-bottom: 4px;
  margin-bottom: 6px;
  font-size: 14px;
  letter-spacing: 2px;
}
.hacking .log .lines {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: pre-wrap;
  overflow-y: auto;
}
.hacking .log .attempts {
  margin-top: 6px;
  font-size: 14px;
  color: var(--phosphor-dim);
  letter-spacing: 2px;
}
.hacking .log .attempts .pip {
  display: inline-block;
  width: 12px; height: 12px;
  background: var(--phosphor);
  margin-right: 3px;
}
.hacking .log .attempts .pip.lost { background: transparent; border: 1px solid var(--phosphor-dim); }

.hacking .difficulty {
  display: flex; gap: 4px;
  font-size: 14px;
}
.hacking .difficulty button {
  padding: 2px 6px;
  border: 1px solid var(--phosphor-dim);
}
.hacking .difficulty button.active {
  background: var(--phosphor);
  color: var(--phosphor-deep);
  text-shadow: none;
}

/* ----- Lockpick ---------------------------------------------------------- */

.lockpick {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: center;
}
@media (max-width: 700px) { .lockpick { grid-template-columns: 1fr; } }

.lockpick .stage {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lockpick svg { width: min(360px, 90%); height: auto; }

.lockpick .pin {
  stroke: var(--phosphor);
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
  transform-origin: 200px 200px;
  filter: drop-shadow(0 0 4px var(--phosphor));
}

.lockpick .cylinder {
  fill: var(--phosphor-deep);
  stroke: var(--phosphor);
  stroke-width: 3;
  transform-origin: 200px 200px;
}

.lockpick .keyhole {
  fill: var(--phosphor-mid);
  stroke: var(--phosphor);
  stroke-width: 1;
  transform-origin: 200px 200px;
}

.lockpick .panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 16px;
}
.lockpick .panel h3 { margin: 0; letter-spacing: 2px; }
.lockpick .pins {
  display: flex; gap: 4px;
}
.lockpick .pins .p {
  width: 26px; height: 4px;
  background: var(--phosphor);
}
.lockpick .pins .p.broken { background: var(--phosphor-mid); }

/* ----- Red Menace, Atomic Command, Zeta Invaders, Pipfall use canvas ----- */

.score-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--phosphor);
  z-index: 4;
}
