/* Perm Ski Classic Game — полностью изолированные стили (.psg-*) */
.psg-wrap {
  --psg-blue: #136dc3;
  --psg-blue-light: #4fa3f7;
  --psg-red: #e63946;
  --psg-green: #2ec4b6;
  --psg-gold: #f4a261;
  --psg-glass: rgba(11, 24, 44, 0.80);
  --psg-border: rgba(255, 255, 255, 0.16);

  position: relative;
  width: 100%;
  height: min(760px, 84vh);
  min-height: 540px;
  border-radius: 16px;
  overflow: hidden;
  background: #081221;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Manrope", sans-serif;
  box-shadow: 0 16px 48px rgba(8, 22, 46, 0.28);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.page-id-2531 main .wp-block-group .entry-content {
  padding: 0;
}
.psg-wrap *, .psg-wrap *::before, .psg-wrap *::after {
  box-sizing: border-box;
}
/* Safety net against broken external wp-emoji images */
.psg-wrap img.emoji,
.psg-ext-lb img.emoji {
  display: none !important;
}
/* Never break button/badge words mid-word across narrow mobile layouts */
.psg-icon-btn,
.psg-mini-btn,
.psg-badge,
.psg-ctrl-btn,
.psg-save-btn,
.psg-secondary-btn,
.psg-primary-btn,
.psg-duel-btn,
.psg-link-btn,
.psg-account-pb {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
}
.psg-wrap:fullscreen, .psg-wrap.psg-is-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border-radius: 0;
}
.psg-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Broadcast HUD */
.psg-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.psg-hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.psg-hud-top-right {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.psg-tv-card {
  background: var(--psg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--psg-border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.psg-tv-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8ec5ff;
  font-weight: 700;
  margin-bottom: 5px;
}
.psg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--psg-red);
  box-shadow: 0 0 8px var(--psg-red);
}
.psg-race-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.psg-pos-badge {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}
.psg-pos-badge span {
  font-size: 13px;
  font-weight: 600;
  color: #9ab3d0;
}
.psg-timer {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.psg-gap {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.psg-gap.ahead { background: rgba(46, 196, 182, 0.22); color: #6ef3e5; }
.psg-gap.behind { background: rgba(230, 57, 70, 0.25); color: #ff8e97; }
.psg-track-sub {
  font-size: 12px;
  color: #b5cbe3;
  margin-top: 4px;
  display: flex;
  gap: 10px;
}

.psg-telemetry { min-width: 175px; }
.psg-tele-grid {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.psg-speed-val { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.psg-speed-unit { font-size: 11px; color: #9ab3d0; margin-left: 2px; }
.psg-slope-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.psg-slope-pill.up { background: rgba(244, 162, 97, 0.24); color: #ffc68a; }
.psg-slope-pill.down { background: rgba(79, 163, 247, 0.24); color: #9ed0ff; }
.psg-hr-row { margin-top: 7px; }
.psg-hr-head { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; }
.psg-hr-bpm { font-weight: 800; font-variant-numeric: tabular-nums; }
.psg-hr-bar { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.psg-hr-fill { height: 100%; width: 45%; border-radius: 999px; transition: width 0.08s linear, background-color 0.2s; }

.psg-icon-btn {
  pointer-events: auto;
  background: var(--psg-glass);
  border: 1px solid var(--psg-border);
  color: #d9ebff;
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
}
.psg-icon-btn:hover { background: rgba(19, 109, 195, 0.85); color: #fff; }

.psg-hud-center {
  position: absolute;
  top: 17%;
  left: 50%;
  transform: translateX(-50%);
}
.psg-callout {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(19, 109, 195, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(6px) scale(0.95);
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
}
.psg-callout.show { opacity: 1; transform: translateY(0) scale(1); }
.psg-callout.good { background: rgba(25, 163, 146, 0.92); }
.psg-callout.warn { background: rgba(214, 54, 56, 0.92); }
.psg-callout.draft { background: rgba(19, 109, 195, 0.92); }

.psg-countdown {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}
.psg-countdown.show { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }

/* Bottom HUD */
.psg-hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.psg-bottom-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(620px, 96%);
  flex-wrap: wrap;
}
.psg-rhythm-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--psg-glass);
  border: 1px solid var(--psg-border);
  padding: 7px 12px;
  border-radius: 12px;
}
.psg-rhythm-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #a7c4e4; font-weight: 700; }
.psg-rhythm-track {
  position: relative;
  width: 115px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.psg-rhythm-zone {
  position: absolute;
  left: 58%;
  width: 28%;
  top: 0;
  bottom: 0;
  background: rgba(46, 196, 182, 0.55);
  border-left: 1px solid #6ef3e5;
  border-right: 1px solid #6ef3e5;
}
.psg-rhythm-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 8px #fff;
}
.psg-profile-card {
  flex: 1;
  min-width: 220px;
  max-width: 360px;
  padding: 6px 10px;
}
.psg-profile-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #a7c4e4;
  margin-bottom: 3px;
}
#psg-profile-canvas { width: 100%; height: 28px; display: block; }

.psg-controls-bar {
  pointer-events: auto;
  width: min(560px, 96%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.psg-ctrl-group { display: flex; gap: 8px; }
.psg-ctrl-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(13, 30, 56, 0.85);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.06s, background 0.12s;
}
.psg-ctrl-btn:active, .psg-ctrl-btn.active {
  transform: scale(0.95);
  background: rgba(19, 109, 195, 0.96);
}
.psg-ctrl-btn.push {
  background: linear-gradient(135deg, #1680e0, #0f5ca8);
  padding: 12px 22px;
  min-width: 118px;
  box-shadow: 0 4px 16px rgba(19, 109, 195, 0.45);
}
.psg-ctrl-btn.tuck {
  background: linear-gradient(135deg, #244068, #162945);
}
.psg-key-hint {
  font-size: 11px;
  color: rgba(15, 35, 65, 0.78);
  background: rgba(255, 255, 255, 0.72);
  padding: 2px 10px;
  border-radius: 999px;
}

/* Overlays & Modals */
.psg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 17, 34, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 20;
}
.psg-overlay.psg-hidden { display: none; }
.psg-modal {
  width: min(680px, 100%);
  max-height: 94%;
  overflow-y: auto;
  background: linear-gradient(180deg, #102442 0%, #0b182e 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  color: #fff;
}
.psg-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.psg-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #84c5ff;
  background: rgba(19, 109, 195, 0.24);
  border: 1px solid rgba(79, 163, 247, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
}
.psg-modal h2 {
  font-size: 24px;
  font-weight: 900;
  margin: 0 0 6px;
  color: #fff;
  line-height: 1.2;
}
.psg-lead {
  font-size: 13.5px;
  color: #adc4df;
  line-height: 1.45;
  margin: 0 0 12px;
}
.psg-challenge-banner {
  background: linear-gradient(135deg, rgba(244, 162, 97, 0.25), rgba(230, 57, 70, 0.22));
  border: 1px solid rgba(244, 162, 97, 0.55);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #ffe8c8;
  font-weight: 700;
}
.psg-section-lbl {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7ea3cc;
  margin: 12px 0 7px;
}
.psg-cards-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.psg-pick-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 11px;
  cursor: pointer;
  text-align: left;
  color: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.psg-pick-card:hover { background: rgba(255, 255, 255, 0.1); }
.psg-pick-card.selected {
  border-color: #4fa3f7;
  background: rgba(19, 109, 195, 0.26);
  box-shadow: 0 0 0 1px rgba(79, 163, 247, 0.45);
}
.psg-pick-title { font-weight: 800; font-size: 13.5px; margin-bottom: 2px; }
.psg-pick-meta { font-size: 11.5px; color: #9eb9d8; line-height: 1.35; }
.psg-wax-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.psg-style-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.psg-swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  color: #d6e6f8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.psg-swatch.selected {
  border-color: #4fa3f7;
  background: rgba(19, 109, 195, 0.28);
  color: #fff;
}
.psg-swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.psg-primary-btn {
  width: 100%;
  margin-top: 14px;
  padding: 13px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #1b86e6, #115da8);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(19, 109, 195, 0.45);
}
.psg-primary-btn:hover { filter: brightness(1.08); }
.psg-secondary-btn {
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}
.psg-secondary-btn:hover { background: rgba(255, 255, 255, 0.14); }

.psg-lb-preview {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
}
.psg-lb-preview .psg-section-lbl { margin-top: 0; }
.psg-lb-list {
  font-size: 12.5px;
  color: #c2d7ef;
  max-height: 132px;
  overflow-y: auto;
}
.psg-lb-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
}
.psg-lb-row:last-child { border-bottom: none; }
.psg-lb-time { font-weight: 800; color: #7cece0; }

.psg-controls-help {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 11.5px;
  color: #a7c1de;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
}
.psg-controls-help b { color: #fff; }

/* Finish protocol & Save form */
.psg-proto-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.psg-stat-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 9px;
  text-align: center;
}
.psg-stat-box .v { font-size: 17px; font-weight: 800; }
.psg-stat-box .l { font-size: 11px; color: #90aecf; margin-top: 2px; }

.psg-save-form {
  background: rgba(46, 196, 182, 0.12);
  border: 1px solid rgba(46, 196, 182, 0.35);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.psg-save-title { font-size: 12.5px; font-weight: 800; color: #8af3e8; margin-bottom: 8px; }
.psg-save-inputs { display: flex; gap: 8px; flex-wrap: wrap; }
.psg-save-inputs input {
  flex: 1;
  min-width: 140px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 20, 38, 0.85);
  color: #fff;
  font-size: 13px;
  user-select: text;
}
.psg-save-btn {
  padding: 9px 16px;
  border-radius: 9px;
  border: none;
  background: #2ec4b6;
  color: #06211f;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.psg-save-btn:disabled { opacity: 0.6; cursor: default; }
.psg-save-status { font-size: 12px; margin-top: 6px; color: #b8f2eb; }

.psg-challenge-share {
  background: rgba(79, 163, 247, 0.14);
  border: 1px solid rgba(79, 163, 247, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #cfe6ff;
}
.psg-share-row { display: flex; gap: 8px; margin-top: 6px; }
.psg-share-row input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 20, 38, 0.85);
  color: #fff;
  font-size: 12px;
  user-select: all;
}

.psg-proto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.psg-proto-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7ea3cc;
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.psg-proto-table td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-variant-numeric: tabular-nums;
}
.psg-proto-table tr.me {
  background: rgba(46, 196, 182, 0.18);
  font-weight: 800;
}
.psg-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.psg-modal-actions .psg-primary-btn { margin-top: 0; flex: 1; }

/* Account bar, Auth / Profile / Full Leaderboard modals */
.psg-head-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}
.psg-lb-open-btn {
  background: rgba(244, 162, 97, 0.22);
  border-color: rgba(244, 162, 97, 0.5);
  color: #ffe7c2;
}
.psg-lb-open-btn:hover { background: rgba(244, 162, 97, 0.34); }

.psg-account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.psg-account-info {
  font-size: 12.5px;
  color: #cde0f5;
  line-height: 1.35;
}
.psg-account-info b { color: #fff; }
.psg-account-pb {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(46, 196, 182, 0.22);
  color: #7ef2e5;
  font-size: 11px;
  font-weight: 800;
}
.psg-account-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.psg-mini-btn {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.psg-mini-btn:hover { background: rgba(255, 255, 255, 0.16); }
.psg-mini-btn.accent {
  background: linear-gradient(135deg, #2ec4b6, #1f9d91);
  border-color: transparent;
  color: #05221f;
}
.psg-mini-btn.accent:hover { filter: brightness(1.08); }

.psg-lb-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.psg-lb-preview-head .psg-section-lbl { margin: 0; }
.psg-link-btn {
  border: none;
  background: transparent;
  color: #6cb8ff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
}
.psg-link-btn:hover { text-decoration: underline; }

.psg-save-box {
  background: rgba(46, 196, 182, 0.14);
  border: 1px solid rgba(46, 196, 182, 0.42);
  border-radius: 12px;
  padding: 10px 13px;
  margin-bottom: 12px;
}
.psg-save-box .psg-save-status {
  margin-top: 0;
  font-size: 13px;
  font-weight: 700;
  color: #a6f7ee;
}
.psg-save-box.pb {
  background: linear-gradient(135deg, rgba(46, 196, 182, 0.24), rgba(244, 162, 97, 0.22));
  border-color: rgba(244, 162, 97, 0.6);
}
.psg-save-box.error {
  background: rgba(230, 57, 70, 0.18);
  border-color: rgba(230, 57, 70, 0.48);
}

.psg-guest-cta {
  background: linear-gradient(135deg, rgba(19, 109, 195, 0.22), rgba(46, 196, 182, 0.16));
  border: 1px solid rgba(79, 163, 247, 0.45);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.psg-guest-cta-title { font-size: 13.5px; font-weight: 800; color: #fff; margin-bottom: 3px; }
.psg-guest-cta-sub { font-size: 12.5px; color: #bfd8f3; margin: 0 0 10px; }
.psg-guest-cta-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.psg-submodal-overlay { z-index: 30; }
.psg-modal-sm { max-width: 440px; }
.psg-modal-md { max-width: 580px; }
.psg-modal-lg { max-width: 820px; }

/* Live Multiplayer Mode & Room Lobby */
.psg-mode-tabs { margin: 4px 0 10px; }
.psg-hidden { display: none; }
.psg-online-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(19, 109, 195, 0.14);
  border: 1px solid rgba(79, 163, 247, 0.35);
}
.psg-online-guest-row {
  margin-bottom: 10px;
}
.psg-online-guest-row input,
.psg-online-join-row input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 20, 38, 0.85);
  color: #fff;
  font-size: 13px;
  user-select: text;
}
.psg-online-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.psg-online-create-btn {
  margin-top: 0;
  flex: 1;
  min-width: 210px;
}
.psg-online-join-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.psg-online-join-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.psg-open-rooms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 6px;
}
.psg-open-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  font-size: 12.5px;
  color: #bfd6ee;
}
.psg-room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.psg-room-item-meta {
  font-size: 11.5px;
  color: #93b3d6;
}
.psg-lobby-players {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}
.psg-lobby-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.psg-lobby-player.me {
  border-color: rgba(46, 196, 182, 0.55);
  background: rgba(46, 196, 182, 0.14);
}
.psg-lobby-p-left {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}
.psg-lobby-ready-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #b7cde6;
}
.psg-lobby-ready-pill.ready {
  background: rgba(46, 196, 182, 0.28);
  color: #82f5e8;
}
.psg-live-room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(19, 109, 195, 0.2);
  border: 1px solid rgba(79, 163, 247, 0.45);
}
.psg-live-room-status {
  font-size: 12.5px;
  font-weight: 700;
  color: #d6eaff;
}
.psg-live-room-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

.psg-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}
.psg-tab {
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #b7cfe9;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.psg-tab:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.psg-tab.active {
  background: rgba(19, 109, 195, 0.38);
  border-color: #4fa3f7;
  color: #fff;
}

.psg-form { display: flex; flex-direction: column; gap: 10px; }
.psg-form.psg-hidden { display: none; }
.psg-field { display: flex; flex-direction: column; gap: 4px; }
.psg-field label {
  font-size: 12px;
  font-weight: 700;
  color: #a9c4e2;
}
.psg-field input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 20, 38, 0.88);
  color: #fff;
  font-size: 13.5px;
  user-select: text;
}
.psg-field input:focus {
  outline: none;
  border-color: #4fa3f7;
  box-shadow: 0 0 0 2px rgba(79, 163, 247, 0.25);
}
.psg-form-msg {
  font-size: 12.5px;
  min-height: 16px;
  color: #ff99a1;
}
.psg-form-msg.ok { color: #7ef2e5; }

.psg-profile-bests {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.psg-pb-card {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}
.psg-pb-card .t { font-size: 10.5px; color: #8fb1d4; }
.psg-pb-card .v { font-size: 14px; font-weight: 800; color: #7ef2e5; margin-top: 2px; font-variant-numeric: tabular-nums; }

.psg-lb-table-wrap {
  max-height: 390px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.psg-lb-full-table th {
  position: sticky;
  top: 0;
  background: #0d213a;
  z-index: 2;
}
.psg-duel-btn {
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid rgba(244, 162, 97, 0.55);
  background: rgba(244, 162, 97, 0.18);
  color: #ffe3bf;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.psg-duel-btn:hover { background: rgba(244, 162, 97, 0.35); }

/* Standalone leaderboard shortcode [perm_ski_game_leaderboard] */
.psg-ext-lb {
  background: #0c1f38;
  color: #eef5fc;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 18px 0;
}
.psg-ext-lb-head h3 {
  margin: 0 0 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}
.psg-ext-pane.psg-hidden { display: none; }
.psg-ext-lb code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  color: #7ef2e5;
}

/* Touch devices: never show keyboard hint */
@media (pointer: coarse) {
  .psg-key-hint { display: none !important; }
}

/* Portrait & Narrow Mobile Screens */
@media (max-width: 680px) {
  .psg-wrap {
    height: min(86svh, 740px);
    min-height: 480px;
    border-radius: 10px;
  }
  .psg-wrap:fullscreen, .psg-wrap.psg-is-fullscreen {
    height: 100svh;
    min-height: 0;
  }
  .psg-overlay {
    padding: 6px;
    align-items: stretch;
  }
  .psg-modal {
    width: 100%;
    max-height: 100%;
    padding: 13px 12px;
    border-radius: 14px;
  }
  .psg-modal h2 { font-size: 19px; margin-bottom: 8px; }
  .psg-lead { font-size: 12.5px; }
  .psg-badge { font-size: 10px; padding: 4px 8px; letter-spacing: 0.05em; }
  .psg-head-btns { flex-wrap: wrap; gap: 5px; }
  .psg-icon-btn { padding: 6px 9px; font-size: 12px; }
  .psg-account-bar { padding: 8px 10px; gap: 8px; }
  .psg-account-info { font-size: 12px; width: 100%; }
  .psg-account-pb { margin-left: 0; margin-top: 4px; display: inline-block; }
  .psg-account-actions { width: 100%; flex-wrap: wrap; }
  .psg-mini-btn { padding: 7px 11px; font-size: 12px; }
  .psg-tabs { gap: 5px; }
  .psg-tab { font-size: 11.5px; padding: 7px 9px; flex: 1 1 auto; text-align: center; }
  .psg-cards-3 { grid-template-columns: 1fr; }
  .psg-pick-card { padding: 8px 10px; }
  .psg-online-create-btn { min-width: 0; width: 100%; flex: 1 1 100%; }
  .psg-online-join-row { flex-direction: column; }
  .psg-modal-actions { flex-wrap: wrap; }
  .psg-proto-stats { gap: 5px; }
  .psg-stat-box { padding: 7px 4px; }
  .psg-stat-box .v { font-size: 14px; }
  .psg-profile-bests { grid-template-columns: 1fr; }

  /* Portrait Race HUD: move rhythm & profile to upper sky, keep skier 100% clear! */
  .psg-hud {
    padding: max(8px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom));
  }
  .psg-hud-top { gap: 6px; }
  .psg-hud-top-right { gap: 5px; }
  .psg-tv-card { padding: 6px 8px; border-radius: 10px; }
  .psg-tv-brand { font-size: 9px; margin-bottom: 3px; }
  .psg-race-row { gap: 6px; }
  .psg-pos-badge { font-size: 16px; }
  .psg-pos-badge span { font-size: 10px; }
  .psg-timer { font-size: 15px; }
  .psg-gap { font-size: 10px; padding: 2px 5px; }
  .psg-track-sub { font-size: 10px; gap: 6px; }
  .psg-telemetry { min-width: 108px; }
  .psg-speed-val { font-size: 17px; }
  .psg-slope-pill { font-size: 10px; padding: 2px 6px; }
  .psg-hr-row { margin-top: 4px; }
  .psg-hr-head { font-size: 9.5px; }
  .psg-hr-bar { height: 5px; }

  .psg-bottom-strip {
    position: absolute;
    top: 84px;
    left: 8px;
    right: 8px;
    width: auto;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .psg-rhythm-wrap { padding: 5px 8px; gap: 6px; flex-shrink: 0; }
  .psg-rhythm-label { font-size: 9.5px; }
  .psg-rhythm-track { width: 72px; height: 8px; }
  .psg-profile-card { min-width: 0; flex: 1; padding: 4px 7px; }
  .psg-profile-head { font-size: 9px; }
  #psg-profile-canvas { height: 20px; }

  .psg-hud-center { top: 28%; }
  .psg-callout { font-size: 11.5px; padding: 5px 11px; }
  .psg-key-hint { display: none !important; }

  /* Controls pinned strictly to bottom-left and bottom-right corners */
  .psg-controls-bar {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .psg-ctrl-group { gap: 5px; }
  .psg-ctrl-btn {
    padding: 12px 10px;
    font-size: 12px;
    background: rgba(13, 30, 56, 0.72);
  }
  .psg-ctrl-btn.push {
    min-width: 88px;
    padding: 12px 13px;
  }
}

/* Landscape Mobile & Short Viewports (e.g. phones rotated horizontally) */
@media (max-height: 560px) {
  .psg-wrap {
    height: min(92svh, 520px);
    min-height: 300px;
  }
  .psg-wrap:fullscreen, .psg-wrap.psg-is-fullscreen {
    height: 100svh;
    min-height: 0;
  }
  .psg-overlay { padding: 6px; }
  .psg-modal { padding: 12px 14px; max-height: 98%; }
  .psg-modal h2 { font-size: 18px; }

  .psg-hud {
    padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .psg-tv-card { padding: 5px 9px; border-radius: 10px; }
  .psg-tv-brand { display: none; }
  .psg-pos-badge { font-size: 17px; }
  .psg-timer { font-size: 16px; }
  .psg-speed-val { font-size: 18px; }
  .psg-track-sub { font-size: 10px; margin-top: 2px; }
  .psg-telemetry { min-width: 132px; }
  .psg-hr-row { margin-top: 4px; }
  .psg-hr-head { font-size: 10px; }
  .psg-hr-bar { height: 5px; }
  .psg-icon-btn { padding: 5px 9px; font-size: 12px; }

  /* Place Rhythm + Track Profile in the upper sky between the left & right HUD cards! */
  .psg-bottom-strip {
    position: absolute;
    top: 6px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: auto;
    max-width: 42%;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  .psg-rhythm-wrap {
    padding: 4px 9px;
    gap: 6px;
    border-radius: 9px;
  }
  .psg-rhythm-label { font-size: 9.5px; }
  .psg-rhythm-track { width: 92px; height: 8px; }
  .psg-profile-card {
    min-width: 160px;
    max-width: 240px;
    width: 100%;
    padding: 3px 8px;
    border-radius: 9px;
  }
  .psg-profile-head { font-size: 9px; margin-bottom: 1px; }
  #psg-profile-canvas { height: 16px; }

  .psg-hud-center { top: 27%; }
  .psg-callout { font-size: 12px; padding: 4px 12px; }
  .psg-countdown { font-size: 56px; top: 44%; }
  .psg-key-hint { display: none !important; }

  /* Push controls cleanly into the bottom-left and bottom-right corners so the skier is 100% unobstructed! */
  .psg-controls-bar {
    width: 100%;
    justify-content: space-between;
  }
  .psg-ctrl-group { gap: 6px; }
  .psg-ctrl-btn {
    padding: 10px 13px;
    font-size: 12.5px;
    background: rgba(13, 30, 56, 0.72);
  }
  .psg-ctrl-btn.push {
    min-width: 100px;
    padding: 10px 16px;
  }
}
