/* ================= AI 水手 Photobooth ================= */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --navy: #0b1e33;
    --navy-2: #12293f;
    --ocean: #1b4a6b;
    --sky: #63b3ed;
    --gold: #f6c445;
    --wood: #b5732f;
    --red: #e0533d;
    --text: #eaf2ff;
    --dim: #9fb4c9;
    --radius: 18px;
}

html, body { height: 100%; }
body {
    font-family: "PingFang HK", "Microsoft JhengHei", "微軟正黑體", -apple-system, "Segoe UI", sans-serif;
    background: radial-gradient(circle at 50% -20%, #1b4a6b 0%, #0b1e33 55%, #061321 100%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* screens */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* buttons */
.btn-primary, .btn-secondary {
    border: none; cursor: pointer; font-weight: 700;
    border-radius: 50px; font-size: 1rem; padding: 14px 34px;
    transition: transform .2s, box-shadow .2s, background .2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold), #ff9f43);
    color: #3a2400; box-shadow: 0 8px 24px rgba(246,196,69,.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(246,196,69,.5); }
.btn-secondary {
    background: rgba(255,255,255,.08); color: var(--text);
    border: 1px solid rgba(255,255,255,.18);
}
.btn-secondary:hover { background: rgba(255,255,255,.16); }
.btn-secondary.small { padding: 10px 18px; font-size: .85rem; }

/* ---------- home ---------- */
.home-wrap { max-width: 760px; margin: 0 auto; padding: 64px 22px; text-align: center; }
.home-badge {
    display: inline-block; padding: 7px 20px; border-radius: 50px;
    background: rgba(99,179,237,.15); border: 1px solid rgba(99,179,237,.4);
    color: #bfe0ff; font-size: .82rem; letter-spacing: 3px; margin-bottom: 26px;
}
.home-title {
    font-size: 3.4rem; line-height: 1.15; font-weight: 900;
    background: linear-gradient(135deg, var(--gold), #ff9f43, #63b3ed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: 18px;
}
.home-sub { color: var(--dim); font-size: 1.08rem; max-width: 540px; margin: 0 auto 34px; }
.home-steps { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin-bottom: 38px; }
.step {
    display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--dim);
}
.step span {
    width: 26px; height: 26px; border-radius: 50%; background: var(--ocean);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
}
.home-note { color: var(--dim); font-size: .82rem; margin-top: 20px; font-style: italic; }

/* ---------- capture ---------- */
.capture-wrap { max-width: 720px; margin: 0 auto; padding: 30px 18px 60px; text-align: center; }
.capture-wrap h2 { margin-bottom: 20px; font-size: 1.4rem; }
.camera-frame {
    position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 62vh;
    margin: 0 auto 22px; border-radius: 24px; overflow: hidden;
    background: #000; border: 3px solid rgba(255,255,255,.12);
}
#video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.shot-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.shot-preview.show { display: block; }
.face-guide {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 58%; height: 72%; border: 2px dashed rgba(246,196,69,.7);
    border-radius: 45% 45% 45% 45% / 40% 40% 55% 55%; pointer-events: none;
}
.countdown {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 8rem; font-weight: 900; color: var(--gold);
    text-shadow: 0 0 30px rgba(0,0,0,.7); opacity: 0; transition: opacity .2s;
}
.countdown.show { opacity: 1; animation: pop .9s ease; }
@keyframes pop { 0% { transform: translate(-50%,-50%) scale(1.6); } 100% { transform: translate(-50%,-50%) scale(1); } }

.capture-actions { display: flex; gap: 16px; justify-content: center; align-items: center; flex-wrap: wrap; }
.btn-shutter {
    width: 84px; height: 84px; border-radius: 50%; cursor: pointer; font-size: 2rem;
    border: 5px solid rgba(255,255,255,.85); background: var(--red); color: #fff;
    transition: transform .15s;
}
.btn-shutter:active { transform: scale(.92); }

/* ---------- loading ---------- */
.loading-wrap { max-width: 560px; margin: 0 auto; padding: 90px 22px; text-align: center; }
.ship-loader { font-size: 5rem; animation: bob 2.2s ease-in-out infinite; margin-bottom: 20px; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-16px) rotate(4deg); } }
.loading-sub { color: var(--dim); margin: 12px 0 26px; }
.progress-track {
    height: 10px; border-radius: 10px; background: rgba(255,255,255,.1);
    overflow: hidden; margin-bottom: 30px;
}
.progress-bar-indet {
    height: 100%; width: 40%; border-radius: 10px;
    background: linear-gradient(90deg, var(--gold), #ff9f43);
    animation: indet 1.3s ease-in-out infinite;
}
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ---------- studio ---------- */
.studio-top { max-width: 1100px; margin: 0 auto; padding: 22px 18px 10px; text-align: center; }
.studio-top h2 { font-size: 1.5rem; margin: 12px 0 6px; }
.studio-hint { color: var(--dim); font-size: .9rem; }

.studio-stage {
    position: relative; max-width: 1100px; margin: 14px auto;
    aspect-ratio: 16 / 9; border-radius: 20px; overflow: hidden;
    background: linear-gradient(#1b4a6b, #0b1e33);
    border: 2px solid rgba(255,255,255,.12);
    touch-action: none; user-select: none;
}
.ship-bg { width: 100%; height: 100%; object-fit: cover; display: block; }
.station-marker {
    position: absolute; transform: translate(-50%, -50%);
    background: rgba(11,30,51,.72); border: 1px solid rgba(99,179,237,.6);
    color: #cfe6ff; font-size: .72rem; padding: 3px 9px; border-radius: 50px;
    white-space: nowrap; pointer-events: none;
}
.station-marker.active { background: var(--gold); color: #3a2400; border-color: var(--gold); }
.sailor {
    position: absolute; left: 50%; top: 90%;
    transform: translate(-50%, -100%);
    cursor: grab; touch-action: none;
    filter: drop-shadow(0 10px 14px rgba(0,0,0,.45));
    max-width: none;
}
.sailor:active { cursor: grabbing; }
.sailor.hidden { display: none; }
.ship-placeholder {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 20px;
}
.ship-placeholder .tiny { font-size: .75rem; color: var(--dim); }

.studio-controls { max-width: 1100px; margin: 0 auto; padding: 0 18px; }
.station-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0; }
.chip {
    padding: 8px 16px; border-radius: 50px; cursor: pointer; font-size: .85rem;
    background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16); color: var(--text);
    transition: all .2s;
}
.chip:hover { background: rgba(99,179,237,.25); }
.chip.active { background: var(--gold); color: #3a2400; border-color: var(--gold); font-weight: 700; }

.slider-row { display: flex; align-items: center; gap: 14px; justify-content: center; color: var(--dim); }
.slider-row input[type=range] { width: 220px; accent-color: var(--gold); }
.studio-footer { text-align: center; padding: 26px 18px 60px; }

/* ---------- result ---------- */
.result-wrap { max-width: 620px; margin: 0 auto; padding: 34px 18px 70px; text-align: center; }
.result-wrap h2 { margin-bottom: 20px; }
.result-img {
    width: 100%; border-radius: 18px; box-shadow: 0 16px 50px rgba(0,0,0,.55);
    border: 2px solid rgba(255,255,255,.12); margin-bottom: 24px;
}
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.qr-box {
    margin-top: 30px; display: flex; flex-direction: column; align-items: center; gap: 10px;
    background: #fff; padding: 16px; border-radius: 16px; width: fit-content; margin-left: auto; margin-right: auto;
}
.qr-box .tiny { color: #333; }
#qrcode img, #qrcode canvas { display: block; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
    .home-title { font-size: 2.4rem; }
    .studio-stage { aspect-ratio: 4 / 3; }
    .result-actions { flex-direction: column; }
    .result-actions button { width: 100%; }
}

/* ---------- print ---------- */
@media print {
    body { background: #fff; }
    .screen { display: none !important; }
    #screen-result.active { display: block !important; }
    .result-wrap h2, .result-actions, .qr-box { display: none !important; }
    .result-img { box-shadow: none; border: none; }
}
