.castle-next { display: block; margin: 26px auto 0; }
.royal-page[hidden], .castle-wipe[hidden] { display: none; }
.royal-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.7vw, 42px);
  background-color: #fff2f2;
  background-image: repeating-linear-gradient(0deg, transparent 0 15px, #dca6b72e 15px 30px), repeating-linear-gradient(90deg, transparent 0 15px, #dca6b72e 15px 30px);
  color: #613046;
}
.royal-shell {
  width: min(100%, max(640px, calc((100svh - 205px) * 1.5)), 1040px);
  border: 2px solid #b06683;
  border-radius: 24px 24px 36px 36px;
  padding: 0 clamp(7px, 1.4vw, 19px) 8px;
  background: #ffe2eb;
  box-shadow: inset 0 3px #fff6f8, 0 5px #d992ac, 0 8px #ae6e86, 0 15px 32px #974c6c26;
}
.royal-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 49px; padding: 4px 9px; }
#royal-title { margin: 0; text-align: center; font: 600 clamp(23px, 2.5vw, 34px)/1.2 Georgia,serif; letter-spacing: -.05em; color: #79354e; }
#royal-title i { font-size: .82em; color: #a95c78; }
.royal-hearts { justify-self: end; font: 16px monospace; letter-spacing: 2px; color: #c25b80; text-shadow: 1px 1px #fff; }
.royal-back { justify-self: start; padding: 8px 4px; border: 0; background: transparent; font: bold 12px var(--type-mono); color: #773d54; cursor: pointer; }
.royal-screen { padding: 5px; background: #975d76; border: 1px solid #814e61; box-shadow: 0 2px #fff3f6, inset 0 2px #69445a; border-radius: 6px; }
#royal-canvas { display: block; width: 100%; height: auto; image-rendering: auto; touch-action: manipulation; cursor: pointer; }
.royal-console { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: clamp(12px, 2vw, 28px); padding: 12px clamp(5px, 1.2vw, 18px) 6px; }
.royal-pad { justify-self: start; display: grid; grid: repeat(3, 29px) / repeat(3, 32px); position: relative; }
.royal-pad:before { content: ''; position: absolute; inset: 32% 30%; background: #b87290; }
.royal-pad button, #royal-action { border: 1px solid #925770; background: #f6c4d6; color: #70354f; box-shadow: inset 0 2px #ffedf3, 0 3px #ab6884; cursor: pointer; font: 700 13px var(--type-mono); user-select: none; -webkit-user-select:none; touch-action: none; }
.royal-pad button { border-radius: 5px; position: relative; padding: 0; }
.royal-pad [data-step=up] { grid-area: 1/2; }
.royal-pad [data-step=left] { grid-area: 2/1; }
.royal-pad [data-step=right] { grid-area: 2/3; }
.royal-pad [data-step=down] { grid-area: 3/2; }
#royal-action { padding: 10px 15px; min-height: 44px; max-width: 160px; border-radius: 16px; background: #bd6186; color: white; box-shadow: inset 0 2px #e49cb9, 0 3px #914360; }
#royal-action:disabled { color: #703b50; background: #ebbcd0; box-shadow: inset 0 2px #f5d9e4,0 2px #b27f94; }
.royal-console button:active { transform: translateY(2px); }
.royal-readout p { margin: 0; }
#royal-status { font: bold clamp(14px,1.2vw,18px)/1.3 Georgia,serif; }
#royal-guide { margin-top: 6px; max-width: 49ch; font: 12px/1.4 var(--type-mono); }
.royal-page :focus-visible { outline: 2px solid #7c2d57; outline-offset: 3px; }
.castle-wipe { position: fixed; inset: 0; z-index: 11; display: grid; grid-template-rows: repeat(12,1fr); pointer-events: all; }
.castle-wipe i { margin-bottom: -1px; background: repeating-linear-gradient(90deg,#f2b5cf 0 24px,#ffdae7 24px 48px); }
.castle-wipe i:nth-child(even) { background-position: 24px; }
@media (max-width: 580px) {
  .royal-page { padding: 8px; }
  .royal-console { grid-template-columns: 1fr auto; gap: 10px; padding: 12px 8px; }
  .royal-readout { grid-row: 1; grid-column: 1/-1; min-height: 55px; }
  .royal-pad { grid: repeat(3,35px) / repeat(3,40px); }
  .royal-hearts { font-size: 13px; }
}

.royal-page { display: block; padding: 0; min-height: 100svh; background: #f5a8c5; }
.royal-shell { position: relative; width: 100%; height: 100svh; padding: 0; border: 0; border-radius: 0; box-shadow: none; overflow: hidden; background: #f8b8d0; }
.royal-header { position: absolute; z-index: 2; top: 10px; left: 12px; display: block; min-height: 0; }
.royal-back { width: 42px; height: 42px; border-radius: 50%; background: #ffe2eecc; font-size: 27px; text-align: center; }
#royal-title, .royal-hearts, .royal-readout, #royal-action { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.royal-screen { position: absolute; inset: 0; padding: 0; border: 0; border-radius: 0; background: #f8b8d0; box-shadow: none; display: grid; place-items: center; }
#royal-canvas { width: min(100vw, 150svh); height: auto; max-height: 100svh; }
.royal-console { position: absolute; z-index: 2; inset: auto 18px 20px; display: flex; justify-content: space-between; align-items: end; padding: 0; pointer-events: none; }
.royal-pad { grid: repeat(3, 38px) / repeat(3, 40px); opacity: .8; pointer-events: auto; }
#royal-jump { pointer-events: auto; width: 60px; height: 60px; border: 2px solid #a54e77; border-radius: 50%; background: #ffd8e9db; color: #813b5b; box-shadow: 0 3px #b9698b; font: bold 28px monospace; touch-action: none; }

.royal-pad { display: flex; gap: 12px; }
.royal-pad:before { display: none; }
.royal-pad button { width: 54px; height: 54px; border-radius: 50%; }

#royal-canvas { width: 100%; height: 100%; max-height: none; }

.royal-pad button { width: 72px; height: 72px; font-size: 20px; }
#royal-jump { width: 76px; height: 76px; }
.royal-next { position: absolute; z-index: 3; top: 14px; right: 16px; border: 1px solid #a45a79; border-radius: 24px; background: #fff0f6df; color: #7f3657; padding: 10px 18px; font: bold 14px var(--type-mono); cursor: pointer; }
.letters[hidden] { display: none; }
.letters { position: relative; isolation: isolate; overflow: hidden; min-height: 100svh; padding: 100px 24px 120px; background: radial-gradient(ellipse at 50% 15%,#fffdfb,#ffedf4 58%,#f7d5e3); text-align: center; }
.letters .frame { z-index: 2; }
.letters-back { position: absolute; z-index: 3; top: 32px; left: clamp(30px,5vw,70px); border: 0; padding: 9px 0; background: none; color: #9e305c; font: 19px var(--type-serif); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.letters-header { position: relative; z-index: 1; color: #aa597a; }
.letters-header span { font-size: 19px; }
#letters-title { margin: 12px 0 48px; color: #8b264d; font: italic 500 clamp(56px,7vw,100px)/1 var(--type-serif); letter-spacing: -.035em; }
.letters-pages { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: clamp(36px,6vw,90px); }
.letters-pages figure { width: min(100%, 770px); margin: 0; padding: clamp(9px,1.5vw,18px); background: #fffaf8; border: 1px solid #e5b8ca; box-shadow: 0 12px 36px #a14d7330; }
.letters-pages img { display: block; width: 100%; height: auto; }
.letters-flower { position: absolute; z-index: 2; width: clamp(100px,18vw,240px); pointer-events: none; filter: drop-shadow(0 8px 14px #8f486935); }
.letters-flower-one { top: 20px; right: -35px; transform: rotate(-30deg); }
.letters-flower-two { bottom: 0; left: -40px; transform: rotate(35deg); }
@media (max-width: 580px) {
  .royal-pad button { width: 66px; height: 66px; }
  #royal-jump { width: 72px; height: 72px; }
  .letters { padding: 110px 25px 100px; }
  .letters-back { font-size: 16px; }
  #letters-title { margin-bottom: 35px; }
}
