/* ============================================================
   PANELS — modal windows, item grids, cards, mixing, journal,
   map, title screen.
   ============================================================ */
#panel-root, #picker-root { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; }
#picker-root { z-index: 45; }
/* Windows, confirm boxes and toasts opened from the title screen must sit above it. */
body.on-title #panel-root { z-index: 72; }
body.on-title #picker-root { z-index: 74; }
body.on-title #toasts { z-index: 76; }
.scrim { position: absolute; inset: 0; background: rgba(40, 40, 80, 0.25); backdrop-filter: blur(2px); }
.panel, .picker {
  position: relative; width: min(560px, 94vw); max-height: min(86vh, 900px); display: flex; flex-direction: column;
  background: var(--paper); border-radius: 24px; border: 4px solid #f0e2c8; box-shadow: 0 16px 50px rgba(40, 40, 80, 0.3);
  animation: pop 0.2s ease-out;
}
.panel.wide { width: min(860px, 96vw); }
.panel header, .picker header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 6px 18px;
  border-bottom: 2px dashed #f0e2c8;
}
.panel h2 { font-size: 1.25rem; color: var(--wood-dark); margin: 0; }
.close { font: inherit; font-size: 1.1rem; width: 40px; height: 40px; border-radius: 50%; border: none; background: #f6ecdc; cursor: pointer; color: var(--ink); }
.panel-body { overflow-y: auto; padding: 12px 18px 18px; -webkit-overflow-scrolling: touch; }
.picker { width: min(520px, 92vw); max-height: 70vh; }
.picker .grid, .picker .empty { overflow-y: auto; padding: 12px; }
.picker.confirm { padding: 18px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab { font: inherit; font-weight: 700; font-size: 0.85rem; padding: 7px 12px; border-radius: 999px; border: 2px solid #eadfcc; background: #fff; color: var(--ink-soft); cursor: pointer; min-height: 38px; }
.tab.on { background: var(--wood); border-color: var(--wood); color: #fff; }

/* ---- items ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.item {
  position: relative; width: 58px; height: 58px; border-radius: 14px; border: 2px solid #eadfcc; background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; font: inherit;
}
.item img { width: 40px; height: 40px; }
.item .count { position: absolute; bottom: 1px; right: 4px; font-size: 0.72rem; font-weight: 800; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.item .label { position: absolute; top: -6px; left: -4px; background: var(--gold); border-radius: 8px; font-size: 0.65rem; padding: 1px 4px; font-weight: 800; }
.item.selected { border-color: var(--wood); background: #fff3dc; }
.item.dim { opacity: 0.5; }
.item.q { font-size: 1.4rem; color: var(--ink-soft); cursor: default; }
.detail { display: flex; gap: 12px; align-items: flex-start; background: #fff6e6; border-radius: 16px; padding: 10px 12px; margin: 8px 0 12px; flex-wrap: wrap; }
.detail img { width: 56px; height: 56px; }
.detail .actions { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }

/* ---- cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card {
  font: inherit; text-align: left; color: var(--ink); background: #fff; border: 2px solid #eadfcc; border-radius: 16px;
  padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.card:hover { border-color: var(--wood); }
.card.dim { opacity: 0.6; }
.card.locked { background: #f4f0ea; }
.card.on { border-color: var(--wood); background: #fff3dc; }
.swatch { height: 26px; border-radius: 10px; border: 2px solid rgba(0, 0, 0, 0.06); }

.rows { display: flex; flex-direction: column; gap: 6px; }
.trow { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid #f0e6d6; border-radius: 14px; padding: 6px 10px; }
.trow.dim { opacity: 0.5; }
.speaker { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.portrait { width: 64px; height: 64px; border-radius: 50%; flex: none; }
.hearts { color: #e05a8a; letter-spacing: 1px; }
.note { padding: 8px 12px; border-radius: 12px; background: #fff3c4; margin-bottom: 8px; font-size: 0.85rem; }
.note.warn { background: #ffe0d8; }

/* ---- mixing ---- */
.mix-top { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.jar { width: 70px; height: 86px; border-radius: 14px 14px 20px 20px; border: 3px solid #b8d8e8; position: relative; overflow: hidden; background: #f4fbff; flex: none; }
.jar .liquid { position: absolute; left: 0; right: 0; bottom: 0; height: 70%; background: var(--c); transition: background 0.5s; animation: slosh 3s ease-in-out infinite; }
.jar .shine { position: absolute; left: 10px; top: 10px; width: 8px; height: 50px; border-radius: 6px; background: rgba(255, 255, 255, 0.6); }
.mixlog { background: #f6f1ff; border-radius: 12px; padding: 8px 12px; font-size: 0.86rem; margin: 8px 0; }
.mixlog div { animation: slidein 0.3s ease-out; }
.steps { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 6px 0; }
.step { display: inline-flex; align-items: center; gap: 3px; background: #fff; border: 1px solid #eadfcc; border-radius: 999px; padding: 2px 8px 2px 4px; font-size: 0.8rem; }
.step img { width: 22px; height: 22px; }
.hint { color: var(--ink-soft); font-style: italic; font-size: 0.85rem; }

/* ---- crafting ---- */
.bench { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; background: #c08a50; padding: 10px; border-radius: 16px; box-shadow: inset 0 -4px 0 #8a5a30; }
.slot { aspect-ratio: 1; border-radius: 12px; border: 2px dashed rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.25); font: inherit; font-size: 1.4rem; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.slot.full { background: #fff8ec; border-style: solid; }
.slot img { width: 80%; }
.msg { font-weight: 700; color: var(--wood-dark); }
.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.recipe { display: flex; gap: 10px; align-items: center; background: #fff; border: 2px solid #f0e6d6; border-radius: 14px; padding: 6px 10px; }
.recipe.dim { opacity: 0.65; }
.recipe.secret { background: #f6f2ff; }

/* ---- exploring ---- */
.isle-banner { border-radius: 16px; padding: 30px 14px 12px; background: linear-gradient(var(--g) 0 55%, var(--r) 55%); color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); margin-bottom: 8px; }
.energy { font-weight: 800; color: #e0a020; letter-spacing: 2px; }
.spots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.spot { font: inherit; display: flex; align-items: center; gap: 8px; text-align: left; padding: 10px 12px; min-height: 48px; border-radius: 14px; background: #fff; border: 2px solid #eadfcc; cursor: pointer; color: var(--ink); }
.spot .ic { font-size: 1.3rem; }
.spot.done { opacity: 0.5; cursor: default; }
.spot.special { border-color: var(--gold); background: #fff8dc; animation: shimmer 2s ease-in-out infinite; }
.quest { background: #fff; border: 2px solid #f0e6d6; border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.quest.main { background: #fff8dc; border-color: #f0d890; }
.quest ul { margin: 6px 0; padding-left: 20px; }
.clue { background: #fdf9ee; border-left: 4px solid var(--wood); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }

/* ---- journal ---- */
.almanac { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.acard { background: #fff; border: 2px solid #f0e6d6; border-radius: 14px; padding: 8px 10px; }
.acard.legend { border-color: var(--gold); background: #fffbe8; }
.acard.secret { background: #f4f0ea; color: var(--ink-soft); }
.acard .row { margin: 0 0 4px; }
.traits { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.traits > span { background: #f6efe2; border-radius: 8px; padding: 1px 6px; }
.traits .rare { background: #f0e0ff; font-weight: 700; }
.log { display: flex; flex-direction: column; gap: 8px; }
.logrow { display: grid; grid-template-columns: 170px 1fr 120px; gap: 10px; align-items: center; }
.bar { height: 12px; background: #f0e6d6; border-radius: 999px; overflow: hidden; }
.bar div { height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); border-radius: 999px; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.stage { padding: 4px 10px; border-radius: 999px; background: #f0e6d6; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.stage.done { background: var(--mint); color: #fff; }
.stage.now { background: var(--gold); color: #5a3a00; }
svg.map { width: 100%; max-height: 52vh; background: linear-gradient(#dff2ff, #f6fbff); border-radius: 16px; }
svg.map .route { stroke: #b8c8d8; stroke-width: 1.2; stroke-dasharray: none; }
svg.map .route.rare { stroke-dasharray: 2 2; }
svg.map .route.next { stroke: var(--wood); stroke-width: 2; }
svg.map .zone circle { stroke: #fff; stroke-width: 1.2; }
svg.map .zone text { font-size: 3.6px; text-anchor: middle; fill: var(--ink); font-weight: 700; }
svg.map .zone text.pin { font-size: 5px; }
svg.map .zone.here circle { stroke: var(--wood); stroke-width: 2; }
svg.map .zone.next circle { stroke: var(--gold); stroke-width: 1.6; }
svg.map .zone.can { cursor: pointer; }
svg.map .zone.can circle { animation: mappulse 1.4s ease-in-out infinite; }
.forecast { margin: 8px 0; font-size: 1.05rem; }

/* ---- customise ---- */
.cust { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.preview { background: linear-gradient(#bfe6ff, #e8f7ff); border-radius: 16px; display: block; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #ddd; cursor: pointer; }
.sw.on { box-shadow: 0 0 0 3px var(--wood); }
.choices { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-btn { font: inherit; font-size: 0.8rem; padding: 5px 10px; border-radius: 999px; border: 2px solid #eadfcc; background: #fff; cursor: pointer; color: var(--ink); min-height: 34px; }
.chip-btn.on { background: var(--wood); color: #fff; border-color: var(--wood); }
.chip-btn.locked { opacity: 0.55; }
.setting { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed #f0e2c8; }
.setting > span { flex: none; min-width: 130px; font-weight: 700; }

/* ---- title ---- */
#title { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: linear-gradient(#7cc4f5, #ffe7c2); overflow: hidden; }
.title-box { position: relative; z-index: 2; width: min(420px, 92vw); text-align: center; background: rgba(255, 253, 247, 0.9); border-radius: 28px; padding: 22px 22px 14px; box-shadow: 0 16px 50px rgba(40, 40, 80, 0.25); max-height: 92vh; overflow-y: auto; }
.title-box h1 { font-size: 2.8rem; color: var(--wood-dark); letter-spacing: 1px; margin: 0; text-shadow: 0 3px 0 #f5d79a; }
.tagline { color: var(--ink-soft); margin: 4px 0 16px; }
#title-menu { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.slotpick { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.slot-card { display: flex; gap: 6px; align-items: center; background: #fff; border-radius: 14px; padding: 8px 10px; border: 2px solid #f0e6d6; flex-wrap: wrap; }
.credits { margin-top: 14px; }
.title-sky { position: absolute; inset: 0; }
.title-cloud { position: absolute; width: 220px; height: 70px; background: #fff; border-radius: 999px; opacity: 0.85; animation: drift 40s linear infinite; }
.title-cloud::before, .title-cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.title-cloud::before { width: 100px; height: 100px; left: 30px; top: -50px; }
.title-cloud::after { width: 80px; height: 80px; left: 110px; top: -36px; }
.title-cloud.c1 { top: 12%; left: -240px; }
.title-cloud.c2 { top: 62%; left: -240px; animation-delay: -15s; transform: scale(1.4); }
.title-cloud.c3 { top: 82%; left: -240px; animation-delay: -28s; transform: scale(0.8); }
.title-island { position: absolute; left: 50%; top: 4%; transform: translateX(-50%); width: 200px; animation: bob 4s ease-in-out infinite; opacity: 0.9; }
.ti-top { height: 26px; background: #94d184; border-radius: 14px; }
.ti-rock { height: 80px; background: linear-gradient(#9a8f84, #6a6058); clip-path: polygon(0 0, 100% 0, 70% 60%, 50% 100%, 30% 55%); margin-top: -4px; }
.ti-mill { position: absolute; left: 120px; top: -60px; width: 20px; height: 64px; background: #efe4d0; border-radius: 4px 4px 0 0; }
.ti-mill::after { content: '✢'; position: absolute; top: -26px; left: -12px; font-size: 40px; color: #f4ecdc; animation: spin 6s linear infinite; }

@media (max-width: 720px) {
  .panel, .panel.wide { width: 100vw; max-height: 92vh; border-radius: 22px 22px 0 0; align-self: flex-end; }
  #panel-root { align-items: flex-end; }
  .cards { grid-template-columns: 1fr 1fr; }
  .cust { grid-template-columns: 1fr; }
  .logrow { grid-template-columns: 1fr 90px; }
  .logrow .bar { grid-column: 1 / -1; grid-row: 2; }
  .bench { grid-template-columns: repeat(4, 1fr); }
  .recipes, .almanac, .spots { grid-template-columns: 1fr; }
  .title-box h1 { font-size: 2.3rem; }
}
