body:has(.pn) {
  background: linear-gradient(180deg, #2b2358 0%, #4a2f66 45%, #7a3f68 100%) fixed;
  color: #f6eee6;
}

body:has(.pn) > header {
  max-width: 760px;
  padding-bottom: 12px;
}

body:has(.pn) > header a {
  color: #d3c3d8;
  font-size: 13px;
}

main:has(.pn) {
  max-width: 760px;
  background: transparent;
  padding-top: 12px;
}

.pn {
  --accent: #ff9d6c;
  --accent-ink: #2b1208;
  --muted: #d3c3d8;
  --panel: rgba(24, 16, 52, .66);
  --line: rgba(255, 190, 150, .28);
  width: 100%;
}

.pn-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.pn-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--muted);
}

.pn-head h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: .08em;
}

.pn-stats {
  display: flex;
  gap: 8px;
}

.pn-stats > div {
  min-width: 68px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: right;
}

.pn-stats span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--muted);
}

.pn-stats strong {
  display: block;
  font-size: 18px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* ---- 画面（縦長 3:4。高さが足りない端末では幅を絞る） ---- */
.pn-frame {
  display: flex;
  justify-content: center;
}

.pn-screen {
  position: relative;
  width: min(100%, calc((100vh - 290px) * .75));
  width: min(100%, calc((100svh - 290px) * .75));
  min-width: min(100%, 240px);
  aspect-ratio: 3 / 4;
  line-height: 0;
  border-radius: 6px;
  outline: 3px solid #5a3f86;
  box-shadow: 0 0 0 7px rgba(255, 157, 108, .08), 0 18px 50px rgba(0, 0, 0, .5);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.pn-screen:focus-visible {
  outline-color: var(--accent);
}

.pn-screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1b1238;
}

.pn-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  line-height: 1.6;
  text-align: center;
  background: rgba(20, 12, 44, .72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.pn-overlay[hidden] {
  display: none;
}

.pn-ov-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .24em;
  color: var(--muted);
}

.pn-ov-title {
  margin: 0;
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 800;
  letter-spacing: .1em;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 157, 108, .55);
}

.pn-ov-desc {
  max-width: 300px;
  margin: 2px 0 12px;
  font-size: 13px;
  line-height: 1.8;
  color: #eadff0;
  white-space: pre-line;
}

.pn-ov-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 170px;
}

/* ---- ボタン ---- */
.pn button {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: #f6eee6;
  background: rgba(60, 40, 100, .8);
  border: 1px solid rgba(255, 190, 150, .35);
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .08s;
}

.pn button:hover:not(:disabled) {
  background: rgba(86, 58, 138, .9);
}

.pn button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.pn button:disabled {
  opacity: .4;
  cursor: default;
}

.pn button[hidden] {
  display: none;
}

.pn .pn-primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.pn .pn-primary:hover:not(:disabled) {
  background: #ffb184;
}

/* ---- タッチ操作 ---- */
.pn-pad {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px auto 0;
  max-width: 420px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.pn-pad-dir {
  display: flex;
  gap: 10px;
  touch-action: none;
}

.pn .pn-pad-dir button {
  width: 68px;
  height: 68px;
  padding: 0;
  font-size: 24px;
  border-radius: 16px;
  pointer-events: none;           /* 指の位置は pad 全体で受ける（滑らせて切り替え） */
}

.pn .pn-pad-dir button.is-on,
.pn .pn-pad-jump.is-on {
  background: var(--accent);
  color: var(--accent-ink);
  transform: scale(.96);
}

.pn .pn-pad-jump {
  width: 128px;
  height: 128px;
  padding: 0;
  font-size: 20px;
  letter-spacing: .12em;
  border-radius: 50%;
  touch-action: none;
  border-width: 2px;
}

.pn-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px auto 0;
  max-width: 420px;
}

.pn-best {
  font-size: 13px;
  color: var(--muted);
}

.pn-best strong {
  margin-left: 4px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.pn-status {
  min-height: 1.5em;
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.pn-sound,
.pn-note {
  margin: 4px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.pn-sound a {
  color: var(--accent);
}

.pn-how {
  margin-top: 22px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.8;
}

.pn-how h2 {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: .08em;
}

.pn-how dl {
  margin: 0 0 10px;
  display: grid;
  gap: 6px;
}

.pn-how dl > div {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: 4px 12px;
}

.pn-how dt {
  font-weight: 700;
  color: var(--accent);
}

.pn-how dd {
  margin: 0;
}

.pn-how ul {
  margin: 0 0 8px;
  padding-left: 1.2em;
}

.pn-how p {
  margin: 8px 0 0;
}

@media (max-width: 520px) {
  .pn-head h1 {
    font-size: 30px;
  }

  .pn-how dl > div {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .pn-pad {
    margin-top: 10px;
  }
}

@media (max-height: 640px) and (max-width: 520px) {
  .pn .pn-pad-jump { width: 104px; height: 104px; }
  .pn .pn-pad-dir button { width: 58px; height: 58px; }
}
