/* Game layer: full-screen harbor scene, HUD, floating dock, ribbon titles, home scene. Loaded last. */
:root { --dock: 96px; --hudh: 56px; }
body { background: #0e1b3d; background-image: none; }
#scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #14224a; }
#scene svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body[data-screen]:not([data-screen="/play"]) #scene svg { filter: blur(3px) brightness(.55) saturate(.9); transform: scale(1.04); }
#scene svg, #scene { transition: filter .5s; }
@keyframes cloudmove { from { transform: translateX(-120px); } to { transform: translateX(160px); } }
@keyframes wavemove { from { transform: translateX(0); } to { transform: translateX(-100px); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-5px) rotate(1deg); } }
@keyframes sail { from { transform: translateX(-260px); } to { transform: translateX(260px); } }
#scene .cloud { animation: cloudmove 38s ease-in-out infinite alternate; } #scene .c2 { animation-duration: 52s; animation-direction: alternate-reverse; } #scene .c3 { animation-duration: 44s; }
#scene .wv { animation: wavemove 7s linear infinite; } #scene .w2 { animation-duration: 5s; } #scene .w3 { animation-duration: 3.6s; }
#scene .bt { animation: sail 60s ease-in-out infinite alternate; } #scene .b2 { animation-duration: 80s; animation-direction: alternate-reverse; }
#scene .boat { animation: bob 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
#scene .sunc { animation: breathe 8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

#app { position: relative; z-index: 1; }
body > #toasts { z-index: 90; }

/* ---------- HUD (replaces the app top bar) ---------- */
.topbar { position: fixed; left: 0; right: 0; top: 0; background: linear-gradient(rgba(8,12,28,.82), rgba(8,12,28,0)); border: 0; box-shadow: none; padding: max(.5rem, env(safe-area-inset-top)) .8rem .9rem; min-height: var(--hudh); }
.demo-flag { position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; opacity: .85; font-size: .62rem; }
.rankbar { position: fixed; z-index: 29; left: 0; right: 0; top: calc(var(--hudh) + env(safe-area-inset-top)); background: none; border: 0; padding: .1rem .8rem .5rem; }
body[data-screen="/play"] .rankbar { display: none; }
.layout { display: block; padding-top: calc(var(--hudh) + 64px + env(safe-area-inset-top)); }
body[data-screen="/play"] .layout { padding-top: 0; }
main { padding-bottom: calc(var(--dock) + 30px + env(safe-area-inset-bottom)); }
body[data-screen="/play"] main { padding: 0; max-width: none; }

/* ---------- floating dock (replaces tab bar / side rail) ---------- */
.dock { position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; align-items: flex-end; gap: .35rem; padding: .45rem .7rem .5rem; width: min(560px, calc(100vw - 16px));
  justify-content: space-around; background: linear-gradient(rgba(22,36,74,.94), rgba(10,16,38,.96)); border: 3px solid var(--sumi); border-radius: 26px; box-shadow: 0 0 0 2px var(--gold), 0 10px 24px rgba(0,0,0,.55); }
.dock a, .dock button { flex: 1 1 0; min-width: 0; background: none; border: 0; cursor: pointer; text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; color: rgba(246,237,218,.78); font-size: .66rem; font-weight: 800; letter-spacing: .04em; position: relative; transition: transform .15s; }
.dock .ic { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; font-family: var(--serif); font-size: 1.6rem; font-weight: 800; background: radial-gradient(circle at 35% 30%, #3b5fa0, #1a2d5c 70%); border: 3px solid var(--sumi); box-shadow: 0 0 0 2px rgba(246,237,218,.35), 0 3px 0 var(--sumi); color: var(--paper); transition: transform .15s, box-shadow .15s; }
.dock a:active .ic, .dock button:active .ic { transform: scale(.9); }
.dock a.on { color: var(--gold-2); }
.dock a.on .ic { background: radial-gradient(circle at 35% 30%, #ff8a63, var(--red) 70%); box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(217,67,43,.8), 0 3px 0 var(--sumi); transform: translateY(-6px) scale(1.08); }
.dock a.hero-btn .ic { width: 62px; height: 62px; margin-top: -18px; font-size: 2rem; background: radial-gradient(circle at 35% 30%, #ff8a63, var(--red) 70%); box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(217,67,43,.75), 0 4px 0 var(--sumi); animation: breathe 3.5s ease-in-out infinite; }
.dock .dot { position: absolute; top: 0; right: 18%; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 2px solid var(--sumi); animation: pulseDot 1.4s infinite; }
@keyframes pulseDot { 50% { transform: scale(1.35); } }

/* ---------- ribbon titles + panel look for non-home screens ---------- */
main > h1 { display: block; text-align: center; margin: .4rem auto 1rem; padding: .45rem 2.2rem; width: max-content; max-width: 100%; color: var(--paper); background: linear-gradient(#e8553a, var(--red-2)); border: 3px solid var(--sumi); text-shadow: 0 2px 0 rgba(0,0,0,.45); position: relative; font-size: 1.45rem; box-shadow: 0 4px 0 rgba(0,0,0,.45); clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 50%, 100% 100%, 0 100%, 18px 50%); }
main > h1::after { display: none; }
@media (min-width: 761px) and (min-height: 521px) { main > h1 { font-size: 1.8rem; } }

/* ---------- HOME: a scene with a HUD, not a dashboard ---------- */
.home { position: relative; min-height: 100dvh; padding: calc(var(--hudh) + 14px + env(safe-area-inset-top)) 12px calc(var(--dock) + 24px + env(safe-area-inset-bottom)); display: grid; gap: 10px;
  grid-template-columns: 1fr 64px; grid-template-rows: auto auto 1fr auto; grid-template-areas: "plate plate" "events side" "hero hero" "acts acts"; }
@media (min-width: 900px) { .home { grid-template-columns: minmax(250px, 1fr) minmax(0, 1.3fr) minmax(250px, 1fr); grid-template-rows: auto 1fr auto; grid-template-areas: "plate hero side" "events hero side" "acts acts acts"; padding-left: 24px; padding-right: 24px; } }
.plate { grid-area: plate; display: flex; align-items: center; gap: 10px; }
.avatar { width: 64px; height: 64px; flex: 0 0 auto; border-radius: 50%; border: 4px solid var(--sumi); background: var(--paper-2) center/cover; box-shadow: 0 0 0 3px var(--gold), 0 4px 0 rgba(0,0,0,.5); display: grid; place-items: center; font-family: var(--serif); font-weight: 800; font-size: 1.8rem; color: var(--ink); }
.pname { color: var(--paper); font-family: var(--serif); font-weight: 800; font-size: 1.15rem; text-shadow: 0 2px 0 var(--sumi); line-height: 1.1; }
.pname small { display: block; font-family: var(--sans); font-size: .72rem; color: var(--gold-2); letter-spacing: .08em; }
.seal-rank { margin-left: auto; text-align: center; text-decoration: none; position: relative; flex: 0 0 auto; }
.seal-rank .n { display: block; min-width: 88px; padding: .35rem .6rem; font-family: var(--serif); font-weight: 800; font-size: 2.2rem; line-height: 1; color: var(--paper); background: linear-gradient(#ee5a3d, var(--red-2)); border: 4px solid var(--sumi); border-radius: 12px 16px 12px 15px; transform: rotate(3deg); box-shadow: inset 0 0 0 3px rgba(246,237,218,.5), 0 5px 0 var(--sumi), 0 0 24px rgba(217,67,43,.65); text-shadow: 0 2px 0 rgba(0,0,0,.4); animation: sealpop .8s cubic-bezier(.2,1.4,.4,1) both; }
.seal-rank.first .n { color: var(--sumi); text-shadow: none; background: linear-gradient(105deg, #d8991f, #fff0a8 40%, #d8991f 60%, #fff0a8); background-size: 220% 100%; animation: shimmer 3s linear infinite; box-shadow: inset 0 0 0 3px rgba(255,255,255,.6), 0 5px 0 var(--sumi), 0 0 30px rgba(244,207,110,.9); }
.seal-rank .b { display: block; margin-top: 8px; color: var(--paper); font-size: .72rem; font-weight: 800; text-shadow: 0 1px 0 var(--sumi); }
@keyframes sealpop { from { transform: scale(2.4) rotate(-14deg); opacity: 0; } to { transform: rotate(3deg); opacity: 1; } }
.events { grid-area: events; display: flex; flex-direction: column; gap: 8px; align-self: start; min-width: 0; }
.evr { display: flex; align-items: center; gap: .5rem; padding: .35rem .8rem .35rem .45rem; color: var(--paper); text-decoration: none; background: linear-gradient(90deg, rgba(10,16,38,.86), rgba(10,16,38,.55)); border-left: 5px solid var(--red); border-radius: 4px 20px 20px 4px; box-shadow: 0 3px 0 rgba(0,0,0,.4); max-width: 100%; transition: transform .15s; animation: slideIn .5s both; }
.evr:hover { transform: translateX(4px); }
.evr.live { border-left-color: var(--gold); } .evr b { display: block; font-size: .82rem; line-height: 1.15; } .evr .cd { color: var(--gold-2); font-size: .8rem; }
.evr .k { font-family: var(--serif); font-size: 1.3rem; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: var(--paper); flex: 0 0 auto; font-weight: 800; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
.side { grid-area: side; display: flex; flex-direction: column; gap: 10px; align-items: center; align-self: start; }
@media (min-width: 900px) { .side { align-items: flex-end; } }
.rbtn { position: relative; width: 58px; height: 58px; border-radius: 50%; border: 4px solid var(--sumi); display: grid; place-items: center; cursor: pointer; text-decoration: none; background: radial-gradient(circle at 35% 30%, #4b72b5, #1d3466 75%); color: var(--paper); font-family: var(--serif); font-weight: 800; font-size: 1.5rem; box-shadow: 0 0 0 3px var(--gold), 0 4px 0 rgba(0,0,0,.5); transition: transform .15s; }
.rbtn:active { transform: scale(.9); } .rbtn:hover { transform: scale(1.08) rotate(-4deg); }
.rbtn small { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-family: var(--sans); font-size: .62rem; color: var(--paper); text-shadow: 0 1px 0 var(--sumi), 0 0 6px var(--sumi); white-space: nowrap; }
.rbtn .dot { position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; background: var(--gold); border: 3px solid var(--sumi); border-radius: 50%; animation: pulseDot 1.4s infinite; }
.side .rbtn { margin-bottom: 14px; }
.herostage { grid-area: hero; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-height: 280px; }
.herostage .aura { position: absolute; bottom: 14%; width: min(78vw, 420px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,220,150,.55), rgba(217,67,43,.0) 68%); animation: breathe 5s ease-in-out infinite; }
.herostage .fig { position: relative; z-index: 1; height: min(46vh, 430px); max-width: 82vw; object-fit: contain; filter: drop-shadow(0 14px 14px rgba(0,0,0,.6)); animation: idle 4.5s ease-in-out infinite; }
@keyframes idle { 50% { transform: translateY(-8px); } }
.herostage .sil { position: relative; z-index: 1; width: min(52vw, 230px); aspect-ratio: .8; display: grid; place-items: center; font-family: var(--serif); font-weight: 800; font-size: min(26vw, 8rem); color: rgba(246,237,218,.9); text-shadow: 0 6px 0 rgba(0,0,0,.5), 0 0 40px rgba(217,67,43,.7); animation: idle 4.5s ease-in-out infinite; background: radial-gradient(ellipse at 50% 90%, rgba(10,16,38,.55), transparent 70%); }
.nameplate { position: relative; z-index: 2; margin-top: -10px; padding: .35rem 1.6rem; color: var(--paper); text-align: center; background: linear-gradient(rgba(14,24,52,.94), rgba(8,12,28,.94)); border: 3px solid var(--gold); border-radius: 6px 22px 6px 22px; box-shadow: 0 5px 0 rgba(0,0,0,.5); }
.nameplate b { font-family: var(--serif); font-size: 1.15rem; display: block; } .nameplate span { font-size: .75rem; color: var(--gold-2); font-weight: 700; letter-spacing: .06em; }
.acts { grid-area: acts; display: grid; grid-template-columns: 1.7fr 1fr 1fr 1fr; gap: 10px; align-items: stretch; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 76px; padding: .4rem .3rem; border: 4px solid var(--sumi); border-radius: 14px 20px 14px 18px; text-decoration: none; color: var(--paper); font-weight: 800; background: linear-gradient(#3d68ab, #1b2f60); box-shadow: 0 0 0 2px var(--gold), 0 6px 0 rgba(0,0,0,.55); position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s; font-size: .8rem; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.act .k { font-family: var(--serif); font-size: 1.9rem; line-height: 1; }
.act:active { transform: translateY(5px); box-shadow: 0 0 0 2px var(--gold), 0 1px 0 rgba(0,0,0,.55); }
.act::after { content: ""; position: absolute; top: 0; left: -80%; width: 50%; height: 100%; background: linear-gradient(105deg, transparent, rgba(255,255,255,.4), transparent); transform: skewX(-20deg); animation: sweep 4.5s ease-in-out infinite; }
@keyframes sweep { 0%, 60% { left: -80%; } 100% { left: 150%; } }
.act.go { background: linear-gradient(#ff6a47, var(--red-2)); min-height: 92px; font-size: 1rem; animation: goPulse 2.4s ease-in-out infinite; }
.act.go .k { font-size: 2.6rem; }
@keyframes goPulse { 0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 6px 0 rgba(0,0,0,.55), 0 0 0 0 rgba(255,106,71,.6); } 50% { box-shadow: 0 0 0 2px var(--gold), 0 6px 0 rgba(0,0,0,.55), 0 0 26px 6px rgba(255,106,71,.55); } }
@media (min-width: 900px) { .acts { max-width: 860px; margin: 0 auto; width: 100%; } .home .herostage .fig { height: min(56vh, 520px); } }
/* phone portrait: the whole home screen fits one view */
.demo-flag { top: 0 !important; bottom: auto !important; left: 50% !important; right: auto !important; transform: translateX(-50%); width: auto; padding: 0 .6rem !important; border-radius: 0 0 8px 8px; font-size: .55rem !important; pointer-events: none; z-index: 96; }
.home { height: 100dvh; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.herostage { min-height: 0; overflow: visible; }
.herostage .fig { height: auto; max-height: 100%; }
@media (max-width: 899px) and (min-height: 521px) {
  .evr { padding: .25rem .7rem .25rem .35rem; gap: .4rem; } .evr b { font-size: .74rem; } .evr .cd { font-size: .72rem; }
  .evr .k { width: 28px; height: 28px; font-size: 1.05rem; }
  .events .evr:nth-child(n+4) { display: none; }
  .events { gap: 5px; }
  .act { min-height: 66px; } .act.go { min-height: 78px; } .act .k { font-size: 1.5rem; } .act.go .k { font-size: 2rem; }
  .acts { grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 7px; font-size: .72rem; }
  .herostage .sil { width: min(40vw, 170px); font-size: min(22vw, 5.5rem); }
  .herostage .aura { width: min(60vw, 300px); }
  .nameplate { padding: .25rem 1rem; } .nameplate b { font-size: 1rem; }
  .home { padding-bottom: calc(var(--dock) + 14px + env(safe-area-inset-bottom)); }
}
@media (min-width: 900px) { .home { min-height: 100dvh; } }
/* landscape phone: the action row replaces the dock on Home */
@media (max-height: 520px) {
  body[data-screen="/play"] .dock { display: none; }
  .home { padding: 46px 10px 8px; height: 100dvh; grid-template-columns: 1.1fr 1.1fr 56px; }
  .events .evr:nth-child(n+3) { display: none; } .evr { padding: .15rem .6rem .15rem .3rem; } .evr b { font-size: .68rem; } .evr .cd { font-size: .66rem; } .evr .k { width: 24px; height: 24px; font-size: .9rem; }
  .side { gap: 4px; } .rbtn { width: 40px; height: 40px; font-size: 1.1rem; border-width: 3px; } .rbtn small { display: none; } .side .rbtn { margin-bottom: 0; }
  .nameplate { padding: .1rem .8rem; } .nameplate b { font-size: .85rem; } .nameplate span { font-size: .62rem; }
  .pname { font-size: .95rem; } .seal-rank .b { display: none; } .seal-rank .n { font-size: 1.3rem; min-width: 56px; padding: .15rem .4rem; }
  .acts { gap: 6px; } .act { min-height: 44px !important; flex-direction: row; gap: .4rem; font-size: .7rem; } .act .k, .act.go .k { font-size: 1.2rem !important; }
}
@media (max-height: 520px) {
  .home { grid-template-columns: 1.1fr 1.2fr 70px; grid-template-rows: auto 1fr auto; grid-template-areas: "plate hero side" "events hero side" "acts acts acts"; padding-top: 50px; padding-bottom: 66px; gap: 6px; }
  .herostage { min-height: 0; } .herostage .fig { height: 40vh; } .herostage .sil { width: 90px; font-size: 3.4rem; }
  .act { min-height: 54px; } .act.go { min-height: 54px; } .act .k { font-size: 1.3rem; } .act.go .k { font-size: 1.5rem; }
  .avatar { width: 46px; height: 46px; font-size: 1.3rem; } .seal-rank .n { font-size: 1.5rem; min-width: 64px; }
  .dock { padding: .2rem .5rem; } .dock .ic { width: 38px; height: 38px; font-size: 1.2rem; } .dock a.hero-btn .ic { width: 44px; height: 44px; margin-top: -10px; } .dock { --dock: 62px; }
  :root { --dock: 68px; }
}
