/* Pony Merge iframe — BRK chrome, fixed logical world, responsive render */

:root {
  --brk-interaction-safe-x: 34px;
  --brk-interaction-safe-y: 30px;
  --pm-ink: #f3e6c8;
  --pm-muted: rgba(243, 230, 200, 0.72);
  --pm-panel: url('../../assets/ui/hud_location_bg2.png');
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  color: var(--pm-ink);
  font-family: 'RDR Lino Regular', 'Hapna Slab Serif', Georgia, serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.pm-root {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  /* Top/left padding gives the frame edge and .pm-glow box-shadow room to
     bleed outward without getting clipped by the iframe edge. */
  padding: 36px 0 0 28px;
  gap: 8px;
  background: transparent;
}

.pm-play-row {
  position: relative;
  display: block;
  /* Play area scaled 15% bigger. HUD gutter (188px) stays fixed since the
     Next/Score boxes are not part of this scale-up. */
  width: min(calc((100% - 188px) * 1.15), calc(min(96vh, 1180px) * 1.127));
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  transform: none;
  margin: 0 0 36px;
}

.pm-stage-wrap {
  position: relative;
  /* Portrait play area, 10% taller than the original 3:4. */
  width: 100%;
  aspect-ratio: 3 / 4.4;
  height: auto;
  max-height: 100%;
  min-height: 0;
  margin: 0;
  isolation: isolate;
  background: transparent;
}

/* Separate layer so 70% inkroller does not fade the playfield or frame. */
.pm-stage-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    url('../../assets/ui/inkroller_1a.png')
      center center / 100% 100% no-repeat;
  opacity: 0.70;
}

.pm-hud {
  position: absolute;
  left: calc(100% + 12px);
  top: 8px;
  flex: none;
  width: 176px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  z-index: 4;
  pointer-events: none;
  padding-top: 0;
}

.pm-hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 176px;
  min-height: 0;
  padding: 10px 12px;
  background: var(--pm-panel) center / 100% 100% no-repeat;
  pointer-events: auto;
}

.pm-hud-label {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pm-muted);
}

.pm-hud-value {
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  line-height: 1;
}

.pm-next {
  width: 144px;
  height: 144px;
  display: block;
}

#pm-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  background: transparent;
  cursor: crosshair;
  touch-action: none;
}

.pm-frame {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    url('../../assets/ui/interaction_frame_square.png')
      center center / 100% 100% no-repeat;
}

.pm-glow {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  border: 2px solid transparent;
  border-radius: 2px;
  box-shadow:
    0 0 0 1px rgba(180, 40, 20, 0.35),
    0 0 18px 2px rgba(190, 50, 20, 0.35),
    inset 0 0 18px rgba(190, 50, 20, 0.18);
  animation: pm-glow-pulse 2.8s ease-in-out infinite;
}

@keyframes pm-glow-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(180, 40, 20, 0.35),
      0 0 14px 2px rgba(190, 50, 20, 0.28),
      inset 0 0 14px rgba(190, 50, 20, 0.14);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(210, 150, 40, 0.45),
      0 0 22px 4px rgba(200, 70, 25, 0.42),
      inset 0 0 20px rgba(210, 140, 40, 0.18);
  }
}

.pm-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -34px;
  margin: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11px;
  color: rgba(201, 191, 173, 0.68);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  pointer-events: none;
  white-space: normal;
  transform: none;
}

.pm-hint kbd {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 3px;
  padding: 0 5px;
  border: 1px solid rgba(231, 222, 202, 0.32);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.48);
  color: rgba(237, 229, 212, 0.9);
  font-family: 'RDR Lino Regular', 'RDRLino', Georgia, serif;
  font-size: 10px;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.04);
  text-transform: none;
  letter-spacing: 0;
}

.pm-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--brk-interaction-safe-y) var(--brk-interaction-safe-x);
  background: rgba(0, 0, 0, 0.55);
}

.pm-overlay.hidden {
  display: none;
}

.pm-overlay-panel {
  width: min(100%, 320px);
  padding: 22px 20px 18px;
  text-align: center;
  background: var(--pm-panel) center / 100% 100% no-repeat;
}

.pm-overlay-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--pm-muted);
}

.pm-overlay-panel h1 {
  margin: 8px 0 6px;
  font-size: 1.55rem;
  font-weight: 400;
}

.pm-overlay-panel p {
  margin: 0 0 16px;
  color: var(--pm-muted);
}

.pm-btn {
  appearance: none;
  border: 1px solid rgba(160, 40, 24, 0.75);
  background: rgba(20, 10, 8, 0.72);
  color: var(--pm-ink);
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 18px;
  cursor: pointer;
}

.pm-btn:hover,
.pm-btn:focus-visible {
  border-color: rgba(210, 150, 50, 0.9);
  outline: none;
}

@media (max-width: 980px) {
  .pm-hint {
    display: none;
  }
}

html.is-mobile-layout .pm-hint {
  display: none;
}

html.is-mobile-layout .pm-root {
  align-items: stretch;
  padding: 14px 0 0;
  overflow: visible;
}

html.is-mobile-layout .pm-play-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
}

html.is-mobile-layout .pm-stage-wrap {
  order: 2;
  width: 100%;
  aspect-ratio: 4 / 5.4;
  max-height: none;
  border-radius: 0;
}

html.is-mobile-layout .pm-hud {
  position: relative;
  order: 1;
  left: auto;
  top: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  height: clamp(72px, 18vw, 98px);
  gap: 0;
  padding: 0 max(12px, env(safe-area-inset-left, 0px)) 0 max(12px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  overflow: visible;
}

html.is-mobile-layout .pm-hud-next {
  grid-column: 1;
}

html.is-mobile-layout .pm-hud-score {
  grid-column: 3;
}

html.is-mobile-layout .pm-hud-block {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 6px 4px 4px;
  transform: none;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}

html.is-mobile-layout .pm-hud-block.pm-hud-next,
html.is-mobile-layout .pm-hud-block.pm-hud-score {
  overflow: visible;
}

html.is-mobile-layout .pm-hud-block.pm-hud-next .pm-hud-label,
html.is-mobile-layout .pm-hud-block.pm-hud-score .pm-hud-label {
  position: relative;
  z-index: 2;
  display: block;
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  line-height: 1;
  text-align: center;
  color: rgba(214, 205, 189, .92);
}

html.is-mobile-layout .pm-hud-label {
  font-size: clamp(0.58rem, 1.8vw, 0.72rem);
}

html.is-mobile-layout .pm-hud-value {
  width: 100%;
  text-align: center;
  font-size: clamp(1.15rem, 4vw, 1.55rem);
}

html.is-mobile-layout .pm-next {
  width: clamp(44px, 12vw, 58px);
  height: clamp(44px, 12vw, 58px);
  flex: 0 0 auto;
  margin: 0 auto -8px;
  transform: scale(1.38);
  transform-origin: top center;
}

@media (max-width: 520px) {
  :root {
    --brk-interaction-safe-x: 18px;
    --brk-interaction-safe-y: 16px;
  }

  .pm-hint {
    font-size: 0.6rem;
  }
}
