/* /play — Storybook game additions on top of game.css (shared HUD). */
.page-storybook .game-canvas canvas { display: block; touch-action: none; }
.page-storybook .game-shell { background: #8fd0f2; }

/* header: compass + settings */
.sb-compass { display: grid; flex: 0 0 46px; width: 46px; height: 46px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: linear-gradient(145deg, rgba(38, 76, 88, .96), rgba(16, 45, 58, .96)); box-shadow: 0 3px 0 rgba(0, 0, 0, .3); cursor: pointer; }
.sb-compass[hidden] { display: none; }
.sb-compass svg { width: 40px; height: 40px; }
.sb-compass:focus-visible { outline: 3px solid #fff7a8; outline-offset: 2px; }
.page-storybook .perspective-toggle span { font-size: 21px; }

.sb-settings { position: absolute; top: calc(70px + var(--safe-top)); right: calc(16px + var(--safe-right)); z-index: 45; display: grid; gap: 10px; width: min(300px, calc(100vw - 24px)); padding: 14px 16px; border: 3px solid #f0d38e; border-radius: 16px; background: linear-gradient(155deg, #23465c, #10293e 70%); box-shadow: 0 8px 0 #081726, 0 20px 50px rgba(0, 0, 0, .45); color: #fff1ce; }
.sb-settings[hidden] { display: none; }
.sb-settings h2 { margin: 0; color: #f3d579; font-size: 1rem; letter-spacing: .06em; text-transform: uppercase; }
.sb-settings fieldset { margin: 0; padding: 0; border: 0; }
.sb-settings legend { margin-bottom: 5px; padding: 0; color: #9fd0b8; font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.sb-seg { display: flex; gap: 6px; }
.sb-seg label { position: relative; flex: 1; }
.sb-seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.sb-seg span { display: block; padding: 8px 6px; border: 2px solid #4d7182; border-radius: 10px; background: #173a4b; font-size: .82rem; font-weight: 900; text-align: center; }
.sb-seg input:checked + span { border-color: #ffe178; background: #f3d579; color: #22313f; }
.sb-seg input:focus-visible + span { outline: 3px solid #fff7a8; outline-offset: 2px; }
.sb-3donly { display: grid; gap: 10px; }
.sb-3donly[hidden] { display: none; }
.sb-wide { min-height: 42px; border: 2px solid #ddc58d; border-radius: 10px; background: #1b3449; color: #ffe6aa; font: inherit; font-weight: 900; cursor: pointer; }
.sb-wide:hover { background: #26475f; }
.sb-settings small { color: #b8cfca; font-size: .72rem; line-height: 1.35; }
.sb-classic { color: #f3d579; font-size: .78rem; font-weight: 800; }

/* rotate / zoom buttons from the 3D view: a column on the right edge */
.page-storybook .w6-bar { position: fixed; top: 50%; right: calc(14px + var(--safe-right)); bottom: auto; z-index: 21; display: flex; flex-direction: column; gap: 8px; transform: translateY(-50%); }
.page-storybook .w6-bar button { width: 44px; height: 44px; border: 2px solid #e9ca82; border-radius: 12px; background: rgba(16, 45, 58, .9); color: #f3d579; font: 900 21px system-ui; cursor: pointer; touch-action: manipulation; }
.page-storybook .w6-bar button:disabled { opacity: .35; cursor: default; }
@media (max-width: 700px) { .page-storybook .w6-bar { top: 42%; right: calc(8px + var(--safe-right)); gap: 6px; } .page-storybook .w6-bar button { width: 40px; height: 40px; font-size: 19px; } }
@media (pointer: coarse) and (orientation: landscape) { .page-storybook .w6-bar { flex-direction: row; top: calc(62px + var(--safe-top)); transform: none; } }

.w6-switching { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; background: rgba(12, 30, 44, .55); color: #fff1ce; font-weight: 1000; font-size: 1.1rem; letter-spacing: .04em; text-shadow: 0 2px 0 #0b1d22; }

/* objective marker over the target (positioned by play.ts) */
.sb-marker { position: absolute; left: 0; top: 0; z-index: 16; width: 0; height: 0; pointer-events: none; }
.sb-marker[hidden] { display: none; }
.sb-marker i { position: absolute; left: -15px; top: -40px; display: grid; width: 30px; height: 30px; place-items: center; border: 3px solid #7a4a1f; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1a8, #ffd24a 55%, #f0a92e); box-shadow: 0 4px 0 rgba(59, 42, 44, .45); animation: sb-bob 1.2s ease-in-out infinite; }
.sb-marker i::before { content: "!"; color: #3b2a2c; font: 1000 18px/1 system-ui; }
.sb-marker i::after { content: ""; position: absolute; left: 50%; bottom: -11px; border: 7px solid transparent; border-top: 8px solid #7a4a1f; transform: translateX(-50%); }
@keyframes sb-bob { 50% { transform: translateY(-7px); } }

/* HUD avatar = the character's head */
.mini-avatar.has-portrait { overflow: hidden; background: radial-gradient(circle at 50% 40%, #9fd8f2, #4f8fb8); font-size: 0; }
.mini-avatar.has-portrait canvas { width: 100%; height: 100%; image-rendering: pixelated; }

/* sprite portraits in dialogs */
.sprite-portrait { object-fit: contain; image-rendering: pixelated; }

/* celebrate burst */
.sb-burst { position: absolute; z-index: 30; width: 0; height: 0; pointer-events: none; }
.sb-burst i { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; background: var(--c); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: sb-spark .9s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes sb-spark { to { transform: rotate(var(--a)) translateY(-58px) rotate(180deg); opacity: 0; } }

/* map: the island plate with the three places */
.sb-map { height: auto; aspect-ratio: 1672 / 941; background: #2f7fa8; }
.sb-map .map-art { object-fit: cover; opacity: .9; }
.sb-map .map-house { left: 74%; top: 22%; }
.sb-map .map-town { left: 44%; top: 56%; }
.sb-map .map-wild { left: 90%; top: 76%; }
@media (max-width: 560px) { .sb-map .map-spot { min-width: 0; padding: 5px 7px; } .sb-map .map-spot small { display: none; } .sb-map .map-spot strong { font-size: .72rem; } }

/* ---------------------------------------------------------------- creator */
.creator-dialog { width: min(880px, calc(100vw - 24px)); }
.sbc { position: relative; display: grid; gap: 10px; padding: 24px 26px 22px; }
.sbc-head small { color: #f3d579; font-size: .68rem; font-weight: 1000; letter-spacing: .13em; }
.sbc-head h1 { margin: 4px 0 6px; }
.sbc-head p { margin: 0; }
.sbc-body { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 18px; align-items: start; }
.sbc-preview { display: grid; gap: 10px; justify-items: center; padding: 12px; border: 3px solid #78a866; border-radius: 16px; background: radial-gradient(circle at 50% 70%, #86c75e, #4f9a48 60%, #3c7a3c); }
.sbc-canvas { width: 100%; max-width: 260px; aspect-ratio: 1; image-rendering: pixelated; cursor: grab; touch-action: none; }
.sbc-turn { display: flex; gap: 8px; }
.sbc-btn { min-width: 44px; min-height: 40px; padding: 0 12px; border: 2px solid #ddc58d; border-radius: 10px; background: #1b3449; color: #ffe6aa; font: inherit; font-weight: 900; cursor: pointer; }
.sbc-btn:hover { background: #26475f; }
.sbc-opts { display: grid; gap: 10px; max-height: min(52vh, 460px); overflow: auto; padding-right: 4px; }
.sbc-row { display: grid; gap: 6px; }
.sbc-row > span { color: #f4dfa8; font-size: .78rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.sbc-row input { height: 46px; padding: 0 12px; border: 3px solid #bf9866; border-radius: 10px; background: #fff0c9; color: #2e3740; font: inherit; font-size: 1.02rem; font-weight: 800; outline: 0; }
.sbc-row input:focus-visible { border-color: #ffe178; box-shadow: 0 0 0 3px rgba(255, 225, 120, .35); }
.sbc-group { display: flex; flex-wrap: wrap; gap: 6px; }
.sbc-opt { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 11px; border: 2px solid #4d7182; border-radius: 10px; background: #173a4b; color: #fff1ce; font: inherit; font-size: .85rem; font-weight: 900; cursor: pointer; }
.sbc-opt[aria-pressed="true"] { border-color: #ffe178; background: #2c5364; color: #ffe178; box-shadow: 0 0 0 2px rgba(255, 225, 120, .25); }
.sbc-opt:focus-visible { outline: 3px solid #fff7a8; outline-offset: 2px; }
.sbc-thumb { flex-direction: column; gap: 1px; padding: 3px 6px; font-size: .7rem; }
.sbc-thumb canvas { width: 44px; height: 44px; border-radius: 6px; background: #3f8a31; image-rendering: pixelated; }
.sbc-sw { width: 38px; min-height: 38px; justify-content: center; padding: 0; }
.sbc-sw i { display: block; width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 2px #0f242b; }
.sbc-status { min-height: 1.2em; margin: 0; color: #ffd98a; font-weight: 800; }
.sbc-foot { display: flex; gap: 10px; align-items: center; }
.sbc-foot .adventure-button { flex: 1; }
.sbc-close { right: 12px; top: 12px; }
@media (max-width: 700px) {
  .creator-dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .sbc { padding: 16px 14px 14px; gap: 8px; }
  .sbc-head p { display: none; }
  .sbc-head h1 { font-size: 1.5rem; }
  .sbc-body { grid-template-columns: 1fr; gap: 10px; }
  .sbc-preview { grid-template-columns: 1fr auto; align-items: center; padding: 6px 10px; }
  .sbc-canvas { max-width: 130px; }
  .sbc-turn { flex-direction: column; }
  .sbc-opts { max-height: none; overflow: visible; }
  .sbc-foot { position: sticky; bottom: -14px; padding: 8px 0 4px; background: linear-gradient(transparent, #10293e 30%); }
}
