/* ============================================
   LAYOUT
   Stage layouts, positioning, responsive design
   ============================================ */

/* --- Main Stage --- */
.stage {
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
    min-height: 0;
    transition: opacity 0.5s ease;
    opacity: 0;
    pointer-events: none;
}

.stage.show {
    opacity: 1;
    pointer-events: auto;
}

#stage-game {
    padding: 0 16px;
    display: none;
}

#stage-game.show {
    display: flex;
}

.number-display-container {
    text-align: center;
    margin-bottom: 0;
    flex-shrink: 0;
}

.stage-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--text-tertiary);
    font-weight: 700;
}

#number-display,
#number-display-legacy {
    font-family: 'Inter', sans-serif;
    font-size: clamp(8rem, 23vw, 13rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    background: var(--num-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 40px 80px rgba(0, 0, 0, 0.15));
    transform-origin: center bottom;
    will-change: transform, filter;
    padding: 0 0.1em;
    overflow: visible;
}

#number-display-legacy {
    font-size: calc(clamp(8rem, 23vw, 13rem) + 5px);
}

/* --- Animal Block --- */
.animal-block {
    display: inline-block;
    position: relative;
    width: clamp(120px, 30vw, 200px);
    height: auto;
    margin: 0 auto;
    -webkit-text-fill-color: initial;
}

.z,
.zz {
    position: absolute;
    color: var(--text-tertiary);
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    opacity: 0;
    -webkit-text-fill-color: var(--text-tertiary);
}

/* --- History Ticker --- */
.history-ticker {
    margin: 0 auto 20px auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0px 20px;
    border-radius: 100px;
    transition: opacity 0.4s, transform 0.4s var(--ease-smooth), padding 0.3s var(--ease-smooth), gap 0.3s ease;
    cursor: pointer;
    z-index: 50;
    overflow: hidden;
    flex-shrink: 0;
    min-height: 40px;
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.history-ticker.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.history-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-right: 2px;
    font-weight: 700;
    letter-spacing: 0.1em;
    white-space: nowrap;
    flex-shrink: 0;
}

#history-preview {
    display: flex;
    align-items: center;
}

.ticker-group {
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    max-width: 0;
    opacity: 0;
    transform: translateX(-10px);
    transition: max-width 0.4s var(--ease-spring), opacity 0.3s ease, transform 0.4s var(--ease-spring);
}

.ticker-group.visible {
    max-width: 60px;
    opacity: 1;
    transform: translateX(0);
}

.ticker-group.instant-show {
    max-width: 60px;
    opacity: 1;
    transform: translateX(0);
    transition: none;
}

.ticker-group:nth-child(n+4) {
    display: none !important;
}

.ticker-num {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.ticker-divider {
    display: inline-block;
    opacity: 0.3;
    color: var(--text-tertiary);
    font-size: 12px;
    margin: 0 6px 0 8px;
    max-width: 10px;
    transition: all 0.3s ease;
}

.ticker-group:last-child .ticker-divider,
.ticker-group:nth-child(3) .ticker-divider {
    opacity: 0;
    max-width: 0;
    margin: 0;
}

.ticker-group:first-child .ticker-num {
    color: var(--text-primary);
    font-weight: 700;
}

/* --- Lobby Layout --- */
#stage-lobby {
    position: fixed;
    inset: 0;
    z-index: 200;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease, backdrop-filter 0.4s ease;
}

#stage-lobby.open {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

#stage-lobby.exiting {
    opacity: 0;
    backdrop-filter: blur(0px);
}

#stage-lobby .stage-label {
    margin-bottom: 24px;
}

/* --- Mode Switch Button --- */
.mode-switch-btn {
    position: fixed;
    top: 25px;
    right: 24px;
    padding: 10px 16px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 50;
    transition: transform 0.2s, background 0.2s;
    font-size: 14px;
    font-weight: 600;
}

.mode-switch-btn:hover {
    background: var(--btn-bg);
    transform: scale(1.02);
}

.mode-switch-btn span {
    display: none;
}

/* --- Player List --- */
.player-list {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: -30px;
    margin-bottom: 10px;
}

/* --- Responsive Design --- */
@media (min-width: 600px) {
    .mode-switch-btn {
        padding: 10px 20px;
    }

    .mode-switch-btn span {
        display: inline;
    }
}

@media (max-width: 600px) {
    .number-display-container {
        margin-bottom: 5px;
    }

    .mode-switch-btn {
        padding: 12px 16px;
    }
}
