.pg-shell {
  --pg-p: #2fd3bd;
  --pg-a: #f2a13f;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 24px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.pg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pg-statline {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.pg-stat {
  min-width: 76px;
  padding: 8px 10px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
}

.pg-stat span {
  display: block;
  color: var(--cg-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.pg-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--cg-ink);
  font-size: 19px;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pg-stat:first-child strong {
  color: #0d6f6b;
}

.pg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pg-btn,
.pg-close,
.pg-seg-btn {
  min-height: 44px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.pg-btn {
  min-width: 44px;
  padding: 0 14px;
}

.pg-btn:hover,
.pg-close:hover,
.pg-seg-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(18, 122, 137, 0.45);
}

.pg-btn:focus-visible,
.pg-close:focus-visible,
.pg-seg-btn:focus-visible {
  outline: 3px solid rgba(49, 95, 157, 0.4);
  outline-offset: 3px;
}

.pg-canvas:focus-visible {
  outline: 2px solid rgba(47, 211, 189, 0.55);
  outline-offset: -2px;
}

.pg-primary {
  border-color: transparent;
  background: var(--cg-teal);
  color: #fff;
}

.pg-icon-btn {
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.pg-icon-btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pg-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid #0c2129;
  border-radius: 10px;
  background: #0a1c25;
  box-shadow: 0 18px 40px rgba(10, 28, 37, 0.28);
}

.pg-canvas {
  display: block;
  width: 100%;
  height: min(56vh, 460px);
  min-height: 320px;
  touch-action: none;
  cursor: ns-resize;
}

.pg-start,
.pg-result {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 6px;
  width: min(86%, 320px);
  padding: 18px;
  border: 1px solid rgba(150, 240, 235, 0.22);
  border-radius: 10px;
  background: rgba(9, 26, 34, 0.9);
  color: #eafcff;
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 20px 50px rgba(3, 12, 18, 0.5);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.pg-result {
  cursor: default;
}

.pg-start strong,
.pg-result strong {
  font-size: 24px;
  line-height: 1.15;
}

.pg-result > span {
  color: var(--pg-p);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.pg-start span,
.pg-result p {
  margin: 0;
  color: rgba(234, 252, 255, 0.72);
  font-size: 14px;
  line-height: 1.4;
}

.pg-rgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.pg-rgrid > div {
  padding: 7px 4px;
  border: 1px solid rgba(150, 240, 235, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.pg-rgrid span {
  display: block;
  color: rgba(234, 252, 255, 0.6);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pg-rgrid strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1;
}

.pg-rrow {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.pg-rrow .pg-btn {
  flex: 1 1 0;
}

.pg-rrow .pg-btn:not(.pg-primary) {
  border-color: rgba(150, 240, 235, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: #eafcff;
  box-shadow: none;
}

.pg-controls {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.pg-ctl {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-ctl-lab {
  flex: 0 0 auto;
  width: 68px;
  color: var(--cg-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pg-ctl.pg-dim {
  opacity: 0.55;
}

.pg-seg {
  display: flex;
  flex: 1 1 auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
}

.pg-seg-btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 0;
  box-shadow: none;
  font-size: 14px;
}

.pg-seg-btn:disabled {
  cursor: default;
}

.pg-seg-btn + .pg-seg-btn {
  border-left-width: 0;
}

.pg-seg-btn:first-child {
  border-radius: 8px 0 0 8px;
}

.pg-seg-btn:last-child {
  border-radius: 0 8px 8px 0;
}

.pg-seg-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #17909c, #0f6b78);
  border-color: #0f6b78;
  color: #fff;
}

#pg-mode-rally[aria-pressed="true"] {
  background: linear-gradient(180deg, #d1613a, #ab4526);
  border-color: #ab4526;
}

.pg-hint {
  margin: 12px 2px 0;
  color: var(--cg-muted);
  font-size: 13px;
  line-height: 1.45;
}

.pg-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 28, 37, 0.42);
}

.pg-modal-card {
  position: relative;
  width: min(100%, 440px);
  max-height: 84vh;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  box-shadow: 0 24px 70px rgba(30, 37, 40, 0.24);
}

.pg-modal-card h2 {
  margin: 0 48px 12px 0;
  font-size: 24px;
  line-height: 1.1;
}

.pg-modal-card p {
  margin: 10px 0 0;
  color: var(--cg-muted);
  line-height: 1.45;
}

.pg-modal-card b {
  color: var(--cg-ink);
}

.pg-close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 44px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.pg-is-hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .pg-shell {
    padding: 0 10px 18px;
  }

  .pg-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pg-statline,
  .pg-actions {
    justify-content: center;
  }

  .pg-stat {
    min-width: 0;
    flex: 1 1 68px;
    padding: 7px 6px;
    text-align: center;
  }

  .pg-stat strong {
    font-size: 17px;
  }

  .pg-ctl-lab {
    width: 54px;
    font-size: 10px;
  }

  .pg-seg-btn {
    padding: 0 4px;
    font-size: 13px;
  }

  .pg-canvas {
    height: min(52vh, 420px);
    min-height: 300px;
  }
}
