/* ERUD'OBA — graphic novel styling, mobile-first landscape. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --cream: #f4e6c8;
    --ink: #0a0508;
    --green: #006400;
    --darkred: #8B0000;
    --purple: #6A0DAD;
    --red: #CC2200;
    --coral: #E8722A;
    --gold: #e9b24a;
}

html, body {
    width: 100%; height: 100%;
    background: #000;
    overflow: hidden;
    font-family: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
    color: var(--cream);
    -webkit-user-select: none; user-select: none;
    touch-action: manipulation;
}

#root, #app { width: 100%; height: 100%; position: relative; }

#game-container {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    background: var(--ink);
}
#game-container canvas { display: block; }

/* ---------------- HUD layer ---------------- */
#hud {
    position: absolute; inset: 0;
    pointer-events: none;
    z-index: 10;
}
#hud button { pointer-events: auto; font-family: inherit; }

.level-badge {
    position: absolute; top: 10px; left: 14px;
    font-size: clamp(11px, 1.7vmin, 17px);
    letter-spacing: 0.14em;
    color: var(--cream);
    text-shadow: 0 2px 8px #000, 0 0 2px #000;
    display: flex; flex-direction: column; gap: 2px;
    max-width: 44vw;
}
.level-badge .boss-name {
    font-style: italic; font-size: 0.85em; color: var(--gold); letter-spacing: 0.06em;
}

.sys-btns {
    position: absolute; top: 10px; right: 12px;
    display: flex; gap: 10px;
}
.sys-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(244, 230, 200, 0.4);
    background: rgba(10, 5, 8, 0.65);
    color: var(--cream);
    font-size: 18px;
    cursor: pointer;
    display: grid; place-items: center;
    backdrop-filter: blur(2px);
}
.sys-btn:active { transform: scale(0.92); }

/* ---- health bars ---- */
.bars {
    position: absolute; top: 58px; left: 0; right: 0;
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    transition: opacity 0.3s;
}
.bar-block { flex: 1; max-width: 40%; }
.bar-block.right { text-align: right; }
.fighter-name {
    font-size: clamp(10px, 1.6vmin, 15px);
    letter-spacing: 0.16em;
    margin-bottom: 4px;
    text-shadow: 0 2px 6px #000;
}
.bar-track {
    position: relative;
    height: clamp(14px, 2.6vmin, 22px);
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(244, 230, 200, 0.5);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    transition: width 0.35s ease-out;
}
.bar-fill.moraja { background: linear-gradient(180deg, #0a8a0a, var(--green)); }
.bar-fill.opp { background: linear-gradient(180deg, #c22, var(--darkred)); float: right; }
.bar-hp {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    font-size: clamp(10px, 1.6vmin, 14px);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
.bar-sub {
    font-size: clamp(9px, 1.4vmin, 13px);
    margin-top: 3px;
    opacity: 0.85;
    font-style: italic;
    text-shadow: 0 1px 4px #000;
}
.bar-sub.olcani-on { color: #ff7a4a; font-weight: bold; font-style: normal; letter-spacing: 0.08em; }
.vs {
    font-size: clamp(16px, 3vmin, 28px);
    font-weight: bold;
    color: var(--gold);
    text-shadow: 0 0 12px rgba(233, 178, 74, 0.7), 0 2px 4px #000;
    padding-top: 10px;
}

/* ---- bottom-left preparation circles ---- */
.counters {
    position: absolute; left: 14px; bottom: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.circle {
    position: relative;
    width: clamp(56px, 11vmin, 76px);
    height: clamp(56px, 11vmin, 76px);
    border-radius: 50%;
    border: 3px solid rgba(244, 230, 200, 0.7);
    color: var(--cream);
    display: grid; place-items: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    transition: transform 0.12s, filter 0.2s;
}
.circle.purple { background: radial-gradient(circle at 35% 30%, #9a3adf, var(--purple) 70%); }
.circle.red { background: radial-gradient(circle at 35% 30%, #ff5a2a, var(--red) 70%); }
.circle.coral { background: radial-gradient(circle at 35% 30%, #ff9a5a, var(--coral) 70%); }
.circle:active { transform: scale(0.9); }
.circle:disabled { filter: grayscale(0.8) brightness(0.55); cursor: default; }
.circle .badge {
    position: absolute; right: -4px; bottom: -4px;
    min-width: 26px; height: 26px;
    border-radius: 13px;
    background: var(--ink);
    border: 2px solid var(--cream);
    font-size: 14px; font-weight: bold;
    display: grid; place-items: center;
    padding: 0 4px;
}

/* ---- bottom-right action buttons ---- */
.actions {
    position: absolute; right: 16px; bottom: 16px;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.act-btn {
    width: clamp(64px, 13vmin, 92px);
    height: clamp(64px, 13vmin, 92px);
    border-radius: 50%;
    border: 3px solid rgba(244, 230, 200, 0.75);
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--cream);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.65);
    transition: transform 0.12s, box-shadow 0.25s, filter 0.25s;
}
.act-btn:active { transform: scale(0.9); }
.act-btn.sword { background: radial-gradient(circle at 35% 30%, #5a2a12, #2a1208 75%); }
.act-btn.eye { background: radial-gradient(circle at 35% 30%, #3a2a5a, #16091f 75%); }
.act-btn.off { filter: grayscale(0.85) brightness(0.5); cursor: default; }
.act-btn.eye.ready {
    border-color: var(--gold);
    animation: goldfire 1.1s ease-in-out infinite alternate;
}
@keyframes goldfire {
    from { box-shadow: 0 0 12px 2px rgba(255, 190, 80, 0.55), 0 5px 18px rgba(0,0,0,0.6); }
    to   { box-shadow: 0 0 26px 8px rgba(255, 210, 120, 0.85), 0 5px 18px rgba(0,0,0,0.6); }
}
.act-btn .lock { display: grid; place-items: center; opacity: 0.85; }

/* ---- block window button ---- */
.block-btn {
    position: absolute; left: 50%; top: 58%;
    transform: translate(-50%, -50%);
    width: clamp(72px, 15vmin, 104px);
    height: clamp(72px, 15vmin, 104px);
    border-radius: 50%;
    border: 4px solid #9be8ff;
    background: radial-gradient(circle at 35% 30%, rgba(60,140,200,0.9), rgba(10,30,60,0.92));
    color: #eaffff;
    cursor: pointer;
    display: grid; place-items: center;
    animation: blockpulse 0.5s ease-in-out infinite alternate;
    z-index: 15;
}
@keyframes blockpulse {
    from { box-shadow: 0 0 10px rgba(155, 232, 255, 0.5); }
    to { box-shadow: 0 0 30px rgba(155, 232, 255, 0.95); }
}
.block-timer {
    position: absolute; inset: -10px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--gold);
    animation: blockring 1s linear forwards;
}
@keyframes blockring { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ---- clue card ---- */
.clue-card {
    position: absolute; left: 50%; top: 96px;
    transform: translateX(-50%);
    width: min(680px, 84vw);
    background: linear-gradient(180deg, rgba(20, 10, 16, 0.94), rgba(10, 5, 8, 0.94));
    border: 2px solid rgba(233, 178, 74, 0.55);
    border-radius: 8px;
    padding: 14px 20px 16px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.75);
    animation: clueIn 0.45s ease-out;
    z-index: 14;
}
@keyframes clueIn { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.clue-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.cdot { width: 9px; height: 9px; border-radius: 50%; background: rgba(244, 230, 200, 0.25); border: 1px solid rgba(244,230,200,0.5); }
.cdot.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.clue-text {
    font-size: clamp(14px, 2.5vmin, 21px);
    font-style: italic;
    line-height: 1.45;
    color: var(--cream);
    text-shadow: 0 2px 6px #000;
}

/* ---- tactical choices row ---- */
.tactics-row {
    position: absolute; right: 16px; bottom: calc(16px + clamp(64px, 13vmin, 92px) * 2 + 28px);
    display: flex; gap: 12px;
    animation: tacticsIn 0.35s ease-out;
    z-index: 16;
}
@keyframes tacticsIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.tactic {
    width: clamp(56px, 11vmin, 78px);
    height: clamp(56px, 11vmin, 78px);
    border-radius: 14px;
    border: 2px solid var(--gold);
    background: rgba(16, 8, 14, 0.92);
    color: var(--cream);
    cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 0 16px rgba(233, 178, 74, 0.35);
}
.tactic:active { transform: scale(0.9); }

/* ---- prep flash banner ---- */
.prep-flash {
    position: absolute; left: 50%; top: 42%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 18;
    animation: flashIn 2s ease-out forwards;
    pointer-events: none;
}
.prep-flash .prep-name {
    display: block;
    font-size: clamp(30px, 7vmin, 58px);
    font-style: italic;
    letter-spacing: 0.08em;
    color: var(--cream);
}
.prep-flash .prep-kind {
    display: block;
    margin-top: 6px;
    font-size: clamp(11px, 1.9vmin, 16px);
    letter-spacing: 0.3em;
    opacity: 0.9;
}
.prep-flash.agbo .prep-name { text-shadow: 0 0 18px var(--purple), 0 0 42px var(--purple), 0 3px 6px #000; }
.prep-flash.olcani .prep-name { text-shadow: 0 0 18px var(--coral), 0 0 42px var(--coral), 0 3px 6px #000; }
@keyframes flashIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
    12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -54%) scale(1); }
}

/* ---- hint toast ---- */
.hint-toast {
    position: absolute; left: 50%; bottom: calc(16px + clamp(64px, 13vmin, 92px) * 2 + 30px);
    transform: translateX(-50%);
    background: rgba(10, 5, 8, 0.85);
    border: 1px solid rgba(233, 178, 74, 0.5);
    border-radius: 20px;
    padding: 7px 18px;
    font-size: clamp(11px, 1.8vmin, 15px);
    font-style: italic;
    letter-spacing: 0.06em;
    color: var(--gold);
    animation: clueIn 0.3s ease-out;
    z-index: 13;
    pointer-events: none;
    white-space: nowrap;
}

/* ---- damage vignette ---- */
.red-vignette {
    position: absolute; inset: 0;
    z-index: 20;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 52%, rgba(160, 0, 0, 0.55) 100%);
    animation: vigFade 0.32s ease-out forwards;
}
@keyframes vigFade { from { opacity: 1; } to { opacity: 0; } }

/* ---------------- overlays ---------------- */
.overlay {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    z-index: 30;
    pointer-events: auto;
}
.overlay.dim { background: rgba(4, 2, 4, 0.78); backdrop-filter: blur(3px); }
.panel {
    background: linear-gradient(180deg, rgba(26, 12, 20, 0.97), rgba(10, 5, 8, 0.97));
    border: 2px solid rgba(233, 178, 74, 0.5);
    border-radius: 12px;
    padding: clamp(20px, 4vmin, 38px) clamp(24px, 6vmin, 56px);
    text-align: center;
    max-width: min(640px, 90vw);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
    display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.kicker {
    font-size: clamp(10px, 1.7vmin, 14px);
    letter-spacing: 0.34em;
    color: var(--gold);
    opacity: 0.9;
}
.title {
    font-size: clamp(38px, 9vmin, 76px);
    letter-spacing: 0.1em;
    color: var(--cream);
    text-shadow: 0 0 24px rgba(233, 178, 74, 0.4), 0 4px 10px #000;
}
.subtitle { font-style: italic; opacity: 0.85; font-size: clamp(12px, 2.1vmin, 17px); }
.result { font-size: clamp(28px, 6vmin, 52px); letter-spacing: 0.1em; }
.result.win { color: var(--gold); text-shadow: 0 0 26px rgba(233, 178, 74, 0.65), 0 3px 8px #000; }
.result.lose { color: #ff6a5a; text-shadow: 0 0 26px rgba(200, 30, 20, 0.6), 0 3px 8px #000; }
.result-sub { font-style: italic; line-height: 1.5; font-size: clamp(12px, 2.1vmin, 17px); max-width: 46ch; }
.rewards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.rw {
    font-size: clamp(11px, 1.9vmin, 15px);
    padding: 6px 14px;
    border-radius: 18px;
    border: 1.5px solid;
    letter-spacing: 0.04em;
}
.rw.purple { border-color: var(--purple); color: #cba6ff; background: rgba(106, 13, 173, 0.18); }
.rw.red { border-color: var(--red); color: #ff9a7a; background: rgba(204, 34, 0, 0.18); }
.rw.coral { border-color: var(--coral); color: #ffb08a; background: rgba(232, 114, 42, 0.18); }
.proverb { font-style: italic; color: var(--gold); font-size: clamp(12px, 2vmin, 17px); text-shadow: 0 2px 8px #000; }

.cta {
    margin-top: 6px;
    padding: 14px 44px;
    font-size: clamp(15px, 2.5vmin, 20px);
    font-family: inherit;
    letter-spacing: 0.2em;
    color: var(--ink);
    background: linear-gradient(180deg, #ffd98a, var(--gold));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 6px 24px rgba(233, 178, 74, 0.4);
    min-height: 52px;
}
.cta:active { transform: scale(0.96); }
.ghost {
    padding: 11px 30px;
    font-size: clamp(12px, 2vmin, 16px);
    letter-spacing: 0.16em;
    background: transparent;
    color: var(--cream);
    border: 2px solid rgba(244, 230, 200, 0.45);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    min-height: 48px;
}
.ghost.danger { border-color: rgba(200, 60, 40, 0.6); color: #ff8a70; }
.ghost:active { transform: scale(0.96); }

/* ---------------- narrative intro ---------------- */
.intro-screen {
    position: absolute; inset: 0;
    z-index: 40;
    background: #000;
    overflow: hidden;
    cursor: pointer;
}
.intro-black { position: absolute; inset: 0; display: grid; place-items: center; }
.whisper {
    color: rgba(244, 230, 200, 0.85);
    font-style: italic;
    font-size: clamp(13px, 2.4vmin, 19px);
    animation: breathe 3.2s ease-in-out infinite;
    padding: 0 8vw;
    text-align: center;
}
@keyframes breathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.9; } }
.ember-dot {
    position: absolute; left: 50%; bottom: 22%;
    width: 10px; height: 10px; border-radius: 50%;
    background: radial-gradient(circle, #ffd080, #ff6a1a 70%);
    box-shadow: 0 0 18px 6px rgba(255, 120, 30, 0.5);
    animation: emberFloat 4s ease-in-out infinite;
}
.ember-dot.d2 { margin-left: -40px; animation-delay: 1.3s; }
.ember-dot.d3 { margin-left: 52px; animation-delay: 2.4s; }
@keyframes emberFloat {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateY(-160px) scale(0.3); opacity: 0; }
}

.intro-frame { position: absolute; inset: 0; display: flex; flex-direction: column; }
.frame-art {
    position: absolute; inset: 0;
    background-size: cover;
    background-position: center;
    animation: kenburns 7s ease-out forwards;
}
.frame-art.village {
    background:
        radial-gradient(ellipse 130% 60% at 50% 108%, #3a1e10 30%, transparent 71%),
        linear-gradient(180deg, #241033 0%, #8a3a2a 55%, #e8963a 68%, #2a1208 70%, #160a06 100%);
}
.frame-art.village::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(circle at 62% 52%, rgba(255, 223, 138, 0.95) 0 5%, transparent 12%),
        conic-gradient(from 210deg at 24% 74%, #0a0508 0 25%, transparent 25%),
        conic-gradient(from 220deg at 80% 76%, #0a0508 0 25%, transparent 25%);
}
.frame-art.raid {
    background:
        radial-gradient(ellipse 60% 45% at 18% 55%, rgba(255, 190, 80, 0.85), transparent 70%),
        linear-gradient(180deg, #12060a 0%, #5a140a 52%, #1c0a06 100%);
    animation: raidFlicker 0.9s ease-in-out infinite alternate, kenburns 7s ease-out forwards;
}
@keyframes raidFlicker { from { filter: brightness(0.85); } to { filter: brightness(1.15); } }
.frame-art.raid::before {
    content: '';
    position: absolute; inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent 0 12vw, rgba(161, 29, 29, 0.5) 12vw calc(12vw + 26px), transparent calc(12vw + 26px) 18vw),
        linear-gradient(180deg, transparent 62%, rgba(6, 3, 5, 0.92) 66%);
}
.frame-art.hero {
    background:
        radial-gradient(circle at 50% 56%, rgba(255, 223, 154, 0.9) 0 12%, transparent 34%),
        linear-gradient(180deg, #1a0933 0%, #7a2a3a 45%, #e8963a 62%, #1c0c10 66%, #0a0508 100%);
}
.frame-art.hero::before {
    content: '';
    position: absolute; left: 50%; top: 10%; bottom: auto;
    transform: translateX(-50%);
    width: 14vmin; height: 34vmin;
    background:
        linear-gradient(180deg, transparent 0 8%, #0c0509 8% 100%),
        none;
    clip-path: polygon(46% 0%, 54% 0%, 58% 26%, 72% 60%, 62% 100%, 38% 100%, 28% 60%, 42% 26%);
    filter: drop-shadow(0 0 24px rgba(255, 180, 80, 0.5));
}
@keyframes kenburns { from { transform: scale(1.12); } to { transform: scale(1); } }

.frame-caption {
    position: absolute; left: 50%; bottom: 9%;
    transform: translateX(-50%);
    width: min(720px, 86vw);
    text-align: center;
    font-style: italic;
    font-size: clamp(13px, 2.5vmin, 20px);
    line-height: 1.5;
    color: var(--cream);
}
.intro-frame.hero .frame-caption {
    bottom: 5%;
    text-shadow: 0 2px 10px #000, 0 0 24px #000;
    animation: capIn 1.2s ease-out;
    pointer-events: none;
}
@keyframes capIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

.intro-frame.hero .cta.begin { position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%); z-index: 3; }

.intro-quote { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 18px; }
.yo-quote {
    font-size: clamp(26px, 6vmin, 54px);
    font-style: italic;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(233, 178, 74, 0.55), 0 4px 12px #000;
    animation: capIn 1.4s ease-out;
    letter-spacing: 0.04em;
}
.en-quote {
    font-size: clamp(15px, 3vmin, 26px);
    font-weight: normal;
    color: var(--cream);
    opacity: 0.9;
    text-shadow: 0 2px 10px #000;
    animation: capIn 1.4s ease-out 0.5s backwards;
}

.intro-narration { position: absolute; inset: 0; display: grid; place-items: center; background: #000; }
.scroll-window {
    width: min(640px, 84vw);
    height: 62vh;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
    mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}
.scroll-text {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    padding: 0 12px;
    font-size: clamp(14px, 2.6vmin, 21px);
    font-style: italic;
    line-height: 1.9;
    text-align: center;
    color: var(--cream);
    text-shadow: 0 0 14px rgba(233, 178, 74, 0.25), 0 2px 8px #000;
    animation: scrollUp 18s linear forwards;
}
@keyframes scrollUp { to { top: -110%; } }

.intro-next {
    position: absolute; right: 4vw; bottom: 4vh;
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(244, 230, 200, 0.5);
    background: rgba(10, 5, 8, 0.6);
    color: var(--cream);
    font-size: 22px;
    cursor: pointer;
    z-index: 4;
    animation: breathe 2.4s ease-in-out infinite;
}
.intro-prev {
    position: absolute; left: 4vw; bottom: 4vh;
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(244, 230, 200, 0.5);
    background: rgba(10, 5, 8, 0.6);
    color: var(--cream);
    font-size: 22px;
    cursor: pointer;
    z-index: 4;
    animation: breathe 2.4s ease-in-out infinite;
}
.intro-progress {
    position: absolute; left: 50%; top: 14px;
    transform: translateX(-50%);
    display: flex; gap: 8px;
    z-index: 4;
}
.intro-progress .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(244, 230, 200, 0.25);
    border: 1px solid rgba(244, 230, 200, 0.4);
}
.intro-progress .dot.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* ---------------- FINAL CROWN SEQUENCE ---------------- */
.crown-seq-screen {
    position: absolute; inset: 0;
    z-index: 35;
    pointer-events: none;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    padding-bottom: 7vh;
    background: radial-gradient(ellipse at 50% 38%, rgba(75, 0, 130, 0.28) 0%, rgba(4, 2, 4, 0.62) 72%);
}
.crown-seq-caption { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.crown-seq-line {
    font-size: clamp(14px, 2.6vmin, 22px);
    font-style: italic;
    color: var(--cream);
    text-shadow: 0 2px 10px #000, 0 0 22px rgba(212, 175, 55, 0.4);
    opacity: 0;
    animation: crownLineIn 2.6s ease-out forwards;
}
.crown-seq-line.l1 { animation-delay: 0.4s; }
.crown-seq-line.l2 { animation-delay: 3.2s; }
.crown-seq-line.l3 { animation-delay: 6.2s; color: #ffd98a; }
.crown-seq-line.l4 { animation-delay: 8.6s; color: #b48cff; }
.crown-seq-line.l5 { animation-delay: 10.6s; color: var(--coral); font-weight: bold; font-style: normal; letter-spacing: 0.08em; }
@keyframes crownLineIn {
    0% { opacity: 0; transform: translateY(14px); }
    18% { opacity: 1; transform: translateY(0); }
    82% { opacity: 1; }
    100% { opacity: 0.92; }
}
.crown-seq-emblem {
    position: absolute; left: 50%; top: 16%;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 26px rgba(212, 175, 55, 0.75));
    opacity: 0;
    animation: crownEmblemIn 1.6s ease-out 10.4s forwards;
}
@keyframes crownEmblemIn { from { opacity: 0; transform: translate(-50%, 18px) scale(0.6); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ---------------- FINAL CELEBRATION ---------------- */
.celebration-screen {
    position: absolute; inset: 0;
    z-index: 36;
    display: grid; place-items: center;
    background:
        radial-gradient(ellipse 120% 70% at 50% 100%, rgba(232, 162, 64, 0.22), transparent 60%),
        linear-gradient(180deg, rgba(26, 8, 40, 0.88) 0%, rgba(10, 5, 8, 0.94) 100%);
    overflow-y: auto;
    pointer-events: auto;
}
.celebration-inner {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    text-align: center;
    padding: clamp(16px, 4vmin, 40px);
    max-width: min(860px, 94vw);
    animation: capIn 1.2s ease-out;
}
.celebration-crown {
    filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.8)) drop-shadow(0 0 60px rgba(232, 114, 42, 0.4));
    animation: crownRise 1.6s ease-out;
}
@keyframes crownRise { from { transform: translateY(24px) scale(0.7); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.celebration-title { color: var(--coral); text-shadow: 0 0 28px rgba(232, 114, 42, 0.7), 0 3px 8px #000; }
.celebration-text { color: var(--cream); font-size: clamp(14px, 2.4vmin, 20px); }
.celebration-epilogue { font-style: italic; color: rgba(244, 230, 200, 0.85); font-size: clamp(11px, 1.9vmin, 15px); line-height: 1.6; max-width: 62ch; }
.tribes-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 720px; }
.tribe {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: clamp(10px, 1.6vmin, 13px);
    letter-spacing: 0.04em;
    padding: 6px 12px;
    border: 1.5px solid; border-radius: 18px;
    background: rgba(10, 5, 8, 0.55);
    color: var(--cream);
}
.tribe i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; box-shadow: 0 0 8px rgba(255, 255, 255, 0.25); }
.celebration-cta { margin-top: 8px; }

/* landscape-first: keep HUD clear of notch areas */
@supports (padding: env(safe-area-inset-left)) {
    .counters { left: calc(14px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom)); }
    .actions { right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-aspect-ratio: 1/1) {
    .bars { top: 52px; }
    .clue-card { top: 84px; }
}

/* ---------------- back button + hover tooltips ---------------- */
.sys-btn.back-btn { border-color: rgba(233, 178, 74, 0.65); color: var(--gold); }
.sys-btn.back-btn:active { transform: scale(0.9); }

/* CSS-only tooltip driven by a data-tip attribute. */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(4px);
    max-width: 220px;
    width: max-content;
    padding: 7px 11px;
    background: linear-gradient(180deg, rgba(26, 12, 20, 0.97), rgba(10, 5, 8, 0.97));
    border: 1.5px solid rgba(233, 178, 74, 0.6);
    border-radius: 8px;
    color: var(--cream);
    font-family: inherit;
    font-size: 12px;
    font-style: italic;
    line-height: 1.35;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: normal;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 60;
}
[data-tip]::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 4px);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(233, 178, 74, 0.6);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 60;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
[data-tip]:hover::before,
[data-tip]:focus-visible::before {
    opacity: 1;
    visibility: visible;
}
/* Keep tooltips inside the viewport on the right-hand action column. */
.actions [data-tip]::after,
.sys-btns [data-tip]::after { left: auto; right: 0; transform: translateX(0) translateY(4px); }
.actions [data-tip]:hover::after,
.sys-btns [data-tip]:hover::after { transform: translateX(0) translateY(0); }
.actions [data-tip]::before,
.sys-btns [data-tip]::before { left: auto; right: 18px; }
/* Left-hand counters: anchor tooltip to the left edge. */
.counters [data-tip]::after { left: 0; transform: translateX(0) translateY(4px); }
.counters [data-tip]:hover::after { transform: translateX(0) translateY(0); }
.counters [data-tip]::before { left: 18px; }
/* Touch devices: 2-second press-and-hold reveals the same tooltip
   (React toggles .tip-open after 2s of pointer-down). */
[data-tip].tip-open::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
[data-tip].tip-open::before { opacity: 1; visibility: visible; }
.actions [data-tip].tip-open::after,
.sys-btns [data-tip].tip-open::after { transform: translateX(0) translateY(0); }
.counters [data-tip].tip-open::after { transform: translateX(0) translateY(0); }
.tactic { touch-action: manipulation; -webkit-touch-callout: none; user-select: none; }

/* ---------------- START GAME button (intro screen) ---------------- */
.start-game-btn {
    position: absolute;
    left: 50%;
    top: 70%;
    transform: translate(-50%, -50%);
    z-index: 100;
    animation: startPulse 2s ease-in-out infinite alternate;
    min-width: 220px;
    text-align: center;
}
@keyframes startPulse {
    from { box-shadow: 0 6px 24px rgba(233, 178, 74, 0.4); }
    to   { box-shadow: 0 6px 38px rgba(233, 178, 74, 0.8), 0 0 18px rgba(255, 210, 120, 0.5); }
}

/* ---------------- Universal Back Button (bottom-left, all post-intro screens) ---------------- */
.universal-back-btn {
    position: absolute;
    left: 14px;
    bottom: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(233, 178, 74, 0.65);
    background: rgba(10, 5, 8, 0.75);
    color: var(--gold);
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 55;
    backdrop-filter: blur(2px);
    transition: transform 0.12s;
    pointer-events: auto;
}
.universal-back-btn:active { transform: scale(0.9); }
/* When HUD counters are visible (in-game), shift back button above them */
#hud ~ .universal-back-btn {
    bottom: calc(16px + clamp(56px, 11vmin, 76px) * 2 + 24px);
}