/* --- Order It --- */
#order-it-player-lives-area {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; padding: 10px;
    background-color: var(--bg-secondary); border-radius: 6px; flex-grow: 1;
}
.order-it-player-life-entry { display: flex; align-items: center; gap: 8px; }
.order-it-player-life-entry.eliminated { opacity: 0.6; }
.order-it-player-life-entry.current-turn .order-it-player-life-name { color: var(--highlight-secondary); font-weight: bold; }
.order-it-player-life-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.order-it-player-life-name { font-size: 0.9em; font-weight: 500; }
.order-it-player-life-hearts { font-size: 1em; color: var(--error-color); letter-spacing: 1px; }

#order-it-scale-container, #order-it-unplaced-container {
    width: 100%; padding: 10px; background-color: var(--bg-secondary); border-radius: 6px;
    min-height: 200px; display: flex; flex-direction: column; /* Increased min-height for stability */
}
#order-it-scale-container { position: relative; }
.order-it-direction-indicator {
    position: absolute; width: 30px; top: 5px; bottom: 5px; z-index: 200;
    box-sizing: border-box; border-radius: 4px; background-color: var(--bg-tertiary);
    color: var(--highlight-secondary); display: flex; justify-content: center; align-items: center;
    font-size: 1.5em; font-weight: bold; user-select: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.order-it-direction-indicator.clickable {
    cursor: pointer;
    background-color: rgba(var(--bg-tertiary-rgb), 0.8);
    border-color: var(--highlight-secondary);
    color: #fff;
    box-shadow: 0 0 10px rgba(var(--highlight-secondary-rgb), 0.3);
}
.order-it-direction-indicator.clickable:hover {
    background-color: var(--highlight-secondary);
    color: var(--bg-primary);
    transform: scaleX(1.1);
}
.order-it-direction-indicator.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}
#order-it-direction-indicator-left { left: 5px; }
#order-it-direction-indicator-right { right: 5px; }

#order-it-unplaced-container h5 { margin-bottom: 10px; text-align: center; color: var(--text-secondary); }
#order-it-unplaced-items-area {
    display: flex; flex-wrap: wrap; gap: var(--order-it-grid-gap); padding: 10px;
    border: 1px dashed var(--border-color); border-radius: 4px; flex-grow: 1; min-height: 0;
    min-height: calc(var(--dynamic-item-size, 100px) + 20px); justify-content: center; align-items: center;
}
#order-it-scale-area {
    display: flex; gap: var(--order-it-grid-gap); min-height: calc(var(--dynamic-item-size, 100px) + 20px);
    justify-content: center; align-items: center; position: relative; border: 1px dashed var(--border-color);
    border-radius: 4px; flex-grow: 1; min-height: 0;
}
.order-it-scale-slot {
    border: 2px dashed var(--border-color); border-radius: 4px; display: flex; justify-content: center;
    align-items: center; font-size: 2em; font-weight: bold; color: var(--text-secondary); flex-shrink: 0; user-select: none;
}
.order-it-scale-slot.fading-out { animation: fadeOut 0.5s ease forwards; }

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.order-it-scale-slot.drop-hover { background-color: color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 15%, var(--bg-secondary)); }

.order-it-item {
    min-width: 40px; min-height: 40px; background-color: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 4px; display: flex; flex-direction: column; justify-content: flex-end; cursor: grab;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); user-select: none; position: relative; overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, border-color 0.2s ease, width 0.2s ease, height 0.2s ease;
    flex-shrink: 0;
}
.order-it-item.dragging { opacity: 0.5 !important; cursor: grabbing !important; transform: scale(1.05); }
.order-it-item.pending-confirmation { border-color: var(--warning-color); border-style: dashed; }
.order-it-item.preview-placement { border-color: var(--highlight-secondary); border-style: dotted !important; opacity: 0.6; }
.order-it-item.order-it-item-awaiting-reveal { border-color: var(--highlight-primary); }

.order-it-item-img-placeholder {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover;
    background-position: center; z-index: 1; background-color: var(--bg-primary);
}
.order-it-item-info {
    position: relative; z-index: 2; background: rgba(var(--bg-tertiary-rgb), 0.90);
    padding: 5px; width: 100%; text-align: center; display: flex; flex-direction: column;
    justify-content: center; align-items: center; gap: 2px; min-height: auto;
}
.order-it-item-name {
    font-size: 0.7em; line-height: 1.2; font-weight: bold; color: #fff;
    display: block; width: 100%; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; position: relative; padding-right: 0;
}
.order-it-item-name.overflows { padding-right: 18px; }
.order-it-item-name.overflows::after {
    content: '🔍'; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    font-size: 0.7em; opacity: 0.7; filter: grayscale(1); pointer-events: none;
}
.order-it-item-value { font-size: 0.6em; line-height: 1.1; color: var(--highlight-secondary); }

/* Missing classes restored */
.order-it-item-shaking {
    animation: orderItShake 0.82s cubic-bezier(.36, .07, .19, .97) both infinite;
    transform: translate3d(0, 0, 0);
}
.order-it-item-glowing {
    border-color: var(--highlight-primary) !important;
    animation: orderItGlow 1.5s ease-in-out infinite alternate;
}
.order-it-item-flash-correct {
    --feedback-flash-bg-color: rgba(46, 204, 113, 0.4);
    --feedback-flash-border-color: var(--success-color);
    animation: orderItFlashFeedback 3s ease-out forwards;
}
.order-it-item-flash-incorrect {
    --feedback-flash-bg-color: rgba(231, 76, 60, 0.4);
    --feedback-flash-border-color: var(--error-color);
    animation: orderItFlashFeedback 3s ease-out forwards;
}

@keyframes orderItFlashFeedback {
    0% { background-color: var(--feedback-flash-bg-color); border-color: var(--feedback-flash-border-color); box-shadow: 0 0 15px var(--feedback-flash-border-color); }
    10% { background-color: var(--feedback-flash-bg-color); border-color: var(--feedback-flash-border-color); box-shadow: 0 0 25px var(--feedback-flash-border-color); }
    100% { background-color: transparent; border-color: transparent; box-shadow: none; }
}

.order-it-container-flash-correct {
    animation: orderItContainerFlashCorrect 3s ease-out forwards;
}
.order-it-container-flash-incorrect {
    animation: orderItContainerFlashIncorrect 3s ease-out forwards;
}

@keyframes orderItContainerFlashCorrect {
    0% { box-shadow: inset 0 0 0px rgba(46, 204, 113, 0); }
    10% { box-shadow: inset 0 0 60px rgba(46, 204, 113, 0.8); }
    100% { box-shadow: inset 0 0 0px rgba(46, 204, 113, 0); }
}
@keyframes orderItContainerFlashIncorrect {
    0% { box-shadow: inset 0 0 0px rgba(231, 76, 60, 0); }
    10% { box-shadow: inset 0 0 60px rgba(231, 76, 60, 0.8); }
    100% { box-shadow: inset 0 0 0px rgba(231, 76, 60, 0); }
}

#order-it-turn-timer {
    display: inline-block; font-size: 1.4em; color: white; margin-left: 12px;
    vertical-align: middle; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-variant-numeric: tabular-nums; min-width: 2ch;
}
#order-it-turn-timer.critical { color: var(--error-color); animation: orderItTimerPulse 1s infinite; }
#order-it-controls-area { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 15px; margin-top: auto; padding-top: 15px; }
.order-it-host-controls-wrapper { display: flex; gap: 15px; justify-content: center; align-items: center; flex-wrap: wrap; }
.order-it-header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 15px;
}

@media (hover: hover) {
    .order-it-item-info.can-expand:hover .order-it-item-name {
        white-space: normal; word-wrap: break-word; overflow: visible; padding-right: 0 !important;
    }
    .order-it-item-info.can-expand:hover .order-it-item-name::after { display: none; }
}
.order-it-item-info.can-expand.expanded .order-it-item-name {
    white-space: normal; word-wrap: break-word; overflow: visible; padding-right: 0 !important;
}
.order-it-item-info.can-expand.expanded .order-it-item-name::after { display: none; }

@media (max-width: 600px) {
    #order-it-game-view .game-view-main { flex-direction: row; align-items: stretch; gap: 10px; overflow-y: hidden; }
    #order-it-scale-container { flex: 1; display: flex; flex-direction: column; align-items: stretch; overflow: hidden; position: relative; padding: 10px; }
    .order-it-direction-indicator { width: auto; left: 5px; right: 5px; }
    #order-it-direction-indicator-left { top: auto; bottom: 5px; }
    #order-it-direction-indicator-right { bottom: auto; top: 5px; }

    #order-it-unplaced-container { flex: 1; max-height: none; display: flex; flex-direction: column; overflow: hidden; }
    #order-it-scale-area { flex-direction: column-reverse; flex-grow: 1; min-height: 0; justify-content: flex-start; align-items: center; padding: 30px; }
    #order-it-unplaced-items-area { flex-direction: column; align-items: center; justify-content: center; flex-grow: 1; padding: 5px; border: 1px dashed var(--border-color); flex-wrap: nowrap; }
    .order-it-item-info { font-size: 0.75em; }
}

body.is-spectator #order-it-confirm-button {
    display: none !important;
}

body.is-spectator #order-it-scale-area,
body.is-spectator #order-it-unplaced-container {
    pointer-events: none !important;
}

body.is-spectator .order-it-direction-indicator {
    display: none !important;
}
