:root {
  /* ============================================
     경마 게임 전용 색상
  ============================================ */
  /* 경마 게임 - 갈색 */
  --horse-50:   #EFEBE9;
  --horse-500:  #8B4513;  /* 메인 */
  --horse-600:  #a0522d;
  --horse-700:  #7a3b0f;  /* 접근성 개선 (4.6:1 대비율) */

  /* Evolution 기믹 */
  --evo-glow: gold;

  /* 경마 레이스 결과 전용 색상 */
  --result-gold-light: #fff8dc;    /* 1등 배경 밝은색 */
  --result-gold-dark: #ffeaa7;     /* 1등 배경 어두운색 */
  --result-gold-text: #8b6914;     /* 1등 텍스트 */
  --result-gold-subtext: #a08030;  /* 1등 서브텍스트 */
  --result-gold-border: #f1c40f;   /* 1등 테두리 */

  --result-silver-light: #f5f5f5;  /* 2등 배경 밝은색 */
  --result-silver-dark: #e8e8e8;   /* 2등 배경 어두운색 */
  --result-silver-border: #bdc3c7; /* 2등 테두리 */

  --result-bronze-light: #fae5d3;  /* 3등 배경 밝은색 */
  --result-bronze-dark: #f0d5b8;   /* 3등 배경 어두운색 */
  --result-bronze-text: #8b5e3c;   /* 3등 텍스트 */
  --result-bronze-subtext: #a07050;/* 3등 서브텍스트 */
  --result-bronze-border: #cd7f32; /* 3등 테두리 */

  --result-loser-light: #2d1f3d;   /* 꼴등 배경 밝은색 */
  --result-loser-dark: #1a1a2e;    /* 꼴등 배경 어두운색 */
  --result-loser-dark2: #16213e;   /* 꼴등 배경 어두운색2 */
  --result-loser-border: #e94560;  /* 꼴등 테두리 */

  /* 경마 그라디언트 & 악센트 */
  --horse-gradient: linear-gradient(135deg, var(--horse-500) 0%, var(--horse-600) 100%);
  --horse-accent: var(--horse-500);
}

/* 게임 상태 바 (3게임 공통 패턴) */
.game-status {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
}
.game-status.waiting {
    background: var(--gray-100);
    color: var(--gray-700);
}
.game-status.ordering {
    background: var(--status-warning-bg);
    color: var(--status-warning-text);
}
.game-status.playing {
    background: var(--status-success-bg);
    color: var(--status-success-text);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--horse-gradient);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    overflow-x: hidden; /* 모바일 수평 스크롤 방지 */
}

.container {
    background: var(--bg-white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 20px auto;
}

body.game-active .container {
    margin-left: calc((100vw - 1140px) / 2 + 160px);
    margin-right: auto;
    max-width: 800px;
}

body.game-active header,
body.game-active footer {
    display: none;
}

h1 {
    text-align: center;
    color: var(--horse-accent);
    margin-bottom: 30px;
    font-size: 2.5em;
    font-family: 'Jua', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.game-section {
    display: none;
}

.game-section.active {
    display: block;
}

button {
    background: var(--horse-gradient);
    color: var(--text-primary);
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    margin-top: 10px;
    font-weight: 600;
}
#cameraSwitchBtn {
    width: auto;
    padding: 2px 8px;
    margin-top: 0;
    font-size: 10px;
    border-radius: 4px;
    background: rgba(0,0,0,0.65);
    color: var(--bg-white);
    border: 1px solid rgba(255,255,255,0.3);
    font-weight: normal;
    top: 6px; bottom: auto;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(139, 69, 19, 0.3);
}

button:disabled {
    background: var(--gray-300);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--horse-accent);
    outline: none;
}

.connection-status {
    text-align: center;
    padding: 5px;
    font-size: 12px;
    margin-bottom: 10px;
}

.connection-status.connected {
    color: var(--green-500);
}

.connection-status.disconnected {
    color: var(--red-500);
}

.connection-sound-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* 볼륨 컨트롤 스타일 */
.volume-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.volume-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s;
}
.volume-btn:hover {
    background: rgba(0,0,0,0.1);
}
.volume-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-300);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--dice-accent);
    border-radius: 50%;
    cursor: pointer;
}
.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--dice-accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}
.volume-slider.muted {
    opacity: 0.5;
}

/* 경주 트랙 컨테이너 - transform 기반 카메라, 터치 드래그 차단 */
.race-track-container {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 20px 0;
    overflow: hidden;
    touch-action: pan-y;
    -ms-overflow-style: none;
    border-radius: 12px;
    background: linear-gradient(to bottom, #87CEEB 0%, #98D8C8 50%, #7CB342 100%);
}
.race-track-container::-webkit-scrollbar {
    display: none;
}

/* 순위 표시 이펙트 */
.finish-effect {
    /* z-index는 인라인 스타일로 제어 */
}

/* 결승선 스타일 */
.finish-line {
    position: absolute;
    width: 6px;
    background: linear-gradient(to right, #ff0000, #cc0000);
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
    z-index: 200;
    pointer-events: none;
    animation: finishLinePulse 1.5s ease-in-out infinite;
}

@keyframes countPop {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
@keyframes obstacleJump {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}
@keyframes trapSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes finishLinePulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.3);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 20px rgba(255, 0, 0, 1), inset 0 0 15px rgba(255, 255, 255, 0.5);
    }
}

.race-track {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url('assets/backgrounds/race_track.png');
    background-repeat: repeat-x;
    background-size: auto 100%;
    background-position: 0 0;
}

/* Fallback: 이미지가 없을 경우 CSS 그라데이션 */
.race-track:not([style*="background-image"]) {
    background: linear-gradient(to bottom, 
        #87CEEB 0%, 
        #87CEEB 20%,
        #98D8C8 20%,
        #98D8C8 40%,
        #7CB342 40%,
        #7CB342 60%,
        #98D8C8 60%,
        #98D8C8 80%,
        #87CEEB 80%,
        #87CEEB 100%);
}

/* 말 컨테이너 */
.horse {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    z-index: 10;
    will-change: left, transform;
}

/* 탈것 스프라이트 애니메이션 - 2프레임 */
.vehicle-sprite {
    position: relative;
    width: 60px;
    height: 45px;
    overflow: visible;
    isolation: isolate;
}

.vehicle-sprite .vehicle-active-layer,
.vehicle-sprite .vehicle-transition-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transform-origin: center center;
    will-change: transform, opacity, filter;
}

.vehicle-sprite .vehicle-active-layer {
    z-index: 2;
}

.vehicle-sprite .vehicle-transition-layer {
    z-index: 3;
}

.vehicle-sprite .vehicle-transition-flash {
    position: absolute;
    inset: -7px;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    z-index: 4;
    mix-blend-mode: screen;
}

/* Fall 연출 먼지/스파크/스모크 트레일 (horse-race-fall-motion.js) */
.vehicle-sprite .vehicle-transition-dust {
    position: absolute;
    left: 3px;
    right: 3px;
    bottom: -2px;
    height: 22px;
    pointer-events: none;
    opacity: 0;
    z-index: 1;
    transform-origin: center bottom;
}

.vehicle-sprite .frame1,
.vehicle-sprite .frame2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 45px;
}

/* 정지 상태: 프레임 1만 보임 */
.vehicle-sprite .frame1 { opacity: 1; }
.vehicle-sprite .frame2 { opacity: 0; }

/* 달리는 상태: 2프레임 교차 */
@keyframes frame1Anim {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}
@keyframes frame2Anim {
    0%, 49% { opacity: 0; }
    50%, 100% { opacity: 1; }
}

/* 대기 상태: 느린 2프레임 교차 (발구르기) */
.horse.idle .vehicle-sprite .frame1 { animation: frame1Anim 0.6s steps(1) infinite; }
.horse.idle .vehicle-sprite .frame2 { animation: frame2Anim 0.6s steps(1) infinite; }

/* 달리는 상태: 빠른 2프레임 교차 */
.horse.racing .vehicle-sprite .frame1 { animation: frame1Anim 0.15s steps(1) infinite; }
.horse.racing .vehicle-sprite .frame2 { animation: frame2Anim 0.15s steps(1) infinite; }

/* 쉬는 상태: 매우 느린 호흡 애니메이션 */
.horse.rest .vehicle-sprite .frame1 { animation: frame1Anim 1.5s steps(1) infinite; }
.horse.rest .vehicle-sprite .frame2 { animation: frame2Anim 1.5s steps(1) infinite; }
.horse.rest { opacity: 0.7; filter: grayscale(30%); }

/* ===== 기믹 이펙트 스타일 ===== */

/* 스프린트 불꽃 이펙트 */
.vehicle-sprite.vehicle-transform-to-power .vehicle-active-layer {
    animation: vehiclePowerIn 0.36s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.vehicle-sprite.vehicle-transform-to-power .vehicle-transition-outgoing {
    animation: vehiclePowerOut 0.36s cubic-bezier(0.2, 0.2, 0.4, 1) both;
}

.vehicle-sprite.vehicle-transform-to-power .vehicle-transition-flash {
    background: radial-gradient(circle, rgba(255, 246, 184, 0.98) 0%, rgba(120, 245, 255, 0.58) 44%, rgba(255, 255, 255, 0) 82%);
    animation: vehiclePowerFlash 0.36s ease-out both;
}

.vehicle-sprite.vehicle-transform-to-base .vehicle-active-layer {
    animation: vehicleBaseIn 0.3s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.vehicle-sprite.vehicle-transform-to-base .vehicle-transition-outgoing {
    animation: vehicleBaseOut 0.3s cubic-bezier(0.3, 0.2, 0.4, 1) both;
}

.vehicle-sprite.vehicle-transform-to-base .vehicle-transition-flash {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.88) 0%, rgba(164, 210, 255, 0.35) 46%, rgba(255, 255, 255, 0) 80%);
    animation: vehicleBaseFlash 0.3s ease-out both;
}

@keyframes vehiclePowerIn {
    0% {
        opacity: 0.18;
        transform: translateX(-4px) scale(0.72) rotate(-6deg);
        filter: saturate(1.9) brightness(1.8) blur(1px);
    }
    55% {
        opacity: 1;
        transform: translateX(1px) scale(1.08) rotate(2deg);
        filter: saturate(1.2) brightness(1.22);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0);
        filter: none;
    }
}

@keyframes vehiclePowerOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0);
        filter: none;
    }
    100% {
        opacity: 0;
        transform: translateX(5px) scale(1.18) rotate(6deg);
        filter: brightness(2.2) blur(2px);
    }
}

@keyframes vehiclePowerFlash {
    0% {
        opacity: 0;
        transform: scale(0.4);
    }
    32% {
        opacity: 0.95;
        transform: scale(1.06);
    }
    100% {
        opacity: 0;
        transform: scale(1.62);
    }
}

@keyframes vehicleBaseIn {
    0% {
        opacity: 0.2;
        transform: translateX(3px) scale(1.15) rotate(3deg);
        filter: brightness(1.35) blur(1px);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0);
        filter: none;
    }
}

@keyframes vehicleBaseOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0);
        filter: none;
    }
    100% {
        opacity: 0;
        transform: translateX(-3px) scale(0.82) rotate(-4deg);
        filter: saturate(0.75) brightness(1.5) blur(1px);
    }
}

@keyframes vehicleBaseFlash {
    0% {
        opacity: 0;
        transform: scale(0.65);
    }
    38% {
        opacity: 0.7;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.34);
    }
}

.gimmick-effect-sprint {
    position: absolute;
    left: -35px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 30px;
    pointer-events: none;
    z-index: 1;
}

.flame {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 25px solid #ff6600;
    filter: blur(1px);
    animation: flameFlicker 0.1s ease-in-out infinite alternate;
}

.flame:nth-child(1) { left: 0; animation-delay: 0s; border-bottom-color: #ff4400; }
.flame:nth-child(2) { left: 10px; animation-delay: 0.05s; border-bottom-color: #ff6600; }
.flame:nth-child(3) { left: 20px; animation-delay: 0.1s; border-bottom-color: #ffaa00; }

.flame-core {
    position: absolute;
    left: 5px;
    top: 5px;
    width: 30px;
    height: 20px;
    background: radial-gradient(ellipse at right, #fff 0%, #ffff00 20%, #ff6600 50%, transparent 70%);
    filter: blur(2px);
    animation: flamePulse 0.15s ease-in-out infinite alternate;
}

@keyframes flameFlicker {
    0% { transform: scaleY(0.8) rotate(-5deg); opacity: 0.8; }
    100% { transform: scaleY(1.2) rotate(5deg); opacity: 1; }
}

@keyframes flamePulse {
    0% { transform: scaleX(0.8); opacity: 0.9; }
    100% { transform: scaleX(1.2); opacity: 1; }
}

/* 속도선 이펙트 */
.speed-lines {
    position: absolute;
    left: -50px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 40px;
    pointer-events: none;
    z-index: 0;
}

.speed-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,100,50,0.8) 50%, rgba(255,200,100,0.5) 100%);
    animation: speedLineMove 0.2s linear infinite;
}

.speed-line:nth-child(1) { top: 5px; width: 30px; animation-delay: 0s; }
.speed-line:nth-child(2) { top: 12px; width: 40px; animation-delay: 0.05s; }
.speed-line:nth-child(3) { top: 19px; width: 35px; animation-delay: 0.1s; }
.speed-line:nth-child(4) { top: 26px; width: 45px; animation-delay: 0.15s; }
.speed-line:nth-child(5) { top: 33px; width: 25px; animation-delay: 0.08s; }

@keyframes speedLineMove {
    0% { opacity: 0; transform: translateX(10px); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-20px); }
}

/* 멈춤 브레이크 연기 이펙트 */
.gimmick-effect-stop {
    position: absolute;
    left: -20px;
    bottom: -5px;
    width: 50px;
    height: 30px;
    pointer-events: none;
    z-index: 1;
}

.brake-smoke {
    position: absolute;
    width: 15px;
    height: 15px;
    background: radial-gradient(circle, rgba(100,100,100,0.6) 0%, transparent 70%);
    border-radius: 50%;
    animation: smokeRise 0.5s ease-out infinite;
}

.brake-smoke:nth-child(1) { left: 0; animation-delay: 0s; }
.brake-smoke:nth-child(2) { left: 15px; animation-delay: 0.1s; }
.brake-smoke:nth-child(3) { left: 30px; animation-delay: 0.2s; }

@keyframes smokeRise {
    0% { transform: translateY(0) scale(0.5); opacity: 0.8; }
    100% { transform: translateY(-20px) scale(1.5); opacity: 0; }
}

/* 느림 피로 이펙트 (땀방울) */
.gimmick-effect-slow {
    position: absolute;
    right: -5px;
    top: -10px;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 2;
}

.sweat-drop {
    position: absolute;
    width: 6px;
    height: 10px;
    background: linear-gradient(to bottom, rgba(100,200,255,0.8) 0%, rgba(50,150,255,0.6) 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: sweatFall 0.6s ease-in infinite;
}

.sweat-drop:nth-child(1) { left: 0; animation-delay: 0s; }
.sweat-drop:nth-child(2) { left: 10px; animation-delay: 0.3s; }

@keyframes sweatFall {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(15px); opacity: 0; }
}

/* 미끄러짐 먼지 이펙트 */
.gimmick-effect-slip {
    position: absolute;
    right: -25px;
    bottom: 0;
    width: 40px;
    height: 25px;
    pointer-events: none;
    z-index: 1;
}

.dust-cloud {
    position: absolute;
    width: 20px;
    height: 15px;
    background: radial-gradient(ellipse, rgba(180,140,100,0.7) 0%, transparent 70%);
    border-radius: 50%;
    animation: dustBurst 0.3s ease-out infinite;
}

.dust-cloud:nth-child(1) { left: 0; bottom: 0; animation-delay: 0s; }
.dust-cloud:nth-child(2) { left: 15px; bottom: 5px; animation-delay: 0.1s; }

@keyframes dustBurst {
    0% { transform: scale(0.5) translateX(0); opacity: 0.8; }
    100% { transform: scale(1.5) translateX(15px); opacity: 0; }
}

/* 지그재그 어지러움 이펙트 */
.gimmick-effect-wobble {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    pointer-events: none;
    z-index: 2;
    animation: wobbleStars 0.3s ease-in-out infinite;
}

@keyframes wobbleStars {
    0%, 100% { transform: translateX(-50%) rotate(-10deg); }
    50% { transform: translateX(-50%) rotate(10deg); }
}

/* ===== Evolution 기믹 ===== */
.evolution-charge {
    animation: evo-pulse 0.4s infinite alternate !important;
    will-change: transform, filter;
}
.evolution-burst {
    animation: evo-burst 0.5s ease-out !important;
    will-change: transform, filter;
}
.evolution-run {
    /* power SVG 자체에 glow filter 내장 — CSS filter 없이 마커 클래스만 */
    will-change: filter;
}

@keyframes evo-pulse {
    from { filter: brightness(1); }
    to { filter: brightness(1.4) drop-shadow(0 0 4px gold); }
}
@keyframes evo-burst {
    0% { filter: brightness(3) blur(2px); transform: scale(1.3); }
    100% { filter: brightness(1) blur(0); transform: scale(1); }
}

/* 결과 오버레이 visible 상태 */
.result-overlay.visible {
    display: flex !important;
}

/* 말 선택 UI */
.horse-selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.horse-selection-button {
    background: var(--bg-white);
    border: 3px solid var(--horse-500);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 48px;
}

.horse-selection-button:hover:not(:disabled) {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(139, 69, 19, 0.3);
    border-color: var(--horse-600);
}

.horse-selection-button.selected {
    background: var(--horse-50);
    border-color: var(--horse-accent);
    border-width: 4px;
}

.horse-selection-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(80%);
    background: var(--gray-100);
    border-color: var(--text-muted);
}

.horse-selection-button.taken {
    position: relative;
}

.horse-selection-button.taken::after {
    content: '선택됨';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.9);
    padding: 2px 8px;
    border-radius: 10px;
}

/* 준비 섹션 */
.ready-section {
    display: none; /* 초기에 숨김, JS에서 조건부 표시 */
    background: var(--horse-50);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid var(--horse-500);
    font-family: 'Jua', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 준비 버튼 hover 효과 */
#readyButton:hover {
    background: linear-gradient(135deg, var(--horse-600) 0%, var(--horse-500) 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(139, 69, 19, 0.3);
}

.users-list {
    background: var(--horse-50);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 50px;
}

/* 준비 섹션 내부 리스트도 갈색톤 */
.ready-section .users-list {
    background: var(--horse-50);
}

.user-tag {
    background: var(--bg-white);
    border: 2px solid var(--horse-500);
    color: var(--horse-accent);
    padding: 6px 12px;
    font-family: 'Jua', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-tag.host {
    background: var(--bg-white);
    color: var(--horse-accent);
}

.user-tag.me {
    background: var(--horse-500);
    color: white;
}

/* 주문받기 섹션 스타일 */
.orders-section {
    margin-bottom: 20px;
    display: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.orders-section.active {
    display: block;
}

.my-order-box {
    background: var(--yellow-50);
    border: 2px solid var(--yellow-500);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.my-order-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--yellow-900);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.order-input-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    position: relative;
}

.order-input-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-suggestion {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px;
    color: var(--text-muted);
    pointer-events: none;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    border: 2px solid transparent;
    border-radius: 8px;
    z-index: 1;
}

#myOrderInput {
    position: relative;
    z-index: 2;
    background-color: transparent;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 2px solid var(--horse-500);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background-color 0.2s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: var(--yellow-50);
}

.menu-manager {
    display: none;
    background: var(--bg-primary);
    border: 2px solid var(--horse-500);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.menu-manager.active {
    display: block;
}

.menu-manager-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--horse-accent);
}

.menu-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-white);
    border: 1px solid var(--gray-300);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.menu-item .delete-btn {
    background: none;
    border: none;
    color: var(--red-500);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    margin-left: 5px;
}

.order-list-container {
    max-height: 300px;
    overflow-y: auto;
}

.order-item {
    background: var(--bg-white);
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 3px solid var(--horse-600);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-item:last-child {
    margin-bottom: 0;
}

.order-item-left {
    flex: 1;
}

.order-user {
    font-weight: 600;
    color: var(--horse-accent);
    margin-bottom: 4px;
}

.order-text {
    color: var(--text-secondary);
    font-size: 20px;
    font-weight: 600;
    word-break: break-word;
}

.order-text.empty {
    color: var(--text-muted);
    font-style: italic;
}

.order-count {
    font-size: 48px;
    font-weight: bold;
    color: var(--horse-accent);
    margin-left: 15px;
}

.sort-buttons {
    display: flex;
    gap: 5px;
}

.sort-button {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--gray-100);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-button:hover {
    background: var(--gray-200);
}

.sort-button.active {
    background: var(--horse-500);
    color: white;
}

.not-ordered-section {
    margin-bottom: 15px;
    padding: 12px;
    background: var(--yellow-50);
    border-radius: 8px;
    border-left: 4px solid var(--red-400);
}

.not-ordered-title {
    font-weight: bold;
    color: var(--red-400);
    margin-bottom: 8px;
    font-size: 13px;
}

.not-ordered-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.not-ordered-item {
    background: var(--red-50);
    color: var(--red-600);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
}

/* 게임 기록 */
.history-section {
    position: fixed;
    right: 20px;
    top: 20px;
    width: 320px;
    /* 스티키 하단 광고와 겹치지 않도록 광고 예약 높이만큼 축소 */
    max-height: calc(100vh - 40px - var(--ad-sticky-reserve));
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 20px;
    overflow-y: auto;
    display: none;
    z-index: 100;
}

.history-section.visible {
    display: block;
}

.history-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--horse-accent);
    margin-bottom: 15px;
    text-align: center;
}

.history-item {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid var(--horse-500);
}

.history-round {
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.history-participants {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.history-winner {
    font-size: 16px;
    font-weight: bold;
    color: var(--horse-accent);
}

/* 채팅 섹션 */
.chat-section {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    border: 2px solid var(--horse-500);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chat-messages {
    max-height: 480px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--bg-white);
    border-radius: 8px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chat-message.system {
    margin-bottom: 10px;
    padding: 12px;
    background: var(--horse-gradient);
    color: white;
    text-align: center;
    font-weight: bold;
    border-radius: 8px;
}

.chat-message.winner {
    background: linear-gradient(135deg, var(--yellow-500) 0%, var(--yellow-600) 100%);
    color: var(--text-primary);
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    padding: 15px;
    animation: celebrate 0.5s ease-in-out infinite alternate;
    border-radius: 8px;
}

@keyframes celebrate {
    from { transform: scale(1); }
    to { transform: scale(1.02); }
}

/* 레이스 중 채팅 오버레이 */
#raceChatOverlay {
    display: none;
    position: absolute;
    left: 8px;
    bottom: 8px;
    width: 260px;
    max-height: 120px;
    z-index: 100;
    overflow: hidden;
    pointer-events: none;
}
#raceChatOverlay .race-chat-msg {
    color: rgba(255,255,255,0.95);
    padding: 1px 0;
    margin-bottom: 1px;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}
#raceChatOverlay .race-chat-msg.system {
    color: var(--yellow-500);
    font-style: italic;
}
#raceChatOverlay .race-chat-msg.me {
    color: var(--yellow-400);
}

/* 레이스 중 채팅 섹션: 제목+메시지 숨기고 입력바만 표시 */
.chat-section.race-active > div:first-child {
    display: none;
}
.chat-section.race-active .chat-messages {
    display: none;
}

/* 접속자 목록 */
.users-section {
    margin-bottom: 0;
}

.users-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--horse-500);
    font-family: 'Jua', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 방 정보 헤더 */
.room-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gray-200);
}

.room-title {
    font-size: 24px;
    color: var(--horse-accent);
    font-weight: bold;
    margin-bottom: 5px;
    font-family: 'Jua', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.host-badge {
    display: none;
    background: var(--host-badge-bg);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

/* 호스트 컨트롤 */
.host-controls {
    display: none;
    background: linear-gradient(135deg, var(--yellow-100) 0%, var(--yellow-200) 100%);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid var(--yellow-500);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.start-button {
    background: linear-gradient(135deg, var(--btn-ready) 0%, var(--green-400) 100%);
    color: white;
    font-size: 20px;
    padding: 15px 30px;
    font-weight: 600;
}

.start-button:disabled {
    background: var(--gray-300);
    color: var(--text-secondary);
}

.end-button {
    background: linear-gradient(135deg, var(--btn-danger) 0%, var(--red-400) 100%);
    color: var(--bg-white);
    font-weight: 600;
    font-size: 16px;
    padding: 15px 30px;
}

/* 결과 오버레이 */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.result-overlay.visible {
    display: flex;
}

.result-card {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    animation: popup 0.5s ease-out;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 20px;
}

@media (max-width: 768px) {
    .result-card {
        padding: 20px 15px;
        max-height: 80vh;
        font-size: 14px;
    }
    
    .result-card .result-title {
        font-size: 20px;
    }
}

@keyframes popup {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* 도착 애니메이션 */
@keyframes finishBounce {
    0% { transform: scale(0) translateY(20px); opacity: 0; }
    50% { transform: scale(1.3) translateY(-10px); opacity: 1; }
    70% { transform: scale(0.9) translateY(0); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes finishGlow {
    0%, 100% { text-shadow: 0 0 10px gold, 0 0 20px gold, 2px 2px 4px rgba(0,0,0,0.5); }
    50% { text-shadow: 0 0 20px gold, 0 0 40px gold, 0 0 60px gold, 2px 2px 4px rgba(0,0,0,0.5); }
}

@keyframes finishFade {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes sparkleRing {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* 꼴등 사망 애니메이션 */
@keyframes soulRise {
    0% { transform: translateY(0); opacity: 0.8; }
    100% { transform: translateY(-100px); opacity: 0; }
}

@keyframes arrowBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

@keyframes tombstoneDrop {
    0% { transform: translateY(-150px); opacity: 0; }
    60% { transform: translateY(10px); opacity: 1; }
    80% { transform: translateY(-5px); }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes deathFade {
    0% { opacity: 1; filter: grayscale(0); }
    100% { opacity: 0; filter: grayscale(100%); visibility: hidden; }
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(80px) rotate(720deg); }
}

.result-title {
    font-size: 24px;
    color: var(--horse-accent);
    margin-bottom: 20px;
    font-family: 'Jua', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.result-winner {
    font-size: 48px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.result-message {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* 순위 발표 1·2·3등 블록 애니메이션 */
@keyframes resultRankBounce {
    0% { transform: scale(0.95); opacity: 0.9; }
    50% { transform: scale(1.02); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.result-rank-1 { animation: resultRankBounce 0.6s ease-out, resultRankPulse 2s ease-in-out 0.6s infinite; }
.result-rank-2 { animation: resultRankBounce 0.5s ease-out 0.1s both; }
.result-rank-3 { animation: resultRankBounce 0.5s ease-out 0.2s both; }
@keyframes resultRankPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(255,215,0,0.4); }
    50% { box-shadow: 0 6px 25px rgba(255,215,0,0.6); }
}

/* 방 폭파 카운트다운 */
.room-expiry-section {
    background: var(--status-warning-bg);
    border: 2px solid var(--yellow-500);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
    text-align: center;
}

/* 말 선택 섹션 */
.horse-selection-section {
    display: none;
    background: var(--bg-primary);
    border: 2px solid var(--horse-500);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.horse-selection-section.active {
    display: block;
}

/* 게임 모드 선택 */
.game-mode-section {
    background: var(--horse-50);
    border: 2px solid var(--horse-500);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.game-mode-section label:hover {
    background: var(--horse-50);
    transform: translateX(2px);
}

.game-mode-section label input[type="radio"]:checked + span {
    color: var(--horse-accent);
    font-weight: 600;
}

@media (max-width: 1200px) {
    body.game-active .container {
        margin-left: auto;
        margin-right: auto;
    }
    
    .history-section {
        position: static;
        width: 100%;
        max-height: none;
        margin-top: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        margin: 5px;
        border-radius: 12px;
    }

    /* [필수1] 게임 활성 시 컨테이너 모바일 대응 */
    body.game-active .container {
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .race-track-container {
        height: 300px;
        margin: 10px 0;
        border-radius: 8px;
        overflow: hidden;
        margin-bottom: 44px; /* 미니맵 풀바 공간 확보 */
    }

    /* [필수2] 히스토리 패널 모바일 대응 */
    .history-section {
        position: static !important;
        width: 100% !important;
        max-height: 200px;
        z-index: auto;
        margin-top: 10px;
    }

    /* [권장7] 미니맵 모바일 하단 풀바 — 래퍼(raceTrackWrapper) 기준 배치 */
    #raceMinimap {
        position: relative !important;
        bottom: auto !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        border-radius: 0 0 8px 8px !important;
        padding: 6px 12px !important;
        background: rgba(0,0,0,0.85) !important;
    }

    /* [권장8] 카메라 버튼 터치 타겟 확대 */
    #cameraSwitchBtn {
        min-width: 44px;
        min-height: 44px;
        font-size: 14px !important;
        padding: 8px 12px !important;
    }

    /* [권장9] 선택 그리드 모바일 최적화 */
    .horse-selection-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .horse-selection-button {
        padding: 12px;
        font-size: 36px;
    }
}

/* ========== 날씨 효과 CSS ========== */
.weather-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 500;
    transition: opacity 0.8s ease;
}

/* 비 효과 */
.weather-rain {
    background: linear-gradient(transparent 0%, rgba(100, 150, 200, 0.1) 100%);
}
.weather-rain::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 40'%3E%3Cline x1='10' y1='0' x2='10' y2='15' stroke='%2387CEEB' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: 20px 40px;
    animation: rainFall 0.4s linear infinite;
    opacity: 0.6;
}
@keyframes rainFall {
    0% { background-position: 0 0; }
    100% { background-position: 10px 40px; }
}

/* 바람 효과 */
.weather-wind::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20'%3E%3Cpath d='M0,10 Q25,5 50,10 T100,10' fill='none' stroke='rgba(200,200,200,0.3)' stroke-width='2'/%3E%3C/svg%3E");
    background-size: 100px 20px;
    animation: windBlow 0.8s linear infinite;
    opacity: 0.5;
}
@keyframes windBlow {
    0% { background-position: 0 0; }
    100% { background-position: 100px 0; }
}

/* 안개 효과 */
.weather-fog {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.25) 0%,
        rgba(255,255,255,0.35) 30%,
        rgba(255,255,255,0.25) 60%,
        rgba(255,255,255,0.35) 100%);
    animation: fogMove 4s ease-in-out infinite;
}
@keyframes fogMove {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.9; }
}

/* 날씨 배너 */
.weather-banner {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    z-index: 600;
    animation: bannerFadeIn 0.3s ease;
    white-space: nowrap;
}
@keyframes bannerFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 날씨 토스트 메시지 */
.weather-toast {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: var(--yellow-500);
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 601;
    animation: toastSlide 3s ease forwards;
    white-space: nowrap;
}
@keyframes toastSlide {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

/* 버프/디버프 삼각형 */
.weather-indicator {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: bold;
    z-index: 200;
    animation: indicatorPulse 2s ease-out forwards;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.weather-buff {
    color: var(--blue-500);
}
.weather-nerf {
    color: var(--red-400);
}
@keyframes indicatorPulse {
    0% { opacity: 0; transform: translateX(-50%) scale(1.5); }
    20% { opacity: 1; transform: translateX(-50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}
/* Animation keyframes */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

/* 탈것 점프 애니메이션 */
@keyframes vehicleJump {
    0% { transform: translateY(0); }
    30% { transform: translateY(-20px); }
    50% { transform: translateY(-25px); }
    100% { transform: translateY(0); }
}

.horse.jumping .vehicle-sprite {
    animation: vehicleJump 0.4s ease-out;
}

/* 주사위 흔들림 애니메이션 */
@keyframes diceWobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    75% { transform: rotate(-15deg); }
}

/* 선택된 탈것 춤 애니메이션 */
@keyframes selectedDance {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    10% { transform: translateY(-8px) rotate(-5deg) scale(1.05); }
    20% { transform: translateY(-3px) rotate(5deg) scale(1.02); }
    30% { transform: translateY(-10px) rotate(-3deg) scale(1.08); }
    40% { transform: translateY(-2px) rotate(3deg) scale(1.02); }
    50% { transform: translateY(-6px) rotate(-2deg) scale(1.05); }
    60% { transform: translateY(-4px) rotate(4deg) scale(1.03); }
    70% { transform: translateY(-8px) rotate(-4deg) scale(1.06); }
    80% { transform: translateY(-2px) rotate(2deg) scale(1.02); }
    90% { transform: translateY(-5px) rotate(-1deg) scale(1.04); }
}

.horse-selection-button.selected .vehicle-display.dancing {
    animation: selectedDance 0.6s ease-in-out;
}

/* ============================================
   N등 투표 + 룰렛 (2026-04-30)
============================================ */
.rank-vote-section {
    margin-top: 14px;
    padding: 14px 14px 16px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.85) 0%, rgba(255,250,240,0.88) 100%),
        linear-gradient(135deg, var(--horse-50) 0%, var(--horse-100) 100%);
    border: 2px solid var(--horse-accent);
    border-radius: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.75),
        inset 0 -2px 0 rgba(139,94,60,0.15),
        0 4px 14px rgba(139,94,60,0.18);
    position: relative;
    overflow: hidden;
}
.rank-vote-section::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at top, rgba(255,215,0,0.08), transparent 60%);
}
.rank-vote-title {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--horse-accent) 0%, #c9881f 60%, #8b6914 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    position: relative;
}
.rank-vote-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 12px;
    position: relative;
}
.rank-vote-warn {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(255, 152, 0, 0.12);
    border: 1px solid rgba(255, 152, 0, 0.45);
    border-radius: 6px;
    font-size: 11px;
    color: #b87a00;
    text-align: center;
    line-height: 1.4;
}
.target-rank-banner {
    margin: 8px 0;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--horse-500) 0%, var(--horse-600) 100%);
    color: var(--bg-white);
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.target-rank-banner .trb-icon { font-size: 18px; }
.target-rank-banner .trb-text { font-size: 15px; }
@media (max-width: 480px) {
    .target-rank-banner { font-size: 13px; padding: 8px 10px; }
    .target-rank-banner .trb-icon { font-size: 15px; }
    .target-rank-banner .trb-text { font-size: 13px; }
}
/* 결정 사유 텍스트 (룰렛 결과 또는 fallback 사유) */
.target-rank-reason {
    margin: 4px auto 8px;
    padding: 8px 14px;
    max-width: 480px;
    background: rgba(255, 250, 230, 0.96);
    border: 1px solid var(--horse-300, #d4a574);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--horse-accent);
    text-align: center;
    line-height: 1.45;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.target-rank-reason.on-canvas {
    margin: 8px auto 0;
    padding: 12px 22px;
    background:
        linear-gradient(180deg, rgba(255, 250, 230, 0.96) 0%, rgba(252, 228, 180, 0.95) 100%);
    border: 2px solid var(--horse-accent);
    border-radius: 14px;
    color: #5d3a24;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    max-width: 92vw;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 0 0 2px rgba(255, 215, 0, 0.4),
        0 8px 28px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: auto;
    animation: reasonCardPop 0.55s cubic-bezier(0.2, 1.4, 0.6, 1);
}
@keyframes reasonCardPop {
    0%   { transform: scale(0.88); opacity: 0; }
    70%  { transform: scale(1.04); opacity: 1; }
    100% { transform: scale(1);    opacity: 1; }
}
@media (max-width: 480px) {
    .target-rank-reason.on-canvas { font-size: 12px; padding: 10px 16px; }
}
@media (max-width: 480px) {
    .target-rank-reason { font-size: 11px; padding: 6px 10px; }
}

/* gameStatus와 캔버스 사이 빈 공간에 배너만 인라인 배치 */
.canvas-result-center {
    margin: 10px 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 1;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.canvas-result-center.fading-out {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
}
.canvas-result-center .target-rank-banner.on-canvas {
    margin: 0;
}

/* 투표 막대 섹션은 캔버스 내부 정중앙 absolute */
.canvas-bars-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
    max-width: 92%;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.canvas-bars-overlay.fading-out {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.96);
}
.canvas-bars-overlay .rank-vote-section.on-canvas {
    margin: 0;
    pointer-events: auto;
}
.target-rank-banner.on-canvas {
    /* 캔버스 위 단순 사각 박스 — 기본 .target-rank-banner 스타일 그대로 사용, 사이즈만 약간 축소 */
    padding: 8px 14px;
    font-size: 14px;
}
.target-rank-banner.on-canvas .trb-icon { font-size: 16px; }
.target-rank-banner.on-canvas .trb-text { font-size: 14px; }
.rank-vote-section.on-canvas {
    background:
        linear-gradient(180deg, rgba(255,250,230,0.96) 0%, rgba(252,228,180,0.95) 100%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.85),
        0 0 0 2px rgba(255, 215, 0, 0.4),
        0 8px 28px rgba(0, 0, 0, 0.55);
    border: 2px solid var(--horse-accent);
    padding: 14px 18px 16px;
}
.rank-vote-section.on-canvas .rank-vote-box {
    max-width: 110px;
    padding: 10px 8px 12px;
}
.rank-vote-section.on-canvas .rank-vote-rank {
    font-size: 17px;
}
.rank-vote-section.on-canvas .rank-vote-bar {
    width: 8px;
    height: 22px;
}
.rank-vote-section.on-canvas .rank-vote-title,
.rank-vote-section.on-canvas .rank-vote-hint,
.rank-vote-section.on-canvas .rank-vote-warn {
    display: none;
}

/* 결과창 winner row — 강조 연출 (box-shadow 펄스 + 모서리 따라 도는 글로우 + 사선 광채) */
.result-target-row {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    outline: 2px solid #ffd700;
    outline-offset: -1px;
    animation: targetRowPulse 1.6s ease-in-out infinite;
    z-index: 0;
}
/* 사선 광채 sweep — 모든 브라우저 안정적으로 동작 */
.result-target-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        100deg,
        transparent 0%,
        rgba(255, 255, 255, 0.55) 45%,
        rgba(255, 245, 160, 0.85) 50%,
        rgba(255, 255, 255, 0.55) 55%,
        transparent 100%
    );
    animation: targetSheen 2s linear infinite;
    z-index: 1;
    pointer-events: none;
    mix-blend-mode: overlay;
}
/* 모서리 따라 도는 골드 글로우 — 위치 변하는 box-shadow */
.result-target-row::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    animation: targetCornerLight 2.4s linear infinite;
    z-index: 2;
}
@keyframes targetSheen {
    0%   { left: -60%; }
    100% { left: 110%; }
}
@keyframes targetCornerLight {
    0%   { box-shadow: inset  0  -3px 16px 2px rgba(255, 215, 0, 0.85); }
    25%  { box-shadow: inset -3px  0   16px 2px rgba(255, 215, 0, 0.85); }
    50%  { box-shadow: inset  0   3px 16px 2px rgba(255, 215, 0, 0.85); }
    75%  { box-shadow: inset  3px  0   16px 2px rgba(255, 215, 0, 0.85); }
    100% { box-shadow: inset  0  -3px 16px 2px rgba(255, 215, 0, 0.85); }
}
@keyframes targetRowPulse {
    0%, 100% { box-shadow: 0 0 14px 2px rgba(255, 215, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.18); }
    50%      { box-shadow: 0 0 28px 4px rgba(255, 215, 0, 0.85), 0 3px 12px rgba(0, 0, 0, 0.22); }
}

/* 결과창 당첨자 칩 */
.winner-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
}
.winner-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 800;
    border-radius: 999px;
    box-shadow: 0 3px 12px rgba(255, 200, 0, 0.55), 0 0 0 2px rgba(255, 255, 255, 0.4) inset;
    letter-spacing: 0.3px;
    animation: winnerChipPop 0.45s cubic-bezier(0.2, 1.4, 0.6, 1) backwards;
}
.winner-chip.empty {
    background: rgba(255, 255, 255, 0.12);
    color: var(--gray-300, #aaa);
    font-weight: 600;
    font-size: 13px;
    box-shadow: none;
    animation: none;
}
@keyframes winnerChipPop {
    0%   { transform: scale(0.4); opacity: 0; }
    70%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}
.winner-chip:nth-child(2) { animation-delay: 0.1s; }
.winner-chip:nth-child(3) { animation-delay: 0.2s; }
.winner-chip:nth-child(4) { animation-delay: 0.3s; }
.winner-chip:nth-child(5) { animation-delay: 0.4s; }
.winner-chip:nth-child(n+6) { animation-delay: 0.5s; }
@media (max-width: 480px) {
    .winner-chip { font-size: 14px; padding: 5px 12px; }
}
.rank-vote-boxes {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: center;
    position: relative;
    width: 100%;
}
.rank-vote-box {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    max-width: 96px;
    padding: 8px 6px 10px;
    background:
        linear-gradient(180deg, #ffffff 0%, #fff8ec 100%);
    border: 2px solid var(--horse-300, #d4a574);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.2, 1.4, 0.6, 1), border-color 0.18s, background 0.18s, box-shadow 0.18s;
    text-align: center;
    user-select: none;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -2px 0 rgba(139,94,60,0.12),
        0 2px 6px rgba(139,94,60,0.15);
}
.rank-vote-box::before {
    content: '';
    position: absolute;
    top: 4px; left: 4px; right: 4px;
    height: 30%;
    border-radius: 8px 8px 50% 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.45), transparent);
    pointer-events: none;
}
.rank-vote-box:hover {
    transform: translateY(-3px);
    border-color: var(--horse-500);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -2px 0 rgba(139,94,60,0.18),
        0 6px 14px rgba(139,94,60,0.28);
}
.rank-vote-box .rank-vote-rank {
    font-size: 15px;
    font-weight: 800;
    color: var(--horse-accent);
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
    letter-spacing: -0.3px;
    position: relative;
    white-space: nowrap;
}
.rank-vote-box .rank-vote-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.rank-vote-box .rank-vote-bars {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    align-items: flex-end;
    margin-top: 8px;
    min-height: 22px;
    position: relative;
}
.rank-vote-bar {
    width: 6px;
    height: 18px;
    background: linear-gradient(180deg, var(--horse-500, #8b5e3c) 0%, var(--horse-600, #6b4530) 100%);
    border-radius: 3px;
    opacity: 0.7;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.25),
        0 1px 2px rgba(0,0,0,0.15);
    transition: transform 0.08s, opacity 0.08s, background 0.08s, box-shadow 0.08s;
}
.rank-vote-bar.active {
    opacity: 1;
    background: linear-gradient(180deg, #ffe06a 0%, #ffb938 100%);
    transform: scaleY(1.35) translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.6),
        0 0 10px rgba(255, 213, 74, 0.95);
}
.rank-vote-bar.winner {
    opacity: 1;
    background: linear-gradient(180deg, #fff3a0 0%, #ffd700 40%, #ffa000 100%);
    transform: scaleY(1.6) translateY(-2px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.85),
        0 0 14px rgba(255, 200, 0, 0.95),
        0 0 0 1.5px #fff8d8;
    animation: rankBarWinnerPulse 1.4s ease-in-out infinite;
}
@keyframes rankBarWinnerPulse {
    0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 0 14px rgba(255, 200, 0, 0.95), 0 0 0 1.5px #fff8d8; }
    50%      { box-shadow: inset 0 1px 0 rgba(255,255,255,0.95), 0 0 24px rgba(255, 220, 80, 1),    0 0 0 2px   #ffffff; }
}
.rank-vote-box .rank-vote-voters {
    font-size: 10px;
    color: var(--horse-accent);
    margin-top: 2px;
    line-height: 1.2;
    word-break: keep-all;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rank-vote-box.selected {
    /* 사이즈/위치 변경 없이 보더+글로우로 선택 강조 */
    border-color: #d4a017;
    outline: 2px solid #ffd700;
    outline-offset: 1px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -2px 0 rgba(180, 130, 30, 0.18),
        0 0 12px rgba(255, 200, 0, 0.55),
        0 2px 6px rgba(139, 94, 60, 0.18);
}
.rank-vote-box.selected::after {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #ffd700 0%, #ffa000 100%);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 900;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.5);
    animation: voteCheckPop 0.35s cubic-bezier(0.2, 1.5, 0.6, 1);
}
@keyframes voteCheckPop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}
.rank-vote-box.selected .rank-vote-rank {
    color: #8b6914;
    text-shadow: 0 1px 0 rgba(255,255,255,0.85);
}
.rank-vote-box.invalid {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
}
.rank-vote-box.invalid::after {
    content: '무효';
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--red-400);
    color: var(--bg-white);
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 6px;
    font-weight: bold;
}

/* ─── 룰렛 오버레이 ─── */
.roulette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.78);
    /* debugLogSection(z-index 10000) 위에 떠야 화살표/strip이 가려지지 않음 */
    z-index: 10001;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}
.roulette-overlay.visible {
    display: flex !important;
}
.roulette-card {
    background: linear-gradient(135deg, var(--horse-500) 0%, var(--horse-600) 100%);
    padding: 20px 22px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 92vw;
    width: 460px;
    color: var(--bg-white);
    text-align: center;
}
.roulette-title {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 4px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.roulette-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 14px;
}
.roulette-track-wrap {
    position: relative;
    width: 100%;
    padding-top: 22px;
    margin-bottom: 12px;
}
.roulette-pointer {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 22px;
    line-height: 1;
    color: var(--yellow-300, #ffd700);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    z-index: 2;
}
.roulette-track {
    position: relative;
    width: 100%;
    height: 56px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.25);
}
.roulette-strip {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    will-change: transform;
}
.roulette-segment {
    flex: 0 0 auto;
    width: 60px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.18);
    font-weight: bold;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.15) 100%);
}
.roulette-segment.r-odd {
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.18) 0%, rgba(255, 215, 0, 0.05) 100%);
}
.roulette-segment .seg-rank {
    font-size: 16px;
    color: var(--bg-white);
}
.roulette-segment .seg-count {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}
.roulette-result {
    font-size: 16px;
    font-weight: bold;
    min-height: 22px;
    color: var(--yellow-300, #ffd700);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
@media (max-width: 480px) {
    .roulette-card { padding: 16px 14px; }
    .roulette-segment { width: 50px; }
}

/* 탈것 선택 헤더 (자동선택 토글 포함) */
.horse-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.auto-select-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-secondary);
}

.auto-select-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.auto-select-toggle-slider {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background: var(--text-secondary);
    border-radius: 999px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.auto-select-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.auto-select-toggle input[type="checkbox"]:checked ~ .auto-select-toggle-slider {
    background: var(--horse-500);
}

.auto-select-toggle input[type="checkbox"]:checked ~ .auto-select-toggle-slider::before {
    transform: translateX(16px);
}

.auto-select-toggle-label {
    font-weight: 600;
}

@media (max-width: 480px) {
    .auto-select-toggle {
        font-size: 12px;
    }
}
