.pg-shell {
  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: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.pg-stat {
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  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;
}

.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 {
  transform: translateY(-1px);
  border-color: rgba(18, 122, 137, 0.45);
}

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

.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-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pg-score {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

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

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

.pg-seg-btn:hover {
  transform: none;
}

.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: var(--cg-teal);
  border-color: var(--cg-teal);
  color: #fff;
}

.pg-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-ink);
  box-shadow: var(--cg-shadow);
}

.pg-canvas {
  display: block;
  width: 100%;
  height: min(62vh, 520px);
  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(84%, 300px);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(21, 34, 37, 0.86);
  color: #f4f6f2;
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.pg-result {
  cursor: default;
}

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

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

.pg-result .pg-primary {
  margin-top: 6px;
}

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

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

.pg-modal-card {
  position: relative;
  width: min(100%, 430px);
  padding: 22px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  box-shadow: 0 24px 70px rgba(30, 37, 40, 0.22);
}

.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-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 {
    flex: 1 1 72px;
    text-align: center;
  }

  .pg-row {
    justify-content: center;
    text-align: center;
  }

  .pg-score {
    width: 100%;
    font-size: 19px;
  }

  .pg-seg-btn {
    flex: 1 1 auto;
    padding: 0 12px;
  }

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