* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #30291f; color: #402d1c; font: 15px system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff3a4; outline-offset: 2px; }
main { position: relative; max-width: 480px; height: 100svh; min-height: 540px; margin: auto; overflow: hidden; background: #d8ba81 url(assets/book-organizer/home.webp) center/cover; }
header { position: absolute; top: env(safe-area-inset-top, 0); left: 12px; right: 12px; z-index: 3; display: flex; justify-content: space-between; align-items: center; height: 42px; font-size: 12px; }
header a, header span { color: #513e27; background: #fff4dae8; padding: 5px 8px; border-radius: 16px; }
#home { position: absolute; inset: 0; background: linear-gradient(#fff3d550, transparent 40%, transparent 66%, #77502f77); }
h1 { position: absolute; top: 7%; width: 100%; text-align: center; font: bold clamp(38px,10vw,52px) "KaiTi",serif; color: #315640; letter-spacing: .1em; text-shadow: 0 2px #ffe5a3, 2px 0 #ffe5a3, -2px 0 #ffe5a3, 0 -2px #ffe5a3; }
.home-actions { position: absolute; bottom: 16%; left: 4%; right: 4%; display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; }
.home-actions button, .start, .actions button { border: 0; background: url(assets/book-organizer/ui3/start.webp) center/100% 100% no-repeat; font-weight: 700; color: #fff3cd; text-shadow: 0 1px 2px #162c1d; }
.home-actions button { height: 60px; padding: 0 5px 0 23%; font-size: 13px; }
#ranks { background-image: url(assets/book-organizer/ui3/ranks.webp); }
#collection { background-image: url(assets/book-organizer/ui3/collection.webp); }
#options { background-image: url(assets/book-organizer/ui3/settings.webp); }
.start { position: absolute; bottom: 5%; left: 15%; width: 70%; height: 65px; padding-left: 35px; font-size: 22px; }
#loading { position: absolute; bottom: 2%; left: 10%; width: 80%; height: 12px; accent-color: #31644c; }
#play { position: absolute; inset: calc(44px + env(safe-area-inset-top,0px)) 0 0; padding: 0 8px; display: flex; flex-direction: column; gap: 5px; background: linear-gradient(#e8d7beec,#d0ac76ee); }
.hud { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 5px; height: 61px; flex-shrink: 0; }
.hud-card { background: url(assets/book-organizer/ui3/stage.webp) center/100% 100% no-repeat; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-left: 20%; }
.time-card { background-image: url(assets/book-organizer/ui3/time.webp); }
.score-card { background-image: url(assets/book-organizer/ui3/score.webp); }
.hud-card small { font-size: 10px; }
.hud-card strong { font-size: 16px; line-height: 1.3; }
.time-card.urgent strong { color: #b03523; }
.combo { position: relative; height: 30px; flex-shrink: 0; padding: 8px 9% 8px 12%; background: url(assets/book-organizer/ui3/combo.webp) center/100% 100% no-repeat; }
.combo-track { height: 100%; overflow: hidden; border-radius: 10px; background: #302a1c; }
#comboFill { height: 100%; background: linear-gradient(#f9df76,#d3a442); transform-origin: left; transform: scaleX(0); will-change: transform; }
#comboText { position: absolute; inset: 0; display: grid; place-items: center; color: #fff6cc; text-shadow: 0 1px 2px #171e11; font-size: 11px; font-weight: bold; }
.rackboard { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: repeat(var(--rows,6),minmax(0,1fr)); gap: 3px; flex: 1; min-height: 0; }
.rackboard.tutorial { flex: 0 0 110px; margin: auto 0; }
.rack { min-height: 0; min-width: 0; position: relative; display: flex; gap: 1px; align-items: center; justify-content: center; padding: 8% 8% 11%; background: url(assets/book-organizer/ui3/shelf.webp) center/100% 100% no-repeat; }
.slot { z-index: 1; position: relative; height: 92%; width: 31%; min-width: 0; padding: 0; background: none; border: 0; touch-action: none; display: flex; align-items: center; justify-content: center; }
.spine { display: block; height: 100%; max-height: 96px; aspect-ratio: 4/7; background: url(assets/book-organizer/spines-v3.webp) 0 0/2000% 1000% no-repeat; flex-shrink: 0; filter: drop-shadow(1px 1px 1px #23170c); }
.slot.empty { border: 1px dashed #e4c77b66; color: #efd6a6; border-radius: 3px; }
.slot[aria-pressed=true] { transform: translateY(-4px); outline: 2px solid #ffe8a0; background: #e9bc5a22; border-radius: 3px; }
.rack.drop-target { outline: 2px solid #ffe69a; outline-offset: -4px; }
.slot.drop-target { background: #f5d36d55; outline: 2px solid #fff0b2; border-radius: 3px; }
.slot.dragging .spine { opacity: .3; }
.slot.placed .spine { animation: book-settle .14s ease-out; }
.back { position: absolute; inset: 7% 9% 18%; display: flex; justify-content: center; gap: 1px; opacity: .38; pointer-events: none; }
.back i { width: 31%; display: flex; justify-content: center; height: 100%; }
.back .spine { height: 90%; }
.depth { position: absolute; right: 6%; top: 2%; z-index: 2; color: #fce6a6; background: #513b23; padding: 0 3px; font: 9px system-ui; border-radius: 3px; }
.note { flex-shrink: 0; margin: 0; padding: 5px 8px; min-height: 32px; font-size: 12px; line-height: 1.4; background: #fff3d4db; border-radius: 6px; }
.actions { display: flex; gap: 6px; margin-top: 10px; }
.actions button { flex: 1; min-height: 46px; padding: 8px 15px; }
#choices { flex-wrap: wrap; }
#choices button { flex: 1 1 40%; }
.play-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px 6px; margin: 0 0 max(8px,env(safe-area-inset-bottom)); height: 96px; flex-shrink: 0; }
.play-actions button { min-height: 44px; font-size: 13px; padding: 4px 10px; }
.play-actions button:disabled { cursor: default; opacity: .55; }
#refresh { background-image: url(assets/book-organizer/ui3/refresh.webp); padding-left: 30px; font-size: 13px; }
#leave { background-image: url(assets/book-organizer/ui3/leave.webp); padding-left: 28px; font-size: 13px; }
dialog { width: min(94vw,430px); max-height: 85svh; overflow: auto; border: 30px solid transparent; border-image: url(assets/book-organizer/ui3/panel.webp) 90 fill / 30px / 0 stretch; padding: 10px 12px; color: #3c2b1a; background: #f4dfb4; border-radius: 12px; box-shadow: 0 12px 60px #24170cad; }
dialog::backdrop { background: #24170c99; }
dialog h2 { font: bold 23px "KaiTi",serif; text-align: center; margin: 5px 0 16px; }
#content { font-size: 14px; line-height: 1.7; }
#content ol { padding-left: 23px; }
#content a { color: #315340; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill,minmax(34px,1fr)); gap: 8px; max-height: 48svh; overflow: auto; }
.sample { height: 112px; display: flex; justify-content: center; align-items: center; }
#dragBook { position: fixed; pointer-events: none; z-index: 99; height: 88px; width: 50.286px; transform: translate(-50%,-65%); }
.guided { animation: guide 1s infinite alternate; }
.hinted { outline: 3px solid #fff3a4; background: #ffe48066; border-radius: 3px; }
.hinted .spine { filter: drop-shadow(0 0 4px #ffeb85); }
.rack.cleared { animation: cell-pop .32s ease-out; }
.rack.cleared::after { content: attr(data-points); position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; color: #fff9c3; text-shadow: 0 1px 3px #5d3410; font-size: 20px; font-weight: bold; pointer-events: none; animation: points .4s ease-out; }
@keyframes cell-pop { 40% { transform: scale(1.08); filter: brightness(1.35); } }
@keyframes points { to { opacity: 0; transform: translateY(-15px); } }
@keyframes guide { to { box-shadow: 0 0 0 2px #fff5ab,0 0 10px #ffe582; } }
@keyframes book-settle { from { transform: translateY(-4px); } to { transform: translateY(0); } }
@media(max-height:680px) { .hud { height: 53px; } .combo { height: 25px; padding-top: 6px; padding-bottom: 6px; } .play-actions { height: 92px; } .note { min-height: 27px; font-size: 11px; } #play { gap: 3px; } }
@media(prefers-reduced-motion:reduce) { * { animation: none !important; } }
