/* ============================================================
   GAMES / FIELD KIT — CRT Terminal Sub-Page
   Debrief-feed aesthetic inside the log-frame.
   Classic console font, expandable rows, inventory grid.
   ============================================================ */

/* ---- SCROLL FIX: Override crt.css lockdown for standalone pages ----
   crt.css sets html,body { overflow:hidden } and #crt-screen { position:fixed }
   which is correct for the terminal SPA but kills scroll on sub-pages.
   These overrides restore natural page scroll while preserving the CRT frame. */
html, body {
  overflow: auto !important;
  overflow-x: hidden !important;
  height: auto !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
}
#crt-screen {
  position: relative !important;
  height: auto !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  overflow: visible !important;
}

/* ---- Games log frame fills the full monitor shell ---- */
.games-log-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Inner scanline overlay for that "screen within a screen" feel */
.games-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
  opacity: 0.35;
  pointer-events: none;
  z-index: 10;
  border-radius: 10px;
}

/* ---- Header strip ---- */
.games-header-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--panel-border-soft);
  font-size: 0.72em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor-dim);
  flex-shrink: 0;
}

.games-header-icon {
  color: #4a8aff;   /* sapphire for diamond suit */
  font-size: 1.2em;
}

.games-header-title {
  flex: 1;
}

.games-header-status {
  color: var(--phosphor);
  font-size: 0.9em;
  animation: games-blink 2s step-end infinite;
}

@keyframes games-blink {
  0%, 70% { opacity: 1; }
  71%, 100% { opacity: 0.3; }
}

/* ---- Scrollable content ---- */
.games-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--phosphor-dim) transparent;
}

.games-content::-webkit-scrollbar {
  width: 4px;
}
.games-content::-webkit-scrollbar-thumb {
  background: var(--phosphor-dim);
  border-radius: 2px;
}
.games-content::-webkit-scrollbar-track {
  background: transparent;
}

/* ---- Row container ---- */
.games-row {
  border: 1px solid var(--panel-border-soft);
  border-radius: 6px;
  margin-bottom: 6px;
  background: var(--phosphor-glow);
  overflow: hidden;
  transition: border-color 0.2s;
}

.games-row:hover {
  border-color: var(--panel-border);
}

/* ---- Row header (clickable) ---- */
.games-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid rgba(28, 255, 155, 0.06);
  background:
    linear-gradient(180deg, rgba(28,255,155,0.03) 0%, transparent 100%);
  color: var(--phosphor);
  font-family: var(--theme-font-data, 'Courier New', 'Lucida Console', 'Consolas', monospace);
  font-size: 0.82em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.games-row-header:hover {
  background:
    linear-gradient(180deg, rgba(28,255,155,0.07) 0%, rgba(28,255,155,0.02) 100%);
  border-bottom-color: rgba(28, 255, 155, 0.15);
}

.games-row-header:active {
  background: rgba(28, 255, 155, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Expanded header gets a glow underline */
.games-row-header[aria-expanded="true"] {
  border-bottom-color: var(--phosphor-dim, #1a6b4a);
  box-shadow: 0 1px 6px rgba(28, 255, 155, 0.08);
}

.games-row-chevron {
  font-size: 0.9em;
  width: 1em;
  text-align: center;
  color: var(--phosphor-dim);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.games-row-label {
  flex: 1;
  font-weight: bold;
}

.games-row-count {
  color: var(--phosphor-dim);
  font-size: 0.85em;
  opacity: 0.7;
}

.games-row-status {
  font-size: 0.75em;
  color: var(--phosphor-dim);
  padding: 2px 6px;
  border: 1px solid var(--panel-border-soft);
  border-radius: 3px;
  letter-spacing: 0.08em;
}

/* ---- Row body (expandable) ---- */
.games-row-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              padding 0.25s ease;
  padding: 0 12px;
  border-top: 0 solid transparent;
}

.games-row-body.games-row-body-open {
  max-height: 660px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--panel-border-soft);
}

/* ---- Puzzle items ---- */
.games-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border-soft);
  transition: background 0.15s;
}

.games-item:last-child {
  border-bottom: none;
}

.games-item:hover {
  background: var(--phosphor-glow);
}

.games-item-icon {
  color: var(--phosphor-dim);
  font-size: 0.9em;
  margin-top: 2px;
  flex-shrink: 0;
}

.games-item-info {
  flex: 1;
  min-width: 0;
}

.games-item-name {
  font-size: 0.82em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--phosphor);
  margin-bottom: 2px;
}

.games-item-desc {
  font-size: 0.72em;
  color: var(--phosphor-dim);
  line-height: 1.5;
  opacity: 0.8;
}

.games-item-tag {
  font-size: 0.62em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}

.games-tag-narrative {
  color: #7aafff;
  border: 1px solid rgba(122, 175, 255, 0.3);
}

.games-tag-timed {
  color: #ffb347;
  border: 1px solid rgba(255, 179, 71, 0.3);
}

.games-tag-locked {
  color: #666;
  border: 1px solid rgba(100, 100, 100, 0.3);
}

.games-item-locked {
  opacity: 0.45;
}

.games-item-locked .games-item-name {
  color: #555;
}

/* ---- Decryption inventory scrollable wrapper ---- */
/* Horizontal scroll strip: ~5 slots visible, right-edge fade hints at more. */
.games-inventory-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 10px;
  max-width: 535px; /* ~5 slots: 3 items + 2 empty placeholders */
  scrollbar-width: thin;
  scrollbar-color: var(--phosphor-dim, #1a9c1a) transparent;
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  mask-image: linear-gradient(to right, black 85%, transparent 100%);
  position: relative;
}
/* Thin styled scrollbar for webkit browsers */
.games-inventory-scroll::-webkit-scrollbar {
  height: 6px;
}
.games-inventory-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}
.games-inventory-scroll::-webkit-scrollbar-thumb {
  background: var(--phosphor-dim, #1a9c1a);
  border-radius: 3px;
  min-width: 30px;
}
.games-inventory-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--phosphor, #33ff33);
}

/* Remove fade mask once user scrolls (JS toggles this class) */
.games-inventory-scroll.scroll-active {
  mask-image: none;
  -webkit-mask-image: none;
}

/* Mobile: narrower strip + smaller slots */
@media (max-width: 768px) {
  .games-inventory-scroll {
    max-width: 85vw;
  }
  .games-inv-slot {
    width: min(80px, 22vw);
    height: min(80px, 22vw);
  }
}

/* ---- Decryption inventory grid (horizontal strip) ---- */
.games-inventory-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  width: max-content;
}

.games-inv-slot {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  cursor: pointer;
}

.games-inv-slot-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 3px 3px;
  border: 1px solid var(--panel-border-soft);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

.games-inv-slot:hover .games-inv-slot-inner {
  border-color: var(--panel-border);
  background: var(--phosphor-glow);
}

.games-inv-slot-num {
  font-size: 0.6em;
  color: var(--phosphor-dim);
  opacity: 0.5;
  letter-spacing: 0.1em;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.games-inv-slot-label {
  font-size: 0.45em;
  color: #444;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.2;
  flex-shrink: 0;
}

.games-inv-empty .games-inv-slot-num {
  opacity: 0.35;
}

/* Empty placeholder slots — dashed border conveys "available" */
.games-inv-empty {
  border-style: dashed;
  border-color: var(--panel-border-soft);
  background: rgba(0, 0, 0, 0.15);
}

/* Empty placeholders label ("EMPTY") dimmer than occupied labels */
.games-inv-empty .games-inv-slot-label {
  opacity: 0.25;
}

/* Last visible empty slot fades off — implies expandability */
.games-inv-fade-hint {
  opacity: 0.3;
  pointer-events: none;
}

/* ---- Equipped slot highlight on inventory ---- */
.games-inv-slot.games-inv-equipped .games-inv-slot-inner {
  border-color: var(--phosphor, #1cff9b);
  box-shadow: 0 0 10px var(--phosphor-glow, rgba(28,255,155,0.25)),
              inset 0 0 6px var(--phosphor-glow, rgba(28,255,155,0.1));
}
.games-inv-slot.games-inv-equipped::after {
  content: 'EQ';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.45em;
  letter-spacing: 0.1em;
  color: var(--phosphor, #1cff9b);
  opacity: 0.7;
}
.games-inv-slot {
  position: relative;
}

/* ---- Equipped item slot (slot 0, data-equipped) ---- */
.games-inv-equipped-slot .games-inv-slot-inner {
  border: 1.5px solid var(--phosphor, #1cff9b);
  box-shadow: 0 0 12px var(--phosphor-glow, rgba(28,255,155,0.3)),
              inset 0 0 8px var(--phosphor-glow, rgba(28,255,155,0.12));
}

.games-inv-equipped-badge {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.4em;
  letter-spacing: 0.12em;
  font-family: 'Courier New', Courier, monospace;
  color: var(--phosphor, #1cff9b);
  opacity: 0.65;
  pointer-events: none;
  z-index: 1;
}

.games-inv-equipped-slot .games-inv-slot-label {
  font-size: 0.48em;
  letter-spacing: 0.08em;
  color: var(--phosphor-dim, #1a9c1a);
}

/* Pulse animation when equipped slot is being dragged from */
.games-inv-equipped-slot:active .games-inv-slot-inner {
  box-shadow: 0 0 18px var(--phosphor-glow, rgba(28,255,155,0.5)),
              inset 0 0 10px var(--phosphor-glow, rgba(28,255,155,0.2));
}

/* ---- Incinerator slot ---- */
.games-inv-incinerator {
  order: 999;  /* Always last in grid */
}

.games-inv-incinerator-inner {
  border: 1.5px dashed rgba(255, 71, 87, 0.4);
  background: rgba(255, 71, 87, 0.04);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  min-height: 52px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  cursor: default;
}

.games-inv-incinerator-inner .games-inv-item-icon {
  font-size: 1.1em;
  opacity: 0.5;
  filter: grayscale(0.4);
  transition: opacity 0.2s, filter 0.2s;
}

.games-inv-incinerator-inner .games-inv-slot-label {
  font-size: 0.45em;
  letter-spacing: 0.1em;
  color: rgba(255, 71, 87, 0.5);
  text-transform: uppercase;
}

/* Hover/dragover state */
.games-inv-incinerator-hover .games-inv-incinerator-inner,
.games-inv-incinerator:hover .games-inv-incinerator-inner {
  border-color: rgba(255, 71, 87, 0.8);
  background: rgba(255, 71, 87, 0.1);
  box-shadow: 0 0 12px rgba(255, 71, 87, 0.3),
              inset 0 0 8px rgba(255, 71, 87, 0.1);
}

.games-inv-incinerator-hover .games-inv-incinerator-inner .games-inv-item-icon,
.games-inv-incinerator:hover .games-inv-incinerator-inner .games-inv-item-icon {
  opacity: 1;
  filter: none;
}

/* Incinerate animation */
.games-inv-incinerator.incinerator-active .games-inv-incinerator-inner {
  animation: incinerator-flash-inv 0.8s ease-out forwards;
}

@keyframes incinerator-flash-inv {
  0%   { background: rgba(255,71,87,0.1); box-shadow: none; }
  10%  { background: rgba(255,165,0,0.6); box-shadow: 0 0 20px rgba(255,165,0,0.5); }
  30%  { background: rgba(255,69,0,0.7); box-shadow: 0 0 30px rgba(255,69,0,0.6); }
  60%  { background: rgba(180,30,0,0.5); box-shadow: 0 0 15px rgba(180,30,0,0.3); }
  100% { background: rgba(255,71,87,0.04); box-shadow: none; }
}

/* ---- Interactive Decoder Ring (in puzzles category) ---- */
.games-decoder-ring-wrap {
  border: 1px solid var(--panel-border-soft);
  border-radius: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  text-align: center;
  margin-bottom: 10px;
}

.games-decoder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.games-decoder-header-label {
  font-size: 0.7em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
}

.games-decoder-header-status {
  font-size: 0.6em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555;
  padding: 2px 6px;
  border: 1px solid #333;
  border-radius: 3px;
}

.games-decoder-header-status.decoder-active {
  color: var(--phosphor, #1cff9b);
  border-color: var(--phosphor-dim, #1a6b4a);
  text-shadow: 0 0 6px var(--phosphor-glow, rgba(28,255,155,0.3));
}

.games-decoder-ring {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.games-decoder-ring canvas {
  max-width: 100%;
  height: auto;
  opacity: 0.25;
  transition: opacity 0.3s ease;
  touch-action: none;
  cursor: grab;
  pointer-events: none;
}

.games-decoder-ring canvas:active {
  cursor: grabbing;
}

.games-decoder-output {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--theme-font-data, 'Courier New', monospace);
}

.games-decoder-output-label {
  font-size: 0.6em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
}

.games-decoder-output-pair {
  font-size: 0.85em;
  font-weight: bold;
  letter-spacing: 0.15em;
  color: var(--phosphor, #1cff9b);
  text-shadow: 0 0 6px var(--phosphor-glow, rgba(28,255,155,0.2));
}

.games-decoder-hint {
  font-size: 0.58em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555;
  margin-top: 6px;
}

/* ---- Puzzles row highlight when decoder ring is equipped ---- */
.games-row.games-row-decoder-active {
  border-color: var(--phosphor-dim, #1a6b4a);
  box-shadow: 0 0 12px var(--phosphor-glow, rgba(28,255,155,0.1));
}
.games-row.games-row-decoder-active .games-row-header {
  color: var(--phosphor, #1cff9b);
}
.games-row.games-row-decoder-active .games-row-status {
  color: var(--phosphor, #1cff9b);
  border-color: var(--phosphor-dim, #1a6b4a);
}

/* ---- Launcher panels (Street-Chronicles, Gone-Rogue) ---- */
.games-launcher {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 10px;
  background:
    linear-gradient(180deg, rgba(28,255,155,0.02) 0%, transparent 40%);
  border-radius: 4px;
}

.games-launcher-banner {
  padding: 8px 0 6px;
  border-bottom: 1px solid rgba(28, 255, 155, 0.10);
}

.games-launcher-title {
  font-size: 1.05em;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor);
  margin-bottom: 4px;
  text-shadow: 0 0 12px rgba(28, 255, 155, 0.2);
}

.games-launcher-sub {
  font-size: 0.72em;
  color: var(--phosphor-dim);
  opacity: 0.8;
  line-height: 1.5;
  letter-spacing: 0.04em;
}

.games-launcher-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.games-launcher-detail {
  display: flex;
  gap: 6px;
  font-size: 0.68em;
  letter-spacing: 0.08em;
}

.games-detail-key {
  color: var(--phosphor-dim);
  opacity: 0.6;
  text-transform: uppercase;
}

.games-detail-val {
  color: var(--phosphor-dim);
}

.games-seed-display {
  color: var(--phosphor) !important;
}

/* ---- Seed row ---- */
.games-seed-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.games-seed-label {
  font-size: 0.68em;
  letter-spacing: 0.12em;
  color: var(--phosphor-dim);
  flex-shrink: 0;
}

.games-seed-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--panel-border-soft);
  border-radius: 3px;
  color: var(--phosphor);
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.72em;
  padding: 5px 8px;
  letter-spacing: 0.06em;
  outline: none;
}

.games-seed-input:focus {
  border-color: var(--phosphor-dim);
}

.games-seed-input::placeholder {
  color: #333;
}

.games-seed-randomize {
  background: transparent;
  border: 1px solid var(--panel-border-soft);
  border-radius: 3px;
  color: var(--phosphor-dim);
  font-size: 1em;
  padding: 3px 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.games-seed-randomize:hover {
  border-color: var(--phosphor);
  color: var(--phosphor);
}

/* ---- Launch button ---- */
.games-launch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--phosphor-dim);
  border-bottom: 2px solid rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(28,255,155,0.06) 0%, rgba(28,255,155,0.02) 100%);
  color: var(--phosphor);
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.82em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(28, 255, 155, 0.08);
  transition:
    background 0.12s,
    border-color 0.12s,
    box-shadow 0.15s,
    transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.games-launch-btn:hover {
  border-color: var(--phosphor);
  background:
    linear-gradient(180deg, rgba(28,255,155,0.10) 0%, rgba(28,255,155,0.04) 100%);
  box-shadow:
    0 4px 16px rgba(28, 255, 155, 0.12),
    0 0 20px rgba(28, 255, 155, 0.06),
    inset 0 1px 0 rgba(28, 255, 155, 0.15);
  transform: translateY(-1px);
}

.games-launch-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow:
    0 0 4px rgba(28, 255, 155, 0.06),
    inset 0 2px 4px rgba(0, 0, 0, 0.25);
  transition-duration: 0.04s;
}

.games-launch-icon {
  font-size: 0.85em;
}

.games-launch-rogue {
  border-color: #ffb000;
  border-bottom: 2px solid rgba(180, 120, 0, 0.5);
  color: #ffb000;
  background:
    linear-gradient(180deg, rgba(255,176,0,0.08) 0%, rgba(255,176,0,0.02) 100%);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 176, 0, 0.10);
}

.games-launch-rogue:hover {
  border-color: #ffc640;
  background:
    linear-gradient(180deg, rgba(255,176,0,0.14) 0%, rgba(255,176,0,0.05) 100%);
  box-shadow:
    0 4px 16px rgba(255, 176, 0, 0.14),
    0 0 20px rgba(255, 176, 0, 0.08),
    inset 0 1px 0 rgba(255, 176, 0, 0.18);
  transform: translateY(-1px);
}

.games-launch-rogue:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  background:
    linear-gradient(180deg, rgba(255,176,0,0.10) 0%, rgba(255,176,0,0.04) 100%);
  box-shadow:
    0 0 4px rgba(255, 176, 0, 0.08),
    inset 0 2px 4px rgba(0, 0, 0, 0.25);
  transition-duration: 0.04s;
}

/* ---- Footer strip ---- */
.games-footer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border-top: 1px solid var(--panel-border-soft);
  font-size: 0.62em;
  letter-spacing: 0.12em;
  color: #333;
  text-transform: uppercase;
  flex-shrink: 0;
}

.games-footer-hiscore {
  color: var(--phosphor-dim);
  text-decoration: none;
  font-size: 1em;
  letter-spacing: 0.1em;
  transition: color 0.15s, text-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.games-footer-hiscore:hover {
  color: var(--phosphor);
  text-shadow: 0 0 8px rgba(28, 255, 155, 0.3);
}

.games-footer-time {
  color: var(--phosphor-dim);
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

/* ---- Occupied inventory slot ---- */
.games-inv-occupied {
  border-color: var(--phosphor-dim);
  background: var(--phosphor-glow);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.games-inv-slot:hover .games-inv-occupied {
  border-color: var(--phosphor);
  box-shadow: 0 0 10px var(--phosphor-glow);
}

.games-inv-item-icon {
  font-size: clamp(1.6em, 4.8vw, 2.5em);
  line-height: 1;
  filter: grayscale(0.3);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;           /* prevent flex overflow */
}

/* Scale item emoji to fill its container (desktop ~8x) */
.games-inv-slot[data-item="magnifying-glass"] .games-inv-slot-inner {
  position: relative;
  overflow: hidden;
}

.games-inv-slot[data-item="magnifying-glass"] .games-inv-item-icon {
  font-size: clamp(2.4em, 6.4vw, 4.4em);
  filter: grayscale(0.15) drop-shadow(0 0 8px var(--phosphor-glow, rgba(28,255,155,0.2)));
  cursor: grab;
  transition: transform 0.2s ease, filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  /* Prevent browser native drag on the emoji — without this,
     pointercancel fires BEFORE our dragstart listener can
     preventDefault(), killing the custom drag ghost.
     See PORTHOLE_PUZZLE_TOOLKIT.md §3a */
  -webkit-user-drag: none;
  user-drag: none;
}

/* Per toolkit §3a: touch-action: none on drag source prevents browser
   scroll/pan from stealing the pointer during drag gestures.
   Scoped to this slot only — rest of the grid scrolls normally. */
.games-inv-slot[data-item="magnifying-glass"] {
  touch-action: none;
}

.games-inv-slot[data-item="magnifying-glass"]:hover .games-inv-item-icon {
  transform: scale(1.08);
  filter: grayscale(0) drop-shadow(0 0 14px var(--phosphor-glow, rgba(28,255,155,0.35)));
}

.games-inv-slot[data-item="magnifying-glass"]:active .games-inv-item-icon {
  cursor: grabbing;
  transform: scale(0.95);
}

.games-inv-slot[data-item="magnifying-glass"] .games-inv-slot-label {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  z-index: 1;
}

.games-inv-occupied .games-inv-slot-label {
  color: var(--phosphor-dim);
  font-size: 0.52em;
  letter-spacing: 0.12em;
  text-align: center;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
  padding-bottom: 2px;
}

/* All occupied slots: inner layout is flex column with emoji centered, label at bottom */
.games-inv-occupied {
  position: relative;
  overflow: hidden;
}

/* ---- Responsive ---- */

/* Tablet portrait */
@media (max-width: 768px) {
  .games-inventory-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .games-decoder-ring canvas {
    width: 200px;
    height: 200px;
  }
}

/* Phone */
@media (max-width: 480px) {
  .games-row-header {
    padding: 8px 8px;
    font-size: 0.75em;
    gap: 6px;
  }

  .games-row-count {
    display: none;
  }

  .games-inv-slot {
    width: min(68px, 20vw);
    height: min(68px, 20vw);
  }

  .games-launcher {
    padding: 8px 6px;
    gap: 10px;
  }

  .games-launcher-title {
    font-size: 0.92em;
  }

  .games-launcher-details {
    flex-direction: column;
    gap: 4px;
  }

  .games-launch-btn {
    padding: 12px 12px;
    font-size: 0.78em;
  }
}

/* ============================================================
   ITEM POPUP — Reusable overlay for item detail inspection
   Matches splash-screen red close button aesthetic.
   ============================================================ */

/* ---- Overlay (full viewport) ---- */
.item-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.item-popup-overlay.item-popup-visible {
  opacity: 1;
}

.item-popup-overlay.item-popup-closing {
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* ---- Backdrop ---- */
.item-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ---- Container (the "card") ---- */
.item-popup-container {
  position: relative;
  z-index: 1;
  max-width: 360px;
  width: 90vw;
  background: var(--bg, #0a0a0a);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-radius: 12px;
  box-shadow:
    0 0 40px rgba(0, 0, 0, 0.6),
    0 0 12px var(--phosphor-glow, rgba(28, 255, 155, 0.1)),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

/* ---- Close button (red, splash-screen style) ---- */
.item-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid rgba(220, 40, 40, 0.6);
  background: rgba(180, 30, 30, 0.85);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  box-shadow: 0 2px 12px rgba(180, 30, 30, 0.4), 0 0 6px rgba(220, 40, 40, 0.2);
  backdrop-filter: blur(4px);
}

.item-popup-close:hover {
  background: rgba(200, 35, 35, 0.95);
  border-color: rgba(255, 60, 60, 0.8);
  transform: scale(1.08);
  box-shadow: 0 2px 18px rgba(220, 40, 40, 0.5), 0 0 10px rgba(255, 60, 60, 0.3);
}

.item-popup-close:active {
  background: rgba(100, 15, 15, 0.95);
  border-color: rgba(140, 20, 20, 0.8);
  transform: scale(0.92);
  box-shadow: 0 1px 6px rgba(100, 15, 15, 0.4);
}

.item-popup-close-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 0 3px rgba(255, 200, 200, 0.4));
}

/* ---- Stage (holds both emoji zoom and final content) ---- */
.item-popup-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 24px 20px;
}

/* ---- Emoji zoom layer ---- */
.item-popup-emoji-zoom {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.5));
}

/* ---- Content (image + title + desc) ---- */
.item-popup-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.item-popup-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-popup-image {
  max-width: 200px;
  max-height: 200px;
  width: auto;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  box-shadow:
    0 2px 16px rgba(0, 0, 0, 0.4),
    0 0 8px var(--phosphor-glow, rgba(28, 255, 155, 0.1));
  image-rendering: auto;
}

.item-popup-title {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.85em;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor, #1cff9b);
  text-align: center;
  text-shadow: 0 0 6px var(--phosphor-glow, rgba(28, 255, 155, 0.3));
}

.item-popup-desc {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.68em;
  line-height: 1.5;
  color: var(--phosphor-dim, #1a6b4a);
  text-align: center;
  max-width: 280px;
  letter-spacing: 0.04em;
}

/* ---- Magnifying glass reveal detection zone ---- */
/* Transparent overlay inside .games-inventory-scroll that acts as the
   porthole detection target.  Position: relative on scroll container
   lets us place this absolutely over the grid. */
.games-inventory-scroll {
  position: relative;
}
.mag-reveal-zone {
  position: absolute;
  inset: 0;
  z-index: 1;            /* above grid, but pointer-events:none so clicks pass through */
  pointer-events: none;
}

/* Glow effect when porthole hovers over a reveal zone */
.mag-reveal-zone.mag-reveal-active {
  box-shadow:
    inset 0 0 30px var(--phosphor-glow, rgba(28, 255, 155, 0.2)),
    0 0 16px var(--phosphor-glow, rgba(28, 255, 155, 0.15));
  border: 1px solid var(--phosphor, #1cff9b);
  border-radius: 6px;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* ---- Hidden slot reveal glow (magnifying glass drag-over) ---- */
.games-inv-slot.mag-reveal-active .games-inv-slot-inner {
  border-color: var(--phosphor, #1cff9b);
  box-shadow:
    0 0 16px var(--phosphor-glow, rgba(28, 255, 155, 0.3)),
    inset 0 0 10px var(--phosphor-glow, rgba(28, 255, 155, 0.15));
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.games-inv-slot.mag-revealed .games-inv-slot-inner {
  animation: mag-reveal-flash 0.5s ease-out;
}

@keyframes mag-reveal-flash {
  0%   { box-shadow: 0 0 30px var(--phosphor, #1cff9b), inset 0 0 20px var(--phosphor-glow, rgba(28,255,155,0.4)); }
  100% { box-shadow: none; }
}

/* ============================================================
   ARCADE — Tile grid for simple minigames
   ============================================================ */

/* ── Arcade Grid ── */
.games-arcade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px 8px;
}

/* ── Arcade Tile — tactile cabinet button ── */
.games-arcade-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 8px 14px;
  background:
    linear-gradient(
      180deg,
      rgba(28, 255, 155, 0.05) 0%,
      rgba(28, 255, 155, 0.01) 60%,
      rgba(0, 0, 0, 0.15) 100%
    );
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-bottom: 2px solid rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--theme-font-data, 'Courier New', monospace);
  color: var(--phosphor, #1cff9b);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(28, 255, 155, 0.08);
  transition:
    border-color 0.12s,
    background 0.12s,
    box-shadow 0.15s,
    transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* Scanline texture overlay */
.games-arcade-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  border-radius: 6px;
  pointer-events: none;
}

/* Hover — glow lift */
.games-arcade-tile:hover,
.games-arcade-tile:focus-visible {
  border-color: var(--phosphor, #1cff9b);
  background:
    linear-gradient(
      180deg,
      rgba(28, 255, 155, 0.10) 0%,
      rgba(28, 255, 155, 0.03) 60%,
      rgba(0, 0, 0, 0.10) 100%
    );
  box-shadow:
    0 4px 14px rgba(28, 255, 155, 0.12),
    0 0 20px rgba(28, 255, 155, 0.08),
    inset 0 1px 0 rgba(28, 255, 155, 0.15);
  outline: none;
  transform: translateY(-1px);
}

/* Active — press in */
.games-arcade-tile:active {
  transform: translateY(2px) scale(0.98);
  border-bottom-width: 1px;
  box-shadow:
    0 0 4px rgba(28, 255, 155, 0.08),
    inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transition-duration: 0.04s;
}

/* ── Icon — big, glowing ── */
.games-arcade-icon {
  font-size: 2.2em;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(28, 255, 155, 0.25));
  transition: filter 0.15s, transform 0.15s;
}
.games-arcade-tile:hover .games-arcade-icon {
  filter: drop-shadow(0 0 10px rgba(28, 255, 155, 0.4));
  transform: scale(1.08);
}
.games-arcade-tile:active .games-arcade-icon {
  transform: scale(0.95);
}

/* ── Title ── */
.games-arcade-title {
  font-size: 0.72em;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(28, 255, 155, 0.2);
}

/* ── Description ── */
.games-arcade-desc {
  font-size: 0.56em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
}

/* ── High score badge (injected by JS) ── */
.games-arcade-hiscore {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  font-size: 0.52em;
  letter-spacing: 0.08em;
  color: var(--phosphor-dim, #1a6b4a);
  opacity: 0.8;
}
.games-arcade-hiscore-value {
  color: var(--phosphor, #1cff9b);
  font-weight: bold;
}

/* ── Achievement medal badge (positioned top-right of tile) ── */
.games-arcade-medal {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 1.1em;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  z-index: 2;
  animation: medal-shine 3s ease-in-out infinite;
}
.games-arcade-medal-gold {
  animation: medal-shine-gold 2.5s ease-in-out infinite;
}
@keyframes medal-shine {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.1); opacity: 1; }
}
@keyframes medal-shine-gold {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.95; }
  50% { transform: scale(1.15) rotate(5deg); opacity: 1; }
}

/* ── Idle pulse keyframes ── */
@keyframes arcade-tile-pulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.35), inset 0 1px 0 rgba(28,255,155,0.08); }
  50% { box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 8px rgba(28,255,155,0.06), inset 0 1px 0 rgba(28,255,155,0.12); }
}
.games-arcade-tile {
  animation: arcade-tile-pulse 4s ease-in-out infinite;
}
.games-arcade-tile:hover,
.games-arcade-tile:active {
  animation: none;
}

/* ── Tile launch flash ── */
@keyframes arcade-tile-launch {
  0%   { box-shadow: inset 0 0 0 rgba(28,255,155,0); }
  30%  { box-shadow: inset 0 0 30px rgba(28,255,155,0.3); }
  100% { box-shadow: inset 0 0 0 rgba(28,255,155,0); }
}
.games-arcade-tile.arcade-tile-launching {
  animation: arcade-tile-launch 0.4s ease-out;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .games-arcade-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px 6px;
  }
  .games-arcade-tile {
    padding: 20px 8px 16px;
  }
  .games-arcade-icon {
    font-size: 2.6em;
  }
  .games-arcade-title {
    font-size: 0.76em;
  }
  .games-arcade-desc {
    font-size: 0.58em;
  }
}

@media (max-width: 380px) {
  .games-arcade-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 4px;
  }
  .games-arcade-tile {
    padding: 16px 6px 12px;
  }
}

/* ============================================================
   MINIGAME MODAL — Cocktail Arcade Cabinet overlay
   ============================================================ */

.minigame-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.6s ease;
  /* Strong perspective so the roll-in reads as real depth.
     JS strips this after animation for clean canvas coords. */
  perspective: 1400px;
  perspective-origin: 50% 35%;
}

.minigame-overlay-open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.92);
}

/* ── The 3D scene container — transforms managed by JS ── */
.minigame-cabinet-scene {
  position: relative;
  /* transform-style, transform, transition all set/stripped by JS
     to ensure clean canvas coordinate space after animation */
}

/* ── Cabinet body: the cocktail table ── */
.minigame-cabinet {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Desktop: ~70% larger than the old 600×460 */
  width: min(1020px, calc(100vw - 48px));
  max-height: min(780px, calc(100vh - 80px));
  background: #0d0d0d;
  border-radius: 14px;
  /* visible during 3D roll-in so box-depth faces aren't clipped;
     JS restores overflow:hidden after the animation lands. */
  overflow: visible;
  /* Cabinet body: dark frame with blue-black inlay */
  border: 3px solid #1a1a2a;
  box-shadow:
    /* Inner phosphor glow on the monitor bezel */
    inset 0 0 20px rgba(28, 255, 155, 0.06),
    /* Outer cabinet shadow + ambient glow */
    0 8px 60px rgba(0, 0, 0, 0.8),
    0 0 2px var(--phosphor-dim, #1a6b4a),
    0 0 30px rgba(28, 255, 155, 0.05);
}

/* ── Arcade table legs (decorative, desktop only) ── */
.minigame-cabinet-legs {
  display: none;
}
@media (min-width: 769px) {
  .minigame-cabinet-legs {
    display: flex;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
    z-index: -1;
  }
  .minigame-cabinet-leg {
    width: 10px;
    height: 60px;
    background: linear-gradient(180deg, #1c1c2e 0%, #111122 40%, #0a0a14 100%);
    border-radius: 0 0 4px 4px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid #1a1a2a;
    border-top: none;
  }
  /* Floor pads */
  .minigame-cabinet-leg::after {
    content: '';
    display: block;
    width: 20px;
    height: 5px;
    background: #16161e;
    border-radius: 2px;
    margin-left: -5px;
    margin-top: -1px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  }
}

/* ── Monitor bezel (terminal metal frame) ── */
.minigame-monitor-bezel {
  background:
    linear-gradient(180deg,
      #1c1c28 0%, #141420 8%, #0e0e18 50%, #141420 92%, #1c1c28 100%);
  border: 2px solid #222238;
  border-radius: 10px;
  margin: 10px;
  padding: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 -1px 0 rgba(0,0,0,0.4),
    0 0 12px rgba(28, 255, 155, 0.04);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Subtle CRT scanline overlay */
.minigame-monitor-bezel::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  border-radius: 8px;
  z-index: 2;
}

/* ── Header bar inside bezel ── */
.minigame-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(28, 255, 155, 0.15);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 3;
}

.minigame-modal-title {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.8em;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor, #1cff9b);
  text-shadow: 0 0 8px var(--phosphor-glow, rgba(28, 255, 155, 0.4));
}

.minigame-modal-close {
  background: none;
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  color: var(--phosphor, #1cff9b);
  font-size: 1.2em;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  z-index: 3;
}

.minigame-modal-close:hover {
  border-color: var(--phosphor, #1cff9b);
  background: rgba(28, 255, 155, 0.12);
}

/* ── Canvas (the CRT screen) ── */
.minigame-canvas {
  display: block;
  background: #060808;
  image-rendering: pixelated;
  /* No flex:1 or width:100% — sizeCanvas() sets explicit pixel dims.
     flex/width would stretch the display beyond the buffer → pixelation. */
  flex: none;
  min-height: 0;
  position: relative;
  z-index: 1;
}

/* ── Footer / controls strip ── */
.minigame-modal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border-top: 1px solid rgba(28, 255, 155, 0.15);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 3;
}

.minigame-controls-hint {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.6em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
}

/* ── Control panel strip (arcade buttons decoration) ── */
.minigame-control-panel {
  display: none;
}
@media (min-width: 769px) {
  .minigame-control-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 12px 28px 18px;
    /* Angled toward viewer like a real cocktail table control face */
    perspective: 500px;
    transform-style: preserve-3d;
    transform: rotateX(20deg);
    transform-origin: top center;
    /* Surface: distinctly lighter than the black overlay so it reads */
    background: linear-gradient(180deg, #22223a 0%, #1a1a2e 50%, #14142a 100%);
    border-top: 2px solid rgba(28, 255, 155, 0.35);
    box-shadow:
      inset 0 4px 12px rgba(0, 0, 0, 0.7),
      0 -1px 0 rgba(28, 255, 155, 0.18);
    border-radius: 0 0 12px 12px;
    position: relative;
  }
  /* Phosphor accent seam where the table face meets the monitor */
  .minigame-control-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 3px;
    background: rgba(28, 255, 155, 0.25);
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 8px rgba(28, 255, 155, 0.3);
  }
  /* Buttons: 3D pucks that pop off the surface */
  .minigame-arcade-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    box-shadow:
      inset 0 2px 5px rgba(255, 255, 255, 0.22),
      inset 0 -2px 4px rgba(0, 0, 0, 0.5),
      0 4px 0 rgba(0, 0, 0, 0.7),
      0 5px 10px rgba(0, 0, 0, 0.55);
    transform: translateZ(14px);
    transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.07s ease;
    cursor: default;
  }
  /* Button depressed — toggled by JS on keypress */
  .minigame-arcade-btn.btn-pressed {
    transform: translateZ(3px);
    box-shadow:
      inset 0 3px 6px rgba(0, 0, 0, 0.6),
      0 1px 0 rgba(0, 0, 0, 0.7);
    filter: brightness(1.6) saturate(1.3);
  }
  .minigame-arcade-btn.btn-red    { background: radial-gradient(circle at 38% 32%, #ff7777 0%, #dd1111 45%, #880808 100%); }
  .minigame-arcade-btn.btn-yellow { background: radial-gradient(circle at 38% 32%, #ffee66 0%, #ddaa00 45%, #886600 100%); }
  .minigame-arcade-btn.btn-blue   { background: radial-gradient(circle at 38% 32%, #7799ff 0%, #1144ee 45%, #0a2299 100%); }
  .minigame-arcade-btn.btn-white  { background: radial-gradient(circle at 38% 32%, #ffffff 0%, #ccccee 45%, #8888aa 100%); }
  /* Joystick — taller shaft, red ball top */
  .minigame-joystick {
    width: 14px;
    height: 32px;
    background: linear-gradient(180deg, #4a4a5a 0%, #2a2a38 50%, #1a1a24 100%);
    border-radius: 7px 7px 4px 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 2px 0 4px rgba(0,0,0,0.5), 0 4px 10px rgba(0,0,0,0.6);
    transform: translateZ(20px);
    transition: transform 0.07s ease;
    position: relative;
  }
  /* Joystick deflected — toggled by JS on arrow/WASD keypress */
  .minigame-joystick.joystick-left  { transform: translateZ(12px) rotateZ(-18deg); }
  .minigame-joystick.joystick-right { transform: translateZ(12px) rotateZ(18deg); }
  .minigame-joystick.joystick-up    { transform: translateZ(12px) rotateX(-18deg); }
  .minigame-joystick.joystick-down  { transform: translateZ(12px) rotateX(18deg); }
  .minigame-joystick::after {
    content: '';
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #ee3333 0%, #aa1111 55%, #770a0a 100%);
    position: absolute;
    top: -14px;
    left: -4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -2px 6px rgba(0,0,0,0.5), inset 0 1px 5px rgba(255,255,255,0.2);
  }
}

/* ── Cabinet 3D box faces — give the table real depth during roll-in ──
   These stay inside the cabinet (position:absolute). Cabinet has
   overflow:visible so the rotated faces can extend beyond its bounds.
   Bezel's overflow:hidden handles canvas clipping independently.
   At identity (face-on) they're perpendicular to screen = invisible.
   During the tilted roll-in they sell the cocktail table cube depth.   */

.minigame-cab-depth {
  position: absolute;
  pointer-events: none;
  backface-visibility: hidden;
}

.minigame-cab-depth.cab-left {
  top: 0;
  left: 0;
  width: 80px;           /* exaggerated table thickness */
  height: 100%;
  transform-origin: left center;
  transform: rotateY(90deg);     /* left edge stays, right edge goes INTO screen */
  background: linear-gradient(to right, #0c0c1a 0%, #070710 100%);
  border-right: 1px solid #1a1a2a;
}

.minigame-cab-depth.cab-right {
  top: 0;
  right: 0;
  left: auto;
  width: 80px;
  height: 100%;
  transform-origin: right center;
  transform: rotateY(-90deg);
  background: linear-gradient(to left, #0c0c1a 0%, #070710 100%);
  border-left: 1px solid #1a1a2a;
}

.minigame-cab-depth.cab-bottom {
  bottom: 0;
  left: 0;
  top: auto;
  width: 100%;
  height: 80px;
  transform-origin: center bottom;
  transform: rotateX(-90deg);    /* bottom edge stays, top goes INTO screen (underside of table) */
  background: linear-gradient(180deg, #0c0c18 0%, #050509 100%);
  border-top: 2px solid #1a1a2a;
}

.minigame-cab-depth.cab-back {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateZ(-80px);
  background: #040408;
  border: 2px solid #111122;
  border-radius: 14px;
}

/* ── Pause overlay (shown on outside-click / escape) ── */
.minigame-pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border-radius: 10px;
}

.minigame-pause-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.minigame-pause-title {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 1.3em;
  font-weight: bold;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--phosphor, #1cff9b);
  text-shadow: 0 0 12px var(--phosphor-glow, rgba(28, 255, 155, 0.5));
}

.minigame-pause-btn {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.85em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--phosphor, #1cff9b);
  background: rgba(28, 255, 155, 0.06);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  padding: 10px 32px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-width: 180px;
  text-align: center;
}

.minigame-pause-btn:hover {
  background: rgba(28, 255, 155, 0.12);
  border-color: var(--phosphor, #1cff9b);
  box-shadow: 0 0 10px var(--phosphor-glow, rgba(28, 255, 155, 0.2));
}

.minigame-pause-btn.exit-btn {
  color: #ff6655;
  border-color: rgba(255, 100, 80, 0.3);
  background: rgba(255, 80, 60, 0.05);
}

.minigame-pause-btn.exit-btn:hover {
  background: rgba(255, 80, 60, 0.12);
  border-color: #ff6655;
  box-shadow: 0 0 10px rgba(255, 80, 60, 0.2);
}

/* ── Mobile: simpler, near-fullscreen ── */
@media (max-width: 768px) {
  .minigame-cabinet {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 32px);
    border-radius: 8px;
    border-width: 2px;
  }
  .minigame-monitor-bezel {
    margin: 4px;
    border-radius: 6px;
  }
}

/* ============================================================
   CLICKABLE PUZZLE ITEMS
   ============================================================ */

.games-item-playable {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.games-item-playable:hover {
  background: rgba(28, 255, 155, 0.04);
}

.games-item-playable:active {
  background: rgba(28, 255, 155, 0.08);
}

/* ============================================================
   PUZZLE POPUP — Fullscreen overlay for interactive puzzles
   ============================================================ */

.puzzle-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99998;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.puzzle-popup-visible {
  opacity: 1;
}

.puzzle-popup-closing {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.puzzle-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.puzzle-popup-container {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg, #0a0a0a);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-radius: 8px;
  box-shadow:
    0 0 40px rgba(0, 0, 0, 0.6),
    0 0 12px var(--phosphor-glow, rgba(28, 255, 155, 0.1));
  scrollbar-width: thin;
  scrollbar-color: var(--phosphor-dim, #1a6b4a) transparent;
}

.puzzle-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--phosphor-dim, #1a6b4a);
}

.puzzle-popup-title {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.8em;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor, #1cff9b);
  text-shadow: 0 0 6px var(--phosphor-glow, rgba(28, 255, 155, 0.3));
}

.puzzle-popup-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid rgba(220, 40, 40, 0.6);
  background: rgba(180, 30, 30, 0.85);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 0 2px 8px rgba(180, 30, 30, 0.3);
  flex-shrink: 0;
}

.puzzle-popup-close:hover {
  background: rgba(220, 40, 40, 0.95);
  border-color: rgba(255, 60, 60, 0.8);
}

.puzzle-popup-body {
  padding: 14px;
}

/* ---- Dead Drop Cipher puzzle styles ---- */

.puzzle-ddc {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  color: var(--phosphor, #1cff9b);
}

.puzzle-ddc-briefing {
  margin-bottom: 12px;
}

.puzzle-ddc-label {
  display: block;
  font-size: 0.65em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
  margin-bottom: 4px;
}

.puzzle-ddc-flavor {
  font-size: 0.72em;
  line-height: 1.5;
  color: var(--phosphor-dim, #1a6b4a);
  margin: 0;
}

.puzzle-ddc-cipher {
  background: rgba(28, 255, 155, 0.04);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 12px;
}

.puzzle-ddc-cipher-label {
  display: block;
  font-size: 0.6em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
  margin-bottom: 6px;
}

.puzzle-ddc-cipher-text {
  font-size: 1em;
  letter-spacing: 0.2em;
  font-weight: bold;
  word-break: break-all;
  text-shadow: 0 0 8px var(--phosphor-glow, rgba(28, 255, 155, 0.3));
}

/* Key table */
.puzzle-keytable {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.puzzle-keytable-label {
  font-size: 0.58em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
  margin-bottom: 2px;
}

.puzzle-keytable-row {
  font-size: 0.72em;
  letter-spacing: 0.18em;
  white-space: nowrap;
  margin-bottom: 6px;
}

/* Answer input */
.puzzle-ddc-answer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.puzzle-ddc-answer-label {
  font-size: 0.62em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--phosphor-dim, #1a6b4a);
}

.puzzle-ddc-input {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.85em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-radius: 4px;
  color: var(--phosphor, #1cff9b);
  outline: none;
  transition: border-color 0.15s;
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

.puzzle-ddc-input:focus {
  border-color: var(--phosphor, #1cff9b);
  box-shadow: 0 0 8px var(--phosphor-glow, rgba(28, 255, 155, 0.2));
}

.puzzle-ddc-input:disabled {
  opacity: 0.5;
  cursor: default;
}

.puzzle-ddc-submit {
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.75em;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 16px;
  background: rgba(28, 255, 155, 0.08);
  border: 1px solid var(--phosphor-dim, #1a6b4a);
  border-radius: 4px;
  color: var(--phosphor, #1cff9b);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.puzzle-ddc-submit:hover:not(:disabled) {
  background: rgba(28, 255, 155, 0.15);
  border-color: var(--phosphor, #1cff9b);
}

.puzzle-ddc-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Feedback messages */
.puzzle-ddc-feedback {
  min-height: 1.5em;
  font-size: 0.72em;
  letter-spacing: 0.06em;
}

.puzzle-ddc-success {
  color: var(--phosphor, #1cff9b);
  text-shadow: 0 0 6px var(--phosphor-glow, rgba(28, 255, 155, 0.3));
}

.puzzle-ddc-error {
  color: #ff6b6b;
}
