/* css/base.css — shared look: stage, shell, 9-slice panels and buttons, cards, modal, toast, night mode */
:root {
  --pink: #f6b6cf; --pink-d: #e37fa8; --lav: #c7b0ef; --lav-d: #8e6cc9; --cream: #fff7ee; --gold: #e9c98a; --gold-d: #b98d43;
  --plum: #5b2d63; --ink: #4b2a57; --ink-soft: #7a5a86; --sky: #a9d6f2;
  --panel-bg: rgba(255, 247, 238, 0.9); --glass: rgba(255, 250, 245, 0.55);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  --outline: 0 2px 0 var(--plum), 2px 0 0 var(--plum), -2px 0 0 var(--plum), 0 -2px 0 var(--plum), 1.5px 1.5px 0 var(--plum), -1.5px 1.5px 0 var(--plum), 1.5px -1.5px 0 var(--plum), -1.5px -1.5px 0 var(--plum), 0 4px 0 rgba(91, 45, 99, 0.45);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3e6f1; font-family: var(--font); color: var(--ink); user-select: none; -webkit-user-select: none; }
#bg-layer { position: fixed; inset: 0; background: url(../assets/hall-bg.webp) center / cover no-repeat; filter: blur(6px) saturate(1.1); transform: scale(1.05); transition: background-image .6s; }
body.night #bg-layer { background-image: url(../assets/bg-night.webp); }
#stage { position: absolute; left: 50%; top: 50%; width: 960px; height: 540px; transform-origin: 50% 50%; overflow: hidden;
  background: url(../assets/hall-bg.webp) center / cover no-repeat; }
body.night #stage { background-image: url(../assets/bg-night.webp); }
#bg-fx { position: absolute; left: 0; top: 0; width: 960px; height: 540px; pointer-events: none; z-index: 1; }
#fx-top { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.hidden { display: none !important; }
.display { font-weight: 900; color: #fff; text-shadow: var(--outline); letter-spacing: .02em; }
button { font-family: var(--font); color: inherit; }
input, textarea { font-family: var(--font); user-select: text; -webkit-user-select: text; }
::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

/* ---------- 9-slice panel & button ---------- */
/* ui-panel.webp (512²): the frame sits at y 74–411, x 10–504 of the picture; slices skip its transparent margin via outset */
.panel { border-style: solid; border-width: 24px 22px 26px 22px; border-image-source: url(../assets/ui-panel.webp); border-image-slice: 150 85 190 85 fill; border-image-width: 44px 26px 56px 26px; border-image-outset: 22px 3px 30px 3px; border-image-repeat: stretch; color: var(--ink); filter: drop-shadow(0 6px 14px rgba(91, 45, 99, .25)); }
.btn { position: relative; min-height: 66px; min-width: 120px; padding: 0 22px; border-style: solid; border-width: 14px 26px; border-image: url(../assets/ui-button.webp) 40% 24% fill / 14px 26px stretch; background: none;
  font-size: 21px; font-weight: 900; color: #fff; text-shadow: var(--outline); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s cubic-bezier(.3, 1.6, .5, 1), filter .15s; line-height: 1.1; }
.btn:hover, .btn.kfocus { filter: brightness(1.08) drop-shadow(0 0 10px rgba(255, 220, 160, .9)); transform: scale(1.04); }
.btn:active { transform: scale(.94); }
.btn.primary { filter: hue-rotate(-8deg) saturate(1.2) drop-shadow(0 0 8px rgba(255, 210, 140, .7)); }
.btn.primary:hover, .btn.primary.kfocus { filter: hue-rotate(-8deg) saturate(1.2) brightness(1.1) drop-shadow(0 0 14px rgba(255, 220, 160, 1)); }
.btn.lav { filter: hue-rotate(40deg) saturate(.9); }
.btn.lav:hover, .btn.lav.kfocus { filter: hue-rotate(40deg) saturate(.9) brightness(1.1) drop-shadow(0 0 10px rgba(220, 200, 255, .9)); }
.btn:disabled { filter: grayscale(.8) opacity(.55); cursor: default; transform: none; }
.btn.small { min-height: 52px; min-width: 64px; font-size: 18px; border-width: 12px 20px; border-image-width: 12px 20px; padding: 0 12px; }
.icon-btn { width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--gold); background: radial-gradient(circle at 35% 30%, #fff, var(--pink) 75%); color: var(--plum);
  font-size: 26px; font-weight: 900; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 var(--gold-d), 0 6px 12px rgba(91, 45, 99, .25); transition: transform .12s; }
.icon-btn:hover, .icon-btn.kfocus { transform: scale(1.08); box-shadow: 0 3px 0 var(--gold-d), 0 0 14px rgba(255, 215, 150, .95); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.on { background: radial-gradient(circle at 35% 30%, #fff, #ff8fb8 75%); color: #fff; text-shadow: 0 1px 0 var(--plum); }
.chip { height: 46px; padding: 0 16px 0 6px; border-radius: 23px; border: 2px solid var(--gold); background: rgba(255, 247, 238, .85); display: inline-flex; align-items: center; gap: 6px;
  font-size: 20px; font-weight: 900; color: var(--plum); cursor: pointer; box-shadow: 0 3px 8px rgba(91, 45, 99, .2); }
.chip img { width: 36px; height: 36px; object-fit: contain; }
.chip.kfocus, .chip:hover { box-shadow: 0 0 12px rgba(255, 215, 150, .95); }
.seg { display: inline-flex; gap: 6px; padding: 5px; border-radius: 30px; background: rgba(255, 247, 238, .7); border: 2px solid var(--gold); }
.seg button { min-height: 48px; min-width: 60px; padding: 0 14px; border-radius: 24px; border: 0; background: transparent; font-size: 18px; font-weight: 800; color: var(--ink-soft); cursor: pointer; }
.seg button.on { background: linear-gradient(180deg, #ffc6dc, var(--pink-d)); color: #fff; text-shadow: 0 1px 0 var(--plum), 0 -1px 0 var(--plum), 1px 0 0 var(--plum), -1px 0 0 var(--plum); }
.seg button.kfocus { box-shadow: 0 0 0 3px var(--gold), 0 0 12px rgba(255, 215, 150, .9); }
.field { width: 100%; min-height: 66px; padding: 10px 16px; border-radius: 18px; border: 2px solid var(--gold); background: rgba(255, 252, 248, .92); font-size: 19px; color: var(--ink); outline: none;
  box-shadow: inset 0 2px 6px rgba(91, 45, 99, .12); }
.field:focus, .field.kfocus { border-color: var(--pink-d); box-shadow: 0 0 0 3px rgba(246, 182, 207, .6), inset 0 2px 6px rgba(91, 45, 99, .12); }
.field::placeholder { color: #b49bb8; }
textarea.field { resize: none; line-height: 1.5; }
.kfocus { outline: none; }
[data-nav].kfocus { box-shadow: 0 0 0 4px var(--gold), 0 0 18px rgba(255, 215, 150, .95) !important; }

/* ---------- title ---------- */
#title-screen { position: absolute; inset: 0; z-index: 30; cursor: pointer; overflow: hidden; }
#title-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: titleZoom 18s ease-in-out infinite alternate; }
#title-veil { position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 25%, rgba(255, 247, 238, .35), transparent 60%); }
#title-logo { position: absolute; left: 4%; top: 6%; width: 56%; max-height: 36%; object-fit: contain; object-position: left top; filter: drop-shadow(0 6px 10px rgba(91, 45, 99, .35)); }
#title-screen.in #title-logo { animation: logoIn .7s cubic-bezier(.3, 1.5, .5, 1) both, logoFloat 4s ease-in-out .7s infinite; }
#title-prompt { position: absolute; left: 18%; right: 18%; bottom: 64px; text-align: center; font-size: 30px; animation: pulse 1.8s ease-in-out infinite; }
#title-hint { position: absolute; left: 0; right: 0; bottom: 30px; text-align: center; font-size: 18px; font-weight: 800; color: var(--plum); text-shadow: 0 0 6px #fff, 0 0 10px #fff; }
#title-screen.out { animation: fadeOut .4s forwards; pointer-events: none; }
@keyframes titleZoom { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes logoIn { 0% { opacity: 0; transform: translateY(-40px) scale(.8); } 100% { opacity: 1; transform: none; } }
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse { 0%, 100% { opacity: .75; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes fadeOut { to { opacity: 0; } }

/* ---------- intro ---------- */
#intro-layer { position: absolute; inset: 0; z-index: 40; background: #f6e8f2 url(../assets/title-bg.webp) center / cover; }
#intro-video { width: 100%; height: 100%; object-fit: cover; }
#intro-skip { position: absolute; right: 120px; bottom: 26px; min-height: 72px; min-width: 150px; }

/* ---------- shell ---------- */
#shell { position: absolute; inset: 0; z-index: 2; }
#rail { position: absolute; left: 8px; top: 92px; bottom: 10px; width: 88px; display: flex; flex-direction: column; gap: 6px; }
#rail .tab { flex: 1; min-height: 70px; border-radius: 22px; border: 2px solid rgba(233, 201, 138, .7); background: rgba(255, 247, 238, .72); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  box-shadow: 0 3px 8px rgba(91, 45, 99, .15); transition: transform .15s, background .2s; }
#rail .tab img { width: 44px; height: 44px; object-fit: contain; transition: transform .2s; }
#rail .tab .tab-label { font-size: 17px; font-weight: 900; color: var(--ink-soft); }
#rail .tab.on { background: linear-gradient(180deg, #ffe1ec, #f7b6cf); border-color: var(--gold); transform: scale(1.04); }
#rail .tab.on img { transform: scale(1.12) rotate(-6deg); }
#rail .tab.on .tab-label { color: #fff; text-shadow: 0 1px 0 var(--plum), 0 -1px 0 var(--plum), 1px 0 0 var(--plum), -1px 0 0 var(--plum); }
#rail .tab.kfocus, #rail .tab:hover { box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(255, 215, 150, .9); }
#topbar { position: absolute; left: 100px; right: 96px; top: 8px; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#page-title { font-size: 30px; padding-left: 4px; white-space: nowrap; }
#pages { position: absolute; left: 104px; right: 10px; top: 76px; bottom: 8px; }
.page { position: absolute; inset: 0; display: none; }
.page.active, .page.leave { display: block; }
.page.enter { animation: pageIn .32s cubic-bezier(.3, 1.4, .5, 1) both; }
.page.leave { animation: pageOut .2s ease-in both; pointer-events: none; }
@keyframes pageIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pageOut { to { opacity: 0; transform: translateY(-10px); } }
.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* ---------- tarot card (3D flip) ---------- */
.tcard { position: relative; width: 120px; height: 180px; perspective: 900px; flex: none; }
.tcard-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.4, 1.4, .5, 1); }
.tcard.flipped .tcard-inner { transform: rotateY(180deg); }
.tcard-back, .tcard-front { position: absolute; inset: 0; border-radius: 9px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 4px 10px rgba(60, 25, 70, .35), 0 0 0 2px rgba(233, 201, 138, .9); }
.tcard-back { background: #f2c5d6 center / cover no-repeat; }
.tcard-front { transform: rotateY(180deg); background: linear-gradient(160deg, #fff4f8, #e8dcfa); }
.tcard-front img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.tcard.rev .tcard-front img { transform: rotate(180deg); }
.tcard-front.noimg::after { content: "✦"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--gold-d); }

/* ---------- modal ---------- */
#overlay-root { position: absolute; inset: 0; z-index: 35; pointer-events: none; }
.modal-wrap { position: absolute; inset: 0; background: rgba(60, 30, 70, .45); display: flex; align-items: center; justify-content: center; pointer-events: auto; animation: fadeIn .18s both; }
.modal-wrap.out { animation: fadeOut .2s forwards; }
.modal { position: relative; width: 600px; max-width: 92%; max-height: 92%; display: flex; flex-direction: column; animation: popIn .3s cubic-bezier(.3, 1.6, .5, 1) both; }
.modal.wide { width: 820px; }
.modal-title { font-size: 28px; text-align: center; margin: 2px 50px 10px; }
.modal-x { position: absolute; right: 2px; top: 0; width: 52px; height: 52px; font-size: 22px; }
.modal-body { font-size: 19px; line-height: 1.55; overflow-y: auto; padding: 4px 8px; min-height: 40px; user-select: text; }
.modal-buttons { display: flex; justify-content: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.help-text p { margin: 0 0 8px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.82); } }

/* ---------- toast ---------- */
#toast-root { position: absolute; left: 0; right: 0; top: 80px; z-index: 45; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 10px 24px; border-radius: 26px; background: linear-gradient(180deg, rgba(255, 247, 238, .97), rgba(255, 224, 236, .97)); border: 2px solid var(--gold); font-size: 19px; font-weight: 900; color: var(--plum);
  box-shadow: 0 6px 16px rgba(91, 45, 99, .3); animation: toastIn .35s cubic-bezier(.3, 1.6, .5, 1) both; }
.toast.out { animation: fadeOut .35s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.9); } }

/* ---------- night mode ---------- */
body.night { --panel-bg: rgba(52, 36, 78, .9); --glass: rgba(40, 28, 64, .55); --ink: #f4e9ff; --ink-soft: #cdb8e8; }
body.night .panel { --ink: #4b2a57; --ink-soft: #7a5a86; color: #4b2a57; filter: drop-shadow(0 0 16px rgba(200, 170, 255, .35)); }
body.night #rail .tab { background: rgba(52, 36, 78, .78); }
body.night #rail .tab.on { background: linear-gradient(180deg, #8e6cc9, #c35d93); }
body.night .chip, body.night .seg, body.night .field { background: rgba(52, 36, 78, .85); color: #f4e9ff; }
body.night .chip { color: #fff3c9; }
body.night .toast { background: linear-gradient(180deg, rgba(70, 48, 100, .97), rgba(98, 52, 100, .97)); color: #fff; }
body.night .modal-wrap { background: rgba(10, 5, 25, .55); }
