/* ============================================================
   Game shell styles: canvas frame, HTML overlays, touch controls.
   The internal logical canvas is 960×720, scaled with `contain`.
   ============================================================ */

.game-page main {
  max-width: 64rem;
}

/* The [hidden] attribute must always win, even over display:flex rules. */
.game-wrap [hidden] {
  display: none !important;
}

.game-wrap {
  position: relative;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}

.game-chrome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.2rem;
}
.game-score {
  font-family: var(--font-stamp);
  font-weight: 700;
  font-size: clamp(1rem, 3vw, 1.4rem);
  letter-spacing: 0.12em;
  background: var(--ink);
  color: var(--paper);
  padding: 0.3rem 0.8rem;
  transform: rotate(-1deg);
}
.game-mute {
  font-size: 1.4rem;
  min-width: 44px;
  min-height: 44px;
  border: 3px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
}
.game-mute[aria-pressed="true"] { background: var(--nicotine); }
.game-mute.pulse { animation: mute-pulse 0.8s ease 3; }
@keyframes mute-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); box-shadow: 0 0 0 4px var(--stamp-red); }
}
@media (prefers-reduced-motion: reduce) {
  .game-mute.pulse { animation: none; }
}

/* ---- Stage: the decorative paper margin frame around the canvas ---- */
.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: min(78vh, 720px);
  margin: 0 auto;
  background: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--shadow);
  overflow: hidden;
  touch-action: none; /* gestures blocked ONLY inside the game area */
}
.game-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- HTML overlays above the canvas ---- */
.game-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.game-titlecard {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-1.5deg);
  width: max-content;
  max-width: 94%;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 1.4rem 2rem;
  text-align: center;
  font-family: var(--font-stamp);
}
.game-titlecard .tc-title {
  /* Header: double the old size. */
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.1;
  display: block;
}
.game-titlecard .tc-subtitle {
  /* Body text: triple the old size. */
  font-size: clamp(1.95rem, 6vw, 2.4rem);
  line-height: 1.2;
  display: block;
  margin-top: 0.5rem;
}
.game-titlecard .tc-controls {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: clamp(2.25rem, 7vw, 2.85rem);
  line-height: 1.15;
  background: var(--nicotine);
  border: 2px solid var(--ink);
  padding: 0.2rem 0.9rem;
  letter-spacing: 0.06em;
}

.game-caption {
  position: absolute;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  max-width: 92%;
  background: rgba(28, 26, 23, 0.92);
  color: #fff;
  font-size: clamp(0.85rem, 2.6vw, 1.1rem);
  padding: 0.35rem 0.8rem;
  text-align: center;
  border-radius: 2px;
}

/* Synthetic media badges: persistent, high-contrast, never auto-hidden early */
.game-badges {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 6;
}
.media-badge {
  font-family: var(--font-stamp);
  font-weight: 700;
  font-size: clamp(0.6rem, 1.8vw, 0.75rem);
  letter-spacing: 0.08em;
  padding: 0.25rem 0.5rem;
  border: 2px solid #fff;
  background: #000;
  color: #ffec3d;
}
.media-badge.badge-image {
  background: #000;
  color: #7ff7ff;
  font-size: clamp(0.55rem, 1.6vw, 0.65rem);
}

/* ---- Intro / fallback panels inside the stage ---- */
.game-intro, .game-fallback {
  position: absolute;
  inset: 0;
  margin: 0;
  z-index: 10;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.2rem;
  transform: none;
}
.intro-title {
  font-family: var(--font-stamp);
  letter-spacing: 0.2em;
  border: 3px double var(--ink);
  padding: 0.3rem 1.2rem;
  font-size: clamp(1rem, 3vw, 1.5rem);
}
.intro-text { max-width: 34rem; font-size: clamp(0.9rem, 2.5vw, 1.05rem); }
.intro-small { max-width: 34rem; font-size: 0.8rem; opacity: 0.85; }
.intro-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.btn-civil { font-size: 0.85rem; }
.btn-bribe {
  font-size: 0.85rem;
  background: var(--envelope-gold);
}

/* ---- Touch controls below the canvas ---- */
.game-touch {
  display: none;
  justify-content: center;
  gap: 0.8rem;
  padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
  flex-wrap: wrap;
}
.game-touch.active { display: flex; }
.touch-btn {
  font-family: var(--font-stamp);
  font-weight: 700;
  font-size: 1.6rem;
  min-width: 72px;
  min-height: 64px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer;
  touch-action: none;
}
.touch-btn:active { background: var(--nicotine); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.touch-btn.touch-wide { min-width: 180px; font-size: 1.1rem; letter-spacing: 0.1em; }

/* ---- Result / share screen overlay (HTML, over canvas) ---- */
.game-result {
  position: absolute;
  inset: 0;
  z-index: 9;
  overflow-y: auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  gap: 0.5rem;
}
.result-score {
  font-family: var(--font-stamp);
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 0;
}
.result-appointment {
  font-size: clamp(1rem, 3.4vw, 1.5rem);
  font-weight: 700;
  color: var(--stamp-red);
  max-width: 34rem;
  margin: 0;
}
.result-gag { font-style: italic; margin: 0.2rem 0; }
.result-unlock {
  background: var(--nicotine);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--shadow);
  font-family: var(--font-note);
  max-width: 30rem;
  padding: 0.7rem 1rem;
  transform: rotate(-1deg);
}

/* ---- Bribe mode: the full menu of assessments ---- */
.bribe-menu { justify-content: flex-start; }
.bribe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.4rem;
  width: 100%;
  max-width: 56rem;
  margin: 0.5rem 0;
}
.bribe-game {
  font-size: 0.72rem;
  padding: 0.6rem 0.4rem;
  margin: 0;
}
.result-disclaimer { font-size: 0.75rem; opacity: 0.85; max-width: 32rem; }
.result-share { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }

/* Debug panel */
.debug-panel {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  z-index: 20;
  background: rgba(0,0,0,0.85);
  color: #0f0;
  font-family: var(--font-stamp);
  font-size: 0.7rem;
  padding: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: 60%;
}
.debug-panel button {
  font-size: 0.65rem;
  background: #222;
  color: #0f0;
  border: 1px solid #0f0;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

/* Portrait phones: chrome above, controls below, stage full width */
@media (max-width: 700px) and (orientation: portrait) {
  .game-page main { padding: 0.3rem; }
  .game-stage { max-height: 62vh; }
}
