/* ── Section preview (클릭 가능한 시작화면 미리보기) ── */
.runner-section-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 20px;
}

.runner-section-preview:hover .runner-start-overlay {
    filter: brightness(0.97);
}

.runner-game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 2 / 3;
    margin: 0 auto;
    background: #87CEEB;
    border-radius: 0;
    overflow: hidden;
    user-select: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    .runner-game-container {
        border-radius: 16px;
    }
}


#runner-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.runner-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.runner-score-board,
.runner-timer-gauge {
    visibility: hidden;
}

.runner-score-board {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 140px;
    font-family: 'Gowun Dodum', serif;
    font-size: 0.9rem;
    color: #333;
    background: #fdfaf5;
    padding: 4px 12px;
    border-radius: 4px;
    border: 2px solid #5a4d41;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 20;
    height: 32px;
    box-sizing: border-box;
}

.runner-score-board::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 1px solid rgba(90, 77, 65, 0.2);
    pointer-events: none;
}

.runner-coin-count {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 60px;
}

.runner-coin-count::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url('../images/runner/coin.png') no-repeat center center;
    background-size: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.runner-dist-count {
    width: 80px;
    text-align: right;
    font-weight: bold;
    color: #5a4d41;
}

/* ── Timer Gauge (top, horizontal) ── */
.runner-timer-gauge {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 165px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
}

.runner-timer-label {
    font-family: 'Gowun Dodum', serif;
    font-size: 0.9rem;
    font-weight: bold;
    color: #333;
    background: #fdfaf5;
    border: 2px solid #5a4d41;
    border-radius: 4px;
    padding: 0 6px;
    width: 52px;
    height: 32px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    flex-shrink: 0;
    box-sizing: border-box;
}

.runner-timer-label .timer-icon {
    justify-self: start;
}

.runner-timer-label #runner-timer-val {
    justify-self: center;
}

.runner-timer-track {
    flex: 1;
    height: 14px;
    background: rgba(253, 250, 245, 0.85);
    border: 2px solid #5a4d41;
    border-radius: 7px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.runner-timer-fill {
    height: 100%;
    width: 100%;
    background: #4caf50;
    border-radius: 5px;
    transition: width 0.1s linear, background 0.3s ease;
}

.runner-start-overlay, .runner-over-overlay {
    pointer-events: auto;
    background: #fdfaf5;
    padding: clamp(14px, 4vh, 28px) clamp(18px, 5vw, 35px);
    border-radius: 4px;
    text-align: center;
    box-shadow: 0 15px 45px rgba(0,0,0,0.2);
    animation: fadeInUp 0.5s ease-out;
    border: 8px solid #4a4a4a;
    border-image: linear-gradient(#4a4a4a, #333) 1;
    position: relative;
    max-width: 88%;
    width: 88%;
}

@keyframes hamsterBounce {
    from { transform: translateY(0) rotate(-6deg); }
    to   { transform: translateY(-10px) rotate(6deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Traditional Decorative Corners */
.runner-start-overlay::before, .runner-over-overlay::before,
.runner-start-overlay::after, .runner-over-overlay::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    border: 3px solid #b22222; /* Traditional Red */
    z-index: 1;
}

.runner-start-overlay::before, .runner-over-overlay::before {
    top: -12px;
    left: -12px;
    border-right: none;
    border-bottom: none;
}

.runner-start-overlay::after, .runner-over-overlay::after {
    bottom: -12px;
    right: -12px;
    border-left: none;
    border-top: none;
}

.runner-start-overlay h3, .runner-over-overlay h3 {
    color: #5a4d41;
    font-size: clamp(1.1rem, 4vh, 1.6rem);
    border-bottom: 2px solid #5a4d41;
    margin-bottom: clamp(10px, 2.5vh, 20px) !important;
    padding-bottom: 8px;
}

.runner-start-overlay p, .runner-over-overlay p {
    font-size: clamp(0.78rem, 2.2vh, 0.9rem);
    margin-bottom: clamp(6px, 1.5vh, 12px) !important;
}

.runner-btn {
    margin-top: clamp(8px, 2vh, 15px);
    padding: clamp(8px, 1.8vh, 12px) 30px;
    font-family: 'Gowun Dodum', serif;
    background: #5a4d41;
    color: #fdfaf5;
    border: 1px solid #3e332a;
    border-radius: 4px;
    cursor: pointer;
    font-size: clamp(0.9rem, 2.5vh, 1.1rem);
    transition: all 0.2s;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    letter-spacing: 1px;
}

.runner-btn:hover {
    background: #463b32;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

/* ── Runner Game Modal ── */
.runner-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: contain;
}

.runner-modal.hidden {
    display: none;
}

.runner-modal-inner {
    position: relative;
    /* 폭 100% 채우되, 세로가 88dvh를 넘지 않도록 높이 기준으로도 제한 */
    width: min(100vw, calc(88vh * 2 / 3));
    width: min(100vw, calc(88dvh * 2 / 3)); /* dvh 지원 브라우저 */
    aspect-ratio: 2 / 3;
}

@media (min-width: 768px) {
    .runner-modal-inner {
        /* 데스크탑: height 기준으로 크기 결정, aspect-ratio가 width 자동 계산 */
        height: min(90vh, 720px);
        height: min(90dvh, 720px); /* dvh 지원 브라우저 */
        width: auto;
    }
}

.runner-modal-close {
    position: absolute;
    top: -14px;
    right: -14px;
    z-index: 1300;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    pointer-events: auto;
    transition: background 0.2s;
}

/* 모바일: 게임이 100vw라 바깥으로 빠져나갈 공간이 없음.
   fixed로 뷰포트 기준 상단에 고정 → 게임 UI와 겹치지 않음 */
@media (max-width: 767px) {
    .runner-modal-close {
        position: fixed;
        top: 14px;
        right: 14px;
    }
}

.runner-modal-close:hover {
    background: #fff;
}

/* Delivery Scene */
.delivery-scene {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../images/runner/hall.png') no-repeat bottom center;
    background-size: cover;
    z-index: 5;
    opacity: 0;
    transition: opacity 1s;
}

.delivery-scene.active {
    opacity: 1;
}

.delivery-text {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

.delivery-text h3 {
    font-family: 'Gowun Dodum', serif;
    font-size: 1.4rem;
    color: #555;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(255,255,255,0.8);
}
