/* Harbor House — Adventure Island · Phase 3 premium plate
   One wide generated plate (220% pannable), Captain Coral performance
   frame at the left, clue-chain hotspots rendered from islandHunt.
   Rules: transform/opacity animation only; calm = body.hh-calm. */

/* ── Stage ──────────────────────────────────────── */
#island-scene,#map-panel{scroll-margin-top:84px}
.isl-scene{position:relative;overflow:hidden;border-radius:var(--radius-lg);aspect-ratio:16/10;background:#274d33;box-shadow:var(--shadow)}
.isl-viewport{position:absolute;inset:0;overflow:hidden;cursor:grab;touch-action:pan-y;border-radius:inherit}
.isl-viewport.dragging{cursor:grabbing}
.isl-world{position:absolute;top:0;left:0;height:100%;width:220%;will-change:transform}
.isl-plate{position:absolute;inset:0;will-change:transform;transition:transform 1.1s cubic-bezier(.22,.9,.28,1)}
body.hh-calm .isl-plate{transition:none}
.isl-plate-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:50% 42%;display:block;pointer-events:none}
#isl-fx{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:30}

.isl-loc-chip{position:absolute;top:10px;left:10px;z-index:22;background:rgba(15,35,64,.88);color:#fff;font-family:var(--font-display);font-weight:700;font-size:var(--fs-sm);border-radius:999px;padding:.45rem .95rem;pointer-events:none;box-shadow:var(--shadow-sm)}
.isl-pan-hint{position:absolute;top:10px;right:10px;z-index:22;background:rgba(255,253,248,.92);color:var(--navy);font-family:var(--font-display);font-weight:700;font-size:var(--fs-sm);border-radius:999px;padding:.45rem .95rem;pointer-events:none;box-shadow:var(--shadow-sm)}
body.hh-calm .isl-pan-hint{display:none}

/* ── Clue hotspots (only the current one glows) ─── */
.isl-hotspot{position:absolute;left:var(--x);top:var(--y);transform:translate(-50%,-50%);width:104px;height:104px;background:none;border:none;cursor:pointer;z-index:6;padding:0;-webkit-tap-highlight-color:transparent}
.isl-hotspot:focus-visible{outline:3px solid var(--sun);outline-offset:2px;border-radius:50%}
.hs-beach{--x:15.5%;--y:39%}
.hs-bridge{--x:45%;--y:64%}
.hs-waterfall{--x:50.5%;--y:28%}
.hs-cave{--x:83%;--y:35%}
.hs-ring{position:absolute;inset:0;border-radius:50%;background:radial-gradient(circle,rgba(255,201,60,.30) 0%,rgba(255,201,60,.12) 62%,rgba(255,201,60,0) 72%);border:4px solid rgba(255,180,0,.95);box-shadow:0 0 18px rgba(255,180,0,.8),0 0 34px rgba(255,201,60,.5);opacity:0;pointer-events:none}
.isl-hotspot.isl-active .hs-ring{opacity:1}
body:not(.hh-calm) .isl-hotspot.isl-active .hs-ring{animation:islGlowPulse 1.9s ease-in-out infinite}
@keyframes islGlowPulse{0%,100%{transform:scale(1);opacity:.8}50%{transform:scale(1.07);opacity:1}}
.hs-medal{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:44px;height:44px;border-radius:50%;background:rgba(255,253,248,.94);border:3px solid #bc6c25;color:#7a4a12;font-family:var(--font-display);font-weight:800;font-size:1.25rem;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow-sm);pointer-events:none}
.isl-hotspot.isl-active .hs-medal{background:var(--sun);border-color:#96520f;color:#4a3205}
.isl-hotspot.isl-solved .hs-medal{background:#ffc93c;border-color:#96520f;color:#7a4a12}
.isl-hotspot.isl-solved .hs-medal::after{content:"✓";position:absolute;right:-9px;top:-9px;width:20px;height:20px;border-radius:50%;background:#2d9e5f;color:#fff;font-size:.8rem;display:flex;align-items:center;justify-content:center;border:2px solid #fff}
.hs-label{position:absolute;left:50%;bottom:-24px;transform:translateX(-50%);white-space:nowrap;background:rgba(15,35,64,.85);color:#fff;font-family:var(--font-display);font-weight:700;font-size:.78rem;border-radius:999px;padding:.28rem .7rem;pointer-events:none}
.hs-item{position:absolute;top:-40px;right:-34px;width:46px;height:46px;opacity:0;transform:scale(.35) rotate(-14deg);pointer-events:none;filter:drop-shadow(0 3px 6px rgba(20,16,4,.45))}
.hs-item svg{width:100%;height:100%;display:block}
.isl-hotspot.isl-solved .hs-item{opacity:1;transform:scale(1) rotate(0)}
body:not(.hh-calm) .isl-hotspot.isl-solved .hs-item{transition:transform .55s cubic-bezier(.2,1.5,.4,1),opacity .3s var(--ease)}
.isl-scene.in-cave .isl-hotspot{pointer-events:none;opacity:0;transition:opacity .4s var(--ease)}

/* Fireflies around the cave mouth — lit when caveOpen */
.isl-fireflies{position:absolute;left:72%;top:8%;width:26%;height:46%;pointer-events:none;opacity:0;transition:opacity 1s var(--ease)}
.isl-fireflies.lit{opacity:1}
.isl-fireflies span{position:absolute;width:9px;height:9px;border-radius:50%;background:#ffe66d;box-shadow:0 0 12px 4px rgba(255,230,109,.75)}
.isl-fireflies span:nth-child(1){left:12%;top:22%}.isl-fireflies span:nth-child(2){left:38%;top:10%}
.isl-fireflies span:nth-child(3){left:58%;top:30%}.isl-fireflies span:nth-child(4){left:76%;top:16%}
.isl-fireflies span:nth-child(5){left:26%;top:52%}.isl-fireflies span:nth-child(6){left:64%;top:58%}
.isl-fireflies span:nth-child(7){left:86%;top:44%}.isl-fireflies span:nth-child(8){left:46%;top:74%}
body:not(.hh-calm) .isl-fireflies.lit span{animation:islFirefly 3.6s ease-in-out infinite}
body:not(.hh-calm) .isl-fireflies.lit span:nth-child(2n){animation-delay:-1.3s}
body:not(.hh-calm) .isl-fireflies.lit span:nth-child(3n){animation-delay:-2.2s}
@keyframes islFirefly{0%,100%{transform:translate(0,0);opacity:.55}50%{transform:translate(5px,-7px);opacity:1}}

/* Cave vignette — friendly-dark, edges only */
.isl-vignette{position:absolute;inset:0;z-index:4;pointer-events:none;opacity:0;transition:opacity 1s var(--ease);background:radial-gradient(ellipse 62% 58% at 76% 40%,rgba(0,0,0,0) 46%,rgba(24,12,4,.42) 78%,rgba(14,7,2,.72) 100%)}
.isl-vignette.on{opacity:1}
body.hh-calm .isl-vignette{transition-duration:.01s}

/* ── Captain Coral performance frame ────────────── */
.coral-dock{position:absolute;left:12px;bottom:12px;z-index:20;display:flex;align-items:flex-end;gap:12px;pointer-events:none}
.coral-frame{position:relative;width:172px;aspect-ratio:3/4;flex:0 0 auto;filter:drop-shadow(0 14px 22px rgba(16,26,8,.45));pointer-events:auto}
/* pointer-events:auto on the frame is load-bearing: the dock is
   pointer-events:none, and without this the frame's own tap target
   (tap Coral → her bubble re-opens with the current clue) is dead —
   taps fall through to the plate and only raise a hint. */
.coral-frame img,.coral-frame video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:50% 16%;display:block;border-radius:20px;opacity:0;transition:opacity .25s ease;
  -webkit-mask-image:linear-gradient(to right,transparent 0,#000 7%,#000 97%,transparent 100%),linear-gradient(to bottom,transparent 0,#000 6%,#000 96%,transparent 100%);
  -webkit-mask-composite:source-in;
          mask-image:linear-gradient(to right,transparent 0,#000 7%,#000 97%,transparent 100%),linear-gradient(to bottom,transparent 0,#000 6%,#000 96%,transparent 100%);
          mask-composite:intersect}
.coral-frame .on{opacity:1}
#coralStill{z-index:1}
#coralIdle{z-index:2}
#coralReact{z-index:3}
.coral-frame.celebrating{animation:coralHop .62s ease-in-out 3}
@keyframes coralHop{0%,100%{transform:translateY(0)}30%{transform:translateY(-6px)}55%{transform:translateY(0)}75%{transform:translateY(-3px)}}
body.hh-calm .coral-frame.celebrating{animation:none}
#polly{position:absolute;top:-16px;right:-18px;width:54px;height:64px;background:none;border:none;cursor:pointer;z-index:6;padding:0;pointer-events:auto}
#polly svg{width:100%;height:100%;display:block;filter:drop-shadow(0 3px 5px rgba(16,26,8,.4))}
#polly:focus-visible{outline:3px solid var(--sun);outline-offset:2px;border-radius:12px}
body:not(.hh-calm) #polly{animation:pollyBob 3.8s ease-in-out infinite}
@keyframes pollyBob{0%,100%{transform:translateY(0) rotate(-2deg)}50%{transform:translateY(-3px) rotate(2deg)}}
.coral-bubble{pointer-events:auto;width:252px;background:#fff;border:3px solid var(--w-island,#bc6c25);border-radius:18px;padding:.65rem .9rem .75rem;box-shadow:var(--shadow);align-self:center}
.coral-bubble p{margin:0;font-weight:800;color:var(--navy);font-size:.95rem;line-height:1.38}
.coral-bubble .cap-name{font-family:var(--font-display);font-size:var(--fs-sm);letter-spacing:.07em;text-transform:uppercase;color:#96520f;margin-bottom:.2rem}
.coral-bubble .cap-actions{display:flex;gap:var(--sp-2);margin-top:.5rem;flex-wrap:wrap}
.coral-bubble .cap-actions .btn{min-height:44px}
.coral-bubble[hidden]{display:none!important}
.polly-bubble{position:absolute;z-index:21;background:#fff;border:3px solid var(--sun);border-radius:16px;padding:.45rem .8rem;box-shadow:var(--shadow);pointer-events:none;opacity:0;visibility:hidden;transform:translateY(4px);transition:opacity .3s var(--ease),transform .3s var(--ease),visibility 0s linear .3s;font-family:var(--font-display);font-weight:800;color:var(--navy);font-size:var(--fs-sm);max-width:230px;left:150px;bottom:calc(100% - 6px)}
.polly-bubble.show{opacity:1;visibility:visible;transform:none;transition:opacity .3s var(--ease),transform .3s var(--ease)}
body.hh-calm .polly-bubble{transform:none}

/* ── In-scene feedback surfaces ─────────────────── */
.isl-scene-hint{position:absolute;top:54px;right:10px;z-index:26;width:min(330px,74%);background:#fff;border:3px solid var(--sun);border-radius:16px;padding:.55rem 2.4rem .6rem .85rem;box-shadow:var(--shadow);font-weight:800;color:var(--navy);font-size:var(--fs-sm);line-height:1.35;pointer-events:none}
.isl-scene-hint p{margin:0}
.isl-scene-hint[hidden]{display:none!important}
.isl-scene-hint-close{position:absolute;top:2px;right:2px;width:44px;height:44px;background:none;border:none;font-size:1rem;font-weight:800;color:var(--navy);cursor:pointer;pointer-events:auto}
.isl-next-banner{position:absolute;bottom:12px;left:50%;transform:translateX(-50%);z-index:26;width:min(470px,94%);background:#fff;border:3px solid var(--sun);border-radius:18px;padding:.6rem .85rem .65rem;box-shadow:var(--shadow);display:flex;align-items:center;gap:var(--sp-2);flex-wrap:wrap;pointer-events:none}
.isl-next-banner[hidden]{display:none!important}
.isl-next-banner p{margin:0;font-weight:800;color:var(--navy);font-size:var(--fs-base);line-height:1.35;flex:1 1 210px}
.isl-next-actions{display:flex;align-items:center;gap:var(--sp-1);pointer-events:auto}
.isl-next-actions .btn{min-height:44px}
.isl-next-close{width:44px;height:44px;flex:0 0 44px;background:none;border:2px solid rgba(15,35,64,.25);border-radius:50%;font-size:1rem;font-weight:800;color:var(--navy);cursor:pointer}

/* ── Treasure-map strip ─────────────────────────── */
.isl-mapstrip{position:absolute;right:10px;bottom:10px;z-index:20;display:flex;align-items:center;gap:7px;background:linear-gradient(160deg,#fdf3d8,#fbecc4);border:2.5px solid #bc6c25;border-radius:999px;padding:6px 13px 6px 10px;box-shadow:var(--shadow)}
.ms-label{font-size:1.05rem}
.ms-pip{width:27px;height:27px;border-radius:50%;border:2.5px solid #bc6c25;background:#fffaf0;color:#7a4a12;font-family:var(--font-display);font-weight:800;font-size:.85rem;display:flex;align-items:center;justify-content:center}
.ms-pip.filled{background:#ffc93c;color:#7a4a12}
.ms-pip.current{border-color:var(--navy);box-shadow:0 0 0 3px rgba(255,201,60,.65)}
.ms-chest{width:32px;height:27px;display:block;filter:grayscale(.85) opacity(.55)}
.ms-chest svg{width:100%;height:100%;display:block}
.ms-chest.open{filter:drop-shadow(0 0 7px rgba(255,201,60,.95))}
.ms-text{font-family:var(--font-display);font-weight:800;color:#7a4a12;font-size:.92rem;white-space:nowrap}

/* Enter-cave button ON the cave */
.btn-enter-scene{position:absolute;right:12px;bottom:62px;z-index:21;min-height:52px;box-shadow:var(--shadow)}
.btn-enter-scene[hidden]{display:none!important}

/* ── Inside the cave: the chest ─────────────────── */
.cave-zone{position:absolute;right:3%;top:54%;transform:translateY(-50%);z-index:25;text-align:center;width:min(330px,62%)}
.cave-zone[hidden]{display:none!important}
.chest-instruction{color:#fdf0d5;font-family:var(--font-display);font-weight:800;font-size:var(--fs-lg);margin:0 0 var(--sp-2);text-shadow:0 2px 10px rgba(0,0,0,.65)}
#chest-hit{position:relative;width:220px;height:178px;margin:0 auto;background:none;border:none;cursor:pointer;padding:0;display:block}
#chest-hit:focus-visible{outline:3px solid var(--sun);outline-offset:3px;border-radius:18px}
#chest-hit svg{width:100%;height:100%;display:block;overflow:visible}
#chest-lid-g{transform-box:fill-box;transform-origin:0% 100%;transition:transform .8s var(--ease)}
#chest-g.chest-open #chest-lid-g{transform:rotate(-38deg)}
#chest-g.chest-open{filter:drop-shadow(0 0 22px rgba(255,201,60,.75))}
#chest-coins{opacity:0;transition:opacity .7s var(--ease) .15s}
#chest-g.chest-open #chest-coins{opacity:1}
body.hh-calm #chest-lid-g,body.hh-calm #chest-coins{transition-duration:.01s}
.cave-actions{display:flex;flex-wrap:wrap;gap:var(--sp-3);justify-content:center;margin-top:var(--sp-3)}
.cave-actions .btn{min-height:48px;background:rgba(15,35,64,.55);color:#fdf0d5;border:2px solid rgba(253,240,213,.65)}
/* Inside the cave the chest owns the stage — Coral watches, bubble rests */
.isl-scene.in-cave .coral-bubble,.isl-scene.in-cave .polly-bubble{display:none!important}

/* ── Captain's Map panel ────────────────────────── */
.map-panel{background:radial-gradient(circle at 18% 22%,rgba(188,108,37,.10) 0 60px,transparent 61px),radial-gradient(circle at 84% 78%,rgba(188,108,37,.08) 0 80px,transparent 81px),linear-gradient(160deg,#fdf3d8,#fbecc4);border:3px dashed #bc6c25;border-radius:var(--radius-lg);box-shadow:var(--shadow);padding:var(--sp-5)}
.map-panel .kicker{color:#96520f}
.map-panel h2{color:#7a4a12;margin-bottom:var(--sp-2)}
.mini-map{display:block;width:100%;height:auto;background:#a8e6e0;border:2.5px solid #dda15e;border-radius:var(--radius);margin:var(--sp-3) 0}
.mini-trail{fill:none;stroke:#bc6c25;stroke-width:5;stroke-dasharray:11 9;stroke-linecap:round;opacity:.35}
.stamp{transform-box:fill-box;transform-origin:center}
.stamp .stamp-bg{fill:#fff;stroke:#bc6c25;stroke-width:4;transition:fill .3s var(--ease)}
.stamp .stamp-num{font-family:var(--font-display);font-weight:800;fill:#7a4a12;pointer-events:none}
.stamp .stamp-check{opacity:0;transition:opacity .3s var(--ease)}
.stamp.stamped .stamp-bg{fill:#ffc93c}
.stamp.stamped .stamp-check{opacity:1}
body:not(.hh-calm) .stamp.stamped{animation:islStampThunk .45s var(--ease)}
@keyframes islStampThunk{0%{transform:scale(1.35)}55%{transform:scale(.94)}100%{transform:scale(1)}}
.stamp.current .stamp-bg{stroke:var(--navy);stroke-width:5}
#map-x{opacity:0;transition:opacity .6s var(--ease)}
#map-x.show{opacity:1}
.clue-card{background:#fffaf0;border:2.5px solid #dda15e;border-radius:var(--radius-lg);padding:var(--sp-4) var(--sp-5);box-shadow:var(--shadow-sm)}
.clue-num{font-family:var(--font-display);font-weight:800;font-size:var(--fs-sm);letter-spacing:.08em;text-transform:uppercase;color:#bc6c25;margin:0 0 var(--sp-1)}
.clue-rhyme{font-size:var(--fs-lg);font-weight:800;color:var(--navy);margin:0 0 var(--sp-2);line-height:1.4}
.clue-plain{font-weight:700;color:var(--ink-soft);margin:0 0 var(--sp-3)}
.clue-actions{display:flex;flex-wrap:wrap;gap:var(--sp-3);align-items:center}
.clue-actions .btn{min-height:52px}
.clue-actions [hidden]{display:none!important}
.clue-progress-text{font-family:var(--font-display);font-weight:800;color:#7a4a12;margin:var(--sp-3) 0 0;font-size:var(--fs-lg)}
.isl-hint{background:#fff;border:2px solid var(--sun);border-radius:var(--radius);padding:var(--sp-3) var(--sp-4);font-weight:800;color:var(--navy);margin-top:var(--sp-3)}
.isl-hint[hidden]{display:none!important}
.sail-row{display:flex;flex-wrap:wrap;gap:var(--sp-2);margin-top:var(--sp-3)}
.sail-btn{min-height:44px;padding:var(--sp-2) var(--sp-3);border-radius:999px;border:2.5px solid rgba(188,108,37,.55);background:#fff;font-family:var(--font-display);font-weight:700;font-size:var(--fs-sm);color:#7a4a12;cursor:pointer}
.sail-btn:hover{border-color:#bc6c25}
.isl-skip-row{margin:var(--sp-2) 0 0}
.isl-skip{background:none;border:none;padding:var(--sp-2);min-height:44px;font-family:var(--font-body);font-weight:800;font-size:var(--fs-sm);color:#96520f;text-decoration:underline;text-underline-offset:3px;cursor:pointer}
.log-card{background:#fff8e6;border:2.5px solid #dda15e;border-left:12px solid #bc6c25;border-radius:var(--radius);padding:var(--sp-4) var(--sp-5);margin-top:var(--sp-4);color:var(--ink);box-shadow:var(--shadow-sm)}
.log-card h3{color:#7a4a12;margin-bottom:var(--sp-2)}
.log-card[hidden]{display:none!important}

/* ── Desktop band: plate crop shifts landmarks up ── */
@media (min-width:761px){
  .hs-beach{--y:37%}
  .hs-bridge{--y:78%}
  .hs-waterfall{--y:19%}
  .hs-cave{--y:30%}
}

/* ── Mobile ─────────────────────────────────────── */
@media (max-width:760px){
  /* P3-6 BIG GAMES: on a portrait phone the island is the whole game —
     the stage takes ~72% of the viewport height (Ocean's shipped
     standard) instead of a ~1/1 strip. island.js fitView() widens the
     world to match (stage height × the plate's 3:2 aspect), so the
     panoramic plate renders uncropped and every hotspot % lands
     exactly on its landmark at the new size. */
  .isl-scene{aspect-ratio:auto;height:min(72vh,660px);height:min(72svh,660px);min-height:470px}
  .isl-hotspot{width:104px;height:104px}
  .hs-medal{width:44px;height:44px;font-size:1.15rem}
  .hs-label{font-size:.72rem;bottom:-22px}
  .hs-item{width:42px;height:42px;top:-36px;right:-30px}
  .coral-dock{left:0;right:0;top:0;bottom:0}
  .coral-frame{position:absolute;left:8px;bottom:8px;width:88px}
  /* P3-6: Coral's panel is a sheet docked at a stage edge, chosen by
     island.js from the ACTIVE hotspot's position (the P3-5 dock-away
     rule): hotspot in the top half → the sheet docks to the BOTTOM,
     clear of Coral's frame (left:106px) and above the map strip
     (bottom:54px); hotspot in the bottom half (the rope bridge) →
     the sheet docks to the TOP, below the location chip (top:54px).
     Max-height 45% of the stage, so the sheet can never reach the
     hotspot's half. The un-classed default is the bottom dock —
     stop 1 (the ship, top half) is never blocked on a fresh load. */
  .coral-bubble{position:absolute;top:auto;bottom:54px;left:106px;right:8px;width:auto;max-width:none;max-height:45%;overflow-y:auto;padding:.55rem .75rem .6rem}
  .coral-bubble.dock-top{top:54px;bottom:auto;left:8px;right:8px}
  .coral-bubble.dock-bottom{top:auto;bottom:54px;left:106px;right:8px}
  .coral-bubble p{font-size:.82rem;line-height:1.32}
  .coral-bubble .cap-name{font-size:.68rem;margin-bottom:.1rem}
  .coral-bubble .cap-actions{margin-top:.4rem;gap:var(--sp-1)}
  .coral-bubble .cap-actions .btn{min-height:44px;padding:.3rem .6rem;font-size:.8rem}
  #polly{width:44px;height:52px;top:-12px;right:auto;left:-12px}
  .polly-bubble{left:102px;bottom:136px;top:auto;max-width:180px;font-size:.78rem}
  .isl-pan-hint{display:none}
  .isl-loc-chip{max-width:60vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .isl-mapstrip{right:8px;bottom:8px;padding:5px 10px 5px 8px;gap:5px}
  .ms-pip{width:23px;height:23px;font-size:.78rem}
  .ms-chest{width:27px;height:23px}
  .ms-text{font-size:.8rem}
  .btn-enter-scene{bottom:56px;right:8px}
  .cave-zone{right:auto;left:50%;top:auto;bottom:64px;transform:translateX(-50%);width:min(320px,92%)}
  .chest-instruction{font-size:1rem}
  #chest-hit{width:180px;height:146px}
  .isl-scene-hint{top:50px;width:min(300px,80%);font-size:.82rem}
  .isl-next-banner{bottom:8px;padding:.5rem .65rem .55rem}
  .isl-next-banner p{font-size:.9rem;flex-basis:100%}
  .map-panel{padding:var(--sp-4)}
  .clue-card{padding:var(--sp-3) var(--sp-4)}
  .clue-actions .btn{flex:1 1 100%;justify-content:center}
}
@media (prefers-reduced-motion:reduce){
  .hs-ring,.isl-fireflies span,#polly,.stamp{animation:none!important}
}
