/* Visual Layout - 9:17 frame, decorative slots, theme panel */

@font-face {
  font-family: 'Kelmscott Roman NF';
  src: url('../fonts/KelmscottRomanNf.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Viewport: holds frame + theme panel side by side */
.visual-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
  min-height: 0;
  position: relative;
  background: var(--bg-primary);
}

/* Frame: strict 9:17, positioned container for canvas + slots */
.visual-frame {
  flex: none;
  position: relative;
  overflow: visible;
  background: #000000;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Canvas container inside frame — below decorative slots, overflow visible for editor panels */
.visual-frame > .canvas-container {
  flex: none;
  position: relative;
  z-index: 1;
  overflow: visible;
  background: transparent;
}

/* Compact mode: nudge canvas up so bucket clears the dock */
.visual-frame--compact > .canvas-container {
  top: calc(-1 * var(--compact-canvas-nudge, 0px));
}

/* Background slot layer — behind canvas for columns etc. */
.visual-slot-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4px;
  z-index: 0;
  pointer-events: none;
}

/* Slot clip layer — clips decorative assets to frame bounds */
.visual-slot-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4px;
  z-index: auto;
  pointer-events: none;
}

/* ─── Slot elements ─────────────────────────────── */

.visual-slot {
  position: absolute;
  pointer-events: none;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  /* z-index set inline by _applyLayerOrder() */
  aspect-ratio: 1;
  transform-origin: center;
  transition: box-shadow 0.15s, outline 0.15s,
              transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.24s ease,
              filter 0.24s ease;
}

/* Column slots: full-height vertical strips, not square */
.visual-slot[data-slot-id="columnLeft"],
.visual-slot[data-slot-id="columnRight"] {
  aspect-ratio: unset;
  height: 100%;
  background-size: 100% 100%;
  /* darken controlled inline via filter: brightness() from config */
}

.visual-slot--portrait-runtime {
  background-image: none !important;
  overflow: hidden;
}

.visual-portrait-layer {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  transition-property: opacity;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;
}

.pvp-target-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 11;
}

.pvp-target-slot {
  position: absolute;
  aspect-ratio: 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition:
    left 0.24s ease,
    top 0.24s ease,
    width 0.24s ease,
    height 0.24s ease,
    opacity 0.2s ease,
    filter 0.24s ease;
}

.pvp-target-slot--characterCircle { z-index: 1; }
.pvp-target-slot--healthCircle { z-index: 2; }
.pvp-target-slot--healthCharCircle { z-index: 3; }

.pvp-aim-timer-ring {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, left 0.24s ease, top 0.24s ease, width 0.24s ease, height 0.24s ease;
  filter: drop-shadow(0 0 5px rgba(235, 255, 235, 0.55));
  z-index: 12;
}

.pvp-aim-timer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.pvp-aim-timer-track,
.pvp-aim-timer-arc {
  fill: none;
  stroke-linecap: round;
}

.pvp-aim-timer-track {
  stroke: rgba(235, 255, 235, 0.14);
  stroke-width: 5.2;
}

.pvp-aim-timer-arc {
  stroke: rgba(235, 255, 235, 0.98);
  stroke-width: 5.2;
  stroke-dasharray: 138.5;
  stroke-dashoffset: var(--pvp-timer-dash-offset, 0);
  transition: stroke-dashoffset 90ms linear;
}

.visual-frame--pvp .visual-slot[data-slot-id="itemCircle"],
.visual-frame--pvp .visual-slot[data-slot-id="arrow"] {
  opacity: 0;
  pointer-events: none;
}

.survival-column-progress-marker {
  position: absolute;
  width: clamp(13px, 3.7%, 21px);
  height: clamp(9px, 2.2%, 15px);
  transform: translate(0, -50%);
  pointer-events: none;
  z-index: 12;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.74));
}

.survival-column-progress-marker__inner {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 68% 0, 100% 50%, 68% 100%, 0 100%);
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0) 42%),
    linear-gradient(90deg, #b8c0c8 0%, #f7fbff 46%, #ffffff 100%);
  box-shadow:
    inset 0 -1px 2px rgba(55, 65, 81, 0.48),
    inset 0 1px 1px rgba(255, 255, 255, 0.86);
}

/* In edit mode: slots become interactive */
.visual-slot--editable {
  pointer-events: auto;
  cursor: grab;
  outline: 1px dashed rgba(255, 255, 255, 0.25);
  outline-offset: -1px;
}

.visual-slot--editable:hover {
  outline-color: rgba(88, 166, 255, 0.5);
}

.visual-slot--selected {
  outline: 2px solid #58a6ff !important;
  outline-offset: -2px;
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.3);
  z-index: 20 !important;
}

.visual-slot--editable:active {
  cursor: grabbing;
}

/* Editing mode indicator on frame */
.visual-frame--editing {
  outline: 2px dashed rgba(88, 166, 255, 0.4);
  outline-offset: -2px;
}

/* Spin mode: fade decorations */
.visual-frame--spin .visual-slot {
  opacity: 0;
  transition: opacity 0.3s;
}

.visual-frame--gamble-ui .visual-slot[data-slot-id="arrow"],
.visual-frame--gamble-ui .visual-slot[data-slot-id="itemCircle"] {
  opacity: 0;
}

/* ─── Theme Panel ───────────────────────────────── */

.theme-panel {
  width: 200px;
  max-height: 100%;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
}

.theme-panel.hidden {
  display: none;
}

.theme-panel-title {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.theme-panel-body {
  padding: 6px 8px 8px;
}

.theme-section {
  margin-bottom: 8px;
}

.theme-section:last-child {
  margin-bottom: 0;
}

.theme-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 0;
}

.theme-row-label {
  font-size: 10px;
  color: var(--text-secondary);
}

.theme-select {
  padding: 2px 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 10px;
  cursor: pointer;
}

.theme-color {
  width: 28px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  background: none;
}

.theme-edit-btn {
  width: 100%;
  padding: 5px 0;
  margin-bottom: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 10px;
  cursor: pointer;
  text-align: center;
}

.theme-edit-btn:active {
  background: var(--border);
}

.theme-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.theme-row-state {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.theme-row-btn {
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 10px;
  cursor: pointer;
  line-height: 1.3;
}

.theme-row-btn:active {
  background: var(--border);
}

.theme-row-btn.is-active,
.theme-edit-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-row-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.theme-row-btn--secondary {
  color: var(--text-dim);
}

.theme-row-range {
  width: 78px;
  height: 3px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-primary);
  border-radius: 2px;
  cursor: pointer;
}

.theme-row-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.theme-range-value {
  min-width: 32px;
  font-size: 9px;
  color: var(--text-dim);
  text-align: right;
}

/* Slot list in panel */
.theme-slot-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.theme-slot-row {
  padding: 4px 5px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
}

.theme-slot-row.selected {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

.theme-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-slot-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.theme-slot-toggle input[type="checkbox"] {
  width: 12px;
  height: 12px;
  cursor: pointer;
}

.theme-slot-name {
  font-size: 10px;
  color: var(--text-secondary);
}

.theme-slot-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.theme-slot-scale {
  flex: 1;
  height: 3px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-primary);
  border-radius: 2px;
  cursor: pointer;
}

.theme-slot-scale::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* Layer reorder buttons */
.theme-slot-layer-btns {
  display: flex;
  gap: 1px;
  flex-shrink: 0;
}

.theme-layer-btn {
  width: 16px;
  height: 14px;
  padding: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-dim);
  font-size: 7px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-layer-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--text-primary);
}

.theme-layer-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Scale number input */
.theme-slot-scale-num {
  width: 36px;
  padding: 1px 2px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 9px;
  text-align: center;
  -moz-appearance: textfield;
}

.theme-slot-scale-num::-webkit-inner-spin-button,
.theme-slot-scale-num::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.theme-slot-upload,
.theme-slot-reset {
  padding: 1px 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 8px;
  cursor: pointer;
}

.theme-slot-upload:active,
.theme-slot-reset:active {
  background: var(--border);
}

/* ─── Ball Counter ──────────────────────────────── */

.bc-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.bc-dot {
  position: absolute;
  width: var(--bc-dot-size, 11%);
  height: var(--bc-dot-size, 11%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.5s ease-in-out, top 0.5s ease-in-out,
              width 0.3s ease, height 0.3s ease,
              opacity 0.4s ease, background 0.3s ease;
}

.bc-dot--filled {
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.bc-dot--empty {
  background: rgba(255, 255, 255, 0.15);
  opacity: 0.4;
  transform: translate(-50%, -50%) scale(0.7);
}

.bc-dot--popping {
  animation: bc-pop 0.4s ease-out;
}

@keyframes bc-pop {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.6); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(0.7); opacity: 0.4; }
}

.bc-dot--appearing {
  animation: bc-appear 0.4s ease-out;
}

@keyframes bc-appear {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.bc-number {
  position: absolute;
  inset: 15%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif', Georgia, serif;
  font-weight: 700;
  color: #fff;
  font-size: var(--bc-font-size, 20px);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  line-height: 1;
}

/* ─── Health Bar (orange pegs indicator) ─────────── */

.health-clip {
  position: absolute;
  inset: 0;
  transition: filter 0.3s ease-out;
}

.health-fill {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: clip-path 0.25s ease-out, background 0.3s ease;
}

/* Health circle: subtle glow transition */
.visual-slot[data-slot-id="healthCircle"] {
  transition: box-shadow 0.3s ease-out,
              transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.24s ease,
              filter 0.24s ease;
}

/* Health char circle: subtle glow */
.visual-slot[data-slot-id="healthCharCircle"] {
  transition: box-shadow 0.3s ease-out,
              transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.24s ease,
              filter 0.24s ease;
}

/* Color picker row in slot controls */
.theme-slot-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
}

.theme-slot-color {
  width: 28px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  background: none;
}

/* ─── Editor panels repositioned outside frame ──── */
/* When panels are reparented into .visual-frame, position them
   to the LEFT of the frame so they don't cover the gameplay area */

.visual-frame > .anim-panel {
  left: auto;
  right: calc(100% + 6px);
}

.visual-frame > .bumper-panel {
  left: auto;
  right: calc(100% + 6px);
  z-index: 34;
}

.visual-frame > .survival-panel {
  left: auto;
  right: calc(100% + 6px);
  top: 8px;
}

.visual-frame > .mode-panel-stack {
  left: auto;
  right: calc(100% + 6px);
  top: 8px;
}

.visual-frame > .aim-length-panel {
  left: auto;
  right: calc(100% + 6px);
  bottom: 8px;
}

/* ─── Responsive ────────────────────────────────── */

/* On narrow screens, hide theme panel by default */
@media (max-width: 540px) {
  .theme-panel {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 160px;
    max-height: 80%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(22, 27, 34, 0.94);
    display: none;
  }

  .theme-panel.visible-mobile {
    display: block;
  }
}

/* ─── Admin panel (separate column to the right of theme panel) ─── */

.admin-panel {
  width: 180px;
  max-height: 100%;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
}

.admin-panel.hidden {
  display: none;
}

.admin-panel-title {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.admin-panel-body {
  padding: 6px 8px 8px;
}

.admin-panel::-webkit-scrollbar {
  width: 3px;
}
.admin-panel::-webkit-scrollbar-track {
  background: transparent;
}
.admin-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.admin-input {
  width: 100%;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 0 6px;
  font-size: 11px;
  margin-bottom: 4px;
}

.admin-select {
  width: 100%;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 10px;
  padding: 0 4px;
  margin-bottom: 4px;
}

.admin-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  cursor: pointer;
}

.admin-toggle input[type="checkbox"] {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.admin-btn {
  display: block;
  width: 100%;
  padding: 4px 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 10px;
  cursor: pointer;
  margin-bottom: 3px;
  text-align: center;
}

.admin-btn:active {
  background: var(--border);
}

.admin-btn--danger {
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.3);
}

/* On narrow screens, hide admin panel */
@media (max-width: 700px) {
  .admin-panel {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 21;
    width: 150px;
    max-height: 80%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(22, 27, 34, 0.94);
    display: none;
  }
}

/* Scrollbar */
.theme-panel::-webkit-scrollbar {
  width: 3px;
}
.theme-panel::-webkit-scrollbar-track {
  background: transparent;
}
.theme-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ─── Pause trigger slots (topLeft, leftCircle in player mode) ─── */

.visual-slot--pause-trigger {
  pointer-events: auto !important;
  cursor: pointer;
}

.visual-slot--input-shield {
  pointer-events: auto !important;
  cursor: default;
}

.visual-slot--decorative-inert {
  pointer-events: none !important;
  cursor: default;
}

/* ─── Pause menu overlay ─── */

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.pause-overlay.pause-overlay--instant {
  transition: none !important;
}

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

/* While level-map is open from pause: keep overlay mounted for instant return,
   but make it visually transparent and non-interactive. */
.pause-overlay.pause-overlay--map-mode {
  opacity: 1;
  background: transparent !important;
  pointer-events: none !important;
  transition: none !important;
}

.pause-overlay.pause-overlay--map-mode .pause-panel {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Character portrait elements: always on top (gameplay + pause) */
.visual-slot[data-slot-id="character"],
.visual-slot[data-slot-id="characterCircle"],
.visual-slot[data-slot-id="healthCircle"],
.visual-slot[data-slot-id="healthCharCircle"] {
  z-index: 501 !important;
}

.visual-frame--billiard-top-active .visual-slot[data-slot-id="characterCircle"] {
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-sizing: border-box;
}

/* Level-map mode: hide the live character stack until the map is exiting. */
.visual-frame--level-map-open:not(.visual-frame--level-map-exiting) .visual-slot[data-slot-id="character"],
.visual-frame--level-map-open:not(.visual-frame--level-map-exiting) .visual-slot[data-slot-id="characterCircle"],
.visual-frame--level-map-open:not(.visual-frame--level-map-exiting) .visual-slot[data-slot-id="healthCircle"],
.visual-frame--level-map-open:not(.visual-frame--level-map-exiting) .visual-slot[data-slot-id="healthCharCircle"] {
  display: none !important;
}

/* Keep the decorative frame and map exit controls above level-map overlay. */
.visual-frame--level-map-open .visual-slot[data-slot-id="columnLeft"],
.visual-frame--level-map-open .visual-slot[data-slot-id="columnRight"],
.visual-frame--level-map-open .visual-slot[data-slot-id="top"],
.visual-frame--level-map-open .visual-slot[data-slot-id="topRight"],
.visual-frame--level-map-open .visual-slot[data-slot-id="leftCircle"],
.visual-frame--level-map-open .visual-slot[data-slot-id="topLeft"] {
  z-index: 701 !important;
}

.visual-frame--level-map-exiting .visual-slot[data-slot-id="rightCircle"],
.visual-frame--level-map-exiting .visual-slot[data-slot-id="ballCounter"],
.visual-frame--level-map-exiting .visual-slot[data-slot-id="character"],
.visual-frame--level-map-exiting .visual-slot[data-slot-id="characterCircle"],
.visual-frame--level-map-exiting .visual-slot[data-slot-id="healthCircle"],
.visual-frame--level-map-exiting .visual-slot[data-slot-id="healthCharCircle"] {
  z-index: 701 !important;
}

.visual-frame--level-map-open .visual-slot[data-slot-id="leftCircle"],
.visual-frame--level-map-open .visual-slot[data-slot-id="topLeft"] {
  pointer-events: auto !important;
}

/* Panel: absolutely positioned so bg circle aligns with character portrait */
.pause-panel {
  position: absolute;
  width: 72%;
  aspect-ratio: 600 / 1217;
  left: 49.5%;
  top: 3.7%;
  transform: translateX(-50%);
}

/* Mobile: panel needs to sit higher to align circle with portrait */
@media (max-width: 520px) {
  .pause-panel {
    top: -3.5%;
  }
}

/* Ornate background frame image */
.pause-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

/* Content layer on top of BG image — pushed below the circle area */
.pause-content {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16% 12% 6%;
  gap: 3.5%;
  box-sizing: border-box;
}

/* Title */
.pause-title {
  font-family: 'Noto Serif', serif;
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 500;
  color: #f0f0f0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  letter-spacing: 1px;
  text-align: center;
}

/* Image buttons (continue, again, level) */
.pause-img-btn {
  display: block;
  width: 92%;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.pause-img-btn .pause-img-btn__normal {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  /* Clip extra transparent padding on wider source images (continue.webp=841px vs others~730px) */
  aspect-ratio: 736 / 215;
  object-fit: cover;
}

.pause-img-btn .pause-img-btn__pressed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  opacity: 0;
}

.pause-img-btn:active .pause-img-btn__normal {
  opacity: 0;
}

.pause-img-btn:active .pause-img-btn__pressed {
  opacity: 1;
}

/* Sound toggle button — positioned absolutely so it doesn't affect flex layout */
.pause-sound-btn {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.pause-sound-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.pause-sound-btn .pause-sound-btn__off { display: none; }
.pause-sound-btn .pause-sound-btn__on  { display: block; }
.pause-sound-btn.muted .pause-sound-btn__off { display: block; }
.pause-sound-btn.muted .pause-sound-btn__on  { display: none; }

/* Hint row (text + checkbox) */
.pause-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8%;
  width: 80%;
  padding: 0 2%;
}

.pause-hint__text {
  font-family: 'Noto Serif', serif;
  font-size: clamp(9px, 2.5vw, 13px);
  font-weight: 300;
  color: #8a8a8a;
  line-height: 1.3;
  text-shadow: none;
  flex: 1;
}

/* Ornate checkbox */
.pause-check {
  position: relative;
  width: clamp(28px, 9vw, 48px);
  height: clamp(28px, 9vw, 48px);
  flex: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pause-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.pause-check img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.pause-check__on {
  display: none;
}

.pause-check input:checked ~ .pause-check__off {
  display: none;
}

.pause-check input:checked ~ .pause-check__on {
  display: block;
}

.pvp-room-overlay {
  position: absolute;
  inset: 0;
  z-index: 480;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.pvp-room-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.pvp-room-card {
  width: min(78%, 320px);
  padding: 18px 16px 16px;
  border: 1px solid rgba(220, 235, 220, 0.28);
  border-radius: 8px;
  background: rgba(8, 10, 14, 0.88);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
  color: #f3f7f3;
}

.pvp-room-title {
  font-family: 'Noto Serif', serif;
  font-size: clamp(16px, 4.2vw, 22px);
  letter-spacing: 0;
}

.pvp-room-code {
  margin-top: 8px;
  font-size: clamp(34px, 11vw, 52px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.pvp-room-status {
  min-height: 34px;
  margin: 12px auto 10px;
  font-size: clamp(11px, 3vw, 13px);
  line-height: 1.35;
  color: rgba(235, 245, 235, 0.78);
}

.pvp-room-copy {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(220, 235, 220, 0.24);
  border-radius: 6px;
  background: rgba(238, 255, 238, 0.08);
  color: #f3f7f3;
  font-size: 12px;
  cursor: pointer;
}

.pvp-room-copy:active {
  background: rgba(238, 255, 238, 0.16);
}

.dialogue-layer {
  position: absolute;
  z-index: 620;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.26s ease, visibility 0.26s ease;
}

.visual-frame--paused .dialogue-layer {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.dialogue-layer--mounted {
  visibility: visible;
}

.dialogue-layer--visible {
  opacity: 1;
}

.dialogue-layer--hiding {
  opacity: 0;
}

.dialogue-card {
  width: min(100%, var(--dialogue-max-width, 300px));
  margin: 0 auto;
  text-align: center;
  position: relative;
  isolation: isolate;
}

.dialogue-card::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(108%, calc(var(--dialogue-max-width, 300px) + 24px));
  height: calc(100% + 28px);
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background:
    radial-gradient(circle at center,
      rgba(0, 0, 0, 0.72) 0%,
      rgba(0, 0, 0, 0.56) 42%,
      rgba(0, 0, 0, 0.24) 72%,
      rgba(0, 0, 0, 0) 100%);
  filter: blur(10px);
  z-index: -1;
  pointer-events: none;
}

.dialogue-text {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: var(--dialogue-font-size, 28px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.88),
    0 6px 18px rgba(0, 0, 0, 0.68),
    0 0 20px rgba(0, 0, 0, 0.48);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dialogue-layer[data-lang="en"] .dialogue-text {
  font-family: 'Kelmscott Roman NF', 'Noto Serif', Georgia, serif;
  font-weight: 400;
  line-height: 1.02;
}

.dialogue-segment {
  display: inline;
}
