/* 테트리스 게임 — harulogs 스킨 통합용 (네온 아케이드 테마) */
.tetris-game {
    --tg-accent: #e94560;
    --tg-bg: #1a1a2e;
    --tg-panel: #16213e;
    --tg-board: #0f0f1a;
}

/* 히어로 */
.tetris-game .tg-hero {
    position: relative;
    text-align: center;
    margin-bottom: 22px;
}
/* 소리 켜기/끄기 토글 버튼 */
.tetris-game .tg-sound-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    border: 2px solid var(--tg-accent);
    border-radius: 50%;
    background: var(--tg-panel);
    color: #fff;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.25);
}
.tetris-game .tg-sound-toggle:hover { transform: scale(1.08); box-shadow: 0 0 14px rgba(233, 69, 96, 0.45); }
.tetris-game .tg-sound-toggle.is-muted { opacity: 0.55; border-color: #666; box-shadow: none; }
.tetris-game .tg-hero h1 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 6px;
}
.tetris-game .tg-hero h1 .tg-mark { color: var(--tg-accent); }
.tetris-game .tg-hero p {
    color: #6c757d;
    margin: 0;
    font-size: 15px;
}

/* 게임 스테이지 (어두운 아케이드 패널) */
.tetris-game .tg-stage {
    position: relative;
    background: var(--tg-bg);
    border-radius: 18px;
    padding: 28px 20px;
    box-shadow: 0 18px 50px rgba(26, 26, 46, 0.45);
    color: #eee;
    font-family: 'Courier New', monospace;
    overflow: hidden;
}

.tetris-game .game-wrapper {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    justify-content: center;
}
.tetris-game .left-panel,
.tetris-game .right-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 132px;
}

.tetris-game canvas#gameCanvas {
    border: 3px solid var(--tg-accent);
    box-shadow: 0 0 20px var(--tg-accent), 0 0 40px rgba(233, 69, 96, 0.3);
    display: block;
    background: var(--tg-board);
    border-radius: 4px;
    touch-action: none;
    max-width: 100%;
    height: auto;
}

.tetris-game .panel-box {
    background: var(--tg-panel);
    border: 2px solid var(--tg-accent);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.2);
}
.tetris-game .panel-box h3 {
    font-size: 11px;
    color: var(--tg-accent);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.tetris-game .panel-box .value {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px var(--tg-accent);
}
.tetris-game canvas#nextCanvas {
    border: 1px solid #444;
    background: var(--tg-board);
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}
.tetris-game .controls {
    background: var(--tg-panel);
    border: 2px solid #444;
    border-radius: 8px;
    padding: 12px;
    font-size: 11px;
    color: #aaa;
    line-height: 1.85;
}
.tetris-game .controls h3 {
    color: var(--tg-accent);
    letter-spacing: 2px;
    margin-bottom: 6px;
    font-size: 10px;
}
.tetris-game .controls .key { color: #fff; font-weight: bold; }

/* 오버레이 (게임 스테이지 내부로 한정)
   광고·공유 버튼이 추가돼 내용이 스테이지보다 길어질 수 있다.
   justify-content:center 는 넘칠 때 위쪽이 잘려 스크롤로도 못 보게 되므로,
   flex-start + 첫/끝 자식 auto 마진으로 "짧으면 중앙, 길면 스크롤"을 만든다. */
.tetris-game #overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 20;
    border-radius: 18px;
    text-align: center;
    padding: 20px;
    overflow-y: auto;
}
/* 위아래 신축 스페이서 — 내용이 짧으면 중앙 정렬, 넘치면 0 으로 줄어 스크롤 시작점이 위가 된다.
   (:last-child 방식은 마지막 자식(광고)이 미채움으로 display:none 될 때 깨져서 쓰지 않는다) */
.tetris-game #overlay::before,
.tetris-game #overlay::after {
    content: "";
    flex: 1 1 0;
    min-height: 0;
}
.tetris-game #overlay h1 {
    font-size: 46px;
    color: var(--tg-accent);
    text-shadow: 0 0 20px var(--tg-accent);
    margin-bottom: 18px;
    letter-spacing: 4px;
}
.tetris-game #overlay p {
    font-size: 15px;
    color: #aaa;
    margin-bottom: 8px;
}
.tetris-game #overlay .final-score {
    font-size: 26px;
    color: #fff;
    margin: 8px 0 22px;
    text-shadow: 0 0 10px var(--tg-accent);
}
.tetris-game #startBtn {
    background: var(--tg-accent);
    color: #fff;
    border: none;
    padding: 14px 40px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}
.tetris-game #startBtn:hover {
    background: #ff6b6b;
    box-shadow: 0 0 30px rgba(233, 69, 96, 0.8);
    transform: scale(1.05);
}
.tetris-game #overlayTitle { display: block; }
.tetris-game #gameoverText { display: none; }

/* 모바일 터치 조작 */
.tetris-game .tg-touch {
    display: none;
    margin-top: 18px;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.tetris-game .tg-touch button {
    flex: 1 1 0;
    min-width: 56px;
    max-width: 90px;
    aspect-ratio: 1 / 1;
    background: var(--tg-panel);
    border: 2px solid var(--tg-accent);
    color: #fff;
    border-radius: 12px;
    font-size: 22px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    transition: background 0.12s;
}
.tetris-game .tg-touch button:active { background: var(--tg-accent); }
.tetris-game .tg-touch button.wide { font-size: 13px; letter-spacing: 1px; }

/* 반응형 */
@media (max-width: 720px) {
    .tetris-game .tg-stage { padding: 18px 12px; }
    .tetris-game .game-wrapper { gap: 10px; }
    .tetris-game .left-panel,
    .tetris-game .right-panel { min-width: 84px; gap: 10px; }
    .tetris-game .panel-box { padding: 8px; }
    .tetris-game .panel-box .value { font-size: 18px; }
    .tetris-game .panel-box h3 { font-size: 9px; }
    .tetris-game .controls { display: none; }
    .tetris-game canvas#nextCanvas { width: 72px; height: 72px; }
    .tetris-game .tg-touch { display: flex; }
}
@media (max-width: 420px) {
    .tetris-game canvas#gameCanvas { width: 210px; }
    .tetris-game .left-panel, .tetris-game .right-panel { min-width: 70px; }
}

/* 점수 등록 폼 (오버레이) */
.tetris-game #scoreSubmit { display: none; margin: 4px 0 18px; }
.tetris-game #nickInput {
    background: #0f0f1a;
    border: 2px solid var(--tg-accent);
    color: #fff;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 15px;
    font-family: 'Courier New', monospace;
    text-align: center;
    width: 180px;
    max-width: 60vw;
    outline: none;
}
.tetris-game #nickInput::placeholder { color: #888; }
.tetris-game #registerBtn {
    margin-left: 8px;
    background: #16213e;
    color: #fff;
    border: 2px solid var(--tg-accent);
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.tetris-game #registerBtn:hover:not(:disabled) { background: var(--tg-accent); }
.tetris-game #registerBtn:disabled { opacity: 0.55; cursor: default; }
.tetris-game #rankResult { margin-top: 10px; font-size: 14px; min-height: 18px; }
.tetris-game #rankResult.tg-ok { color: #00e676; }
.tetris-game #rankResult.tg-err { color: #ff6b6b; }

/* 랭킹 */
.tetris-game .tg-ranking-wrap { margin: 22px auto 0; }
.tetris-game .tg-ranking {
    height: 100%;
    margin: 0;
    background: var(--tg-panel);
    border: 2px solid var(--tg-accent);
    border-radius: 14px;
    padding: 16px 18px 10px;
    color: #eee;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 14px rgba(233, 69, 96, 0.18);
}
.tetris-game .tg-ranking h3 {
    text-align: center;
    color: var(--tg-accent);
    letter-spacing: 2px;
    font-size: 15px;
    margin-bottom: 12px;
}
.tetris-game .tg-ranking ol { list-style: none; margin: 0; padding: 0; }
.tetris-game .tg-ranking ol li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
}
.tetris-game .tg-ranking ol li:last-child { border-bottom: none; }
.tetris-game .tg-rank-badge { width: 34px; text-align: center; font-size: 17px; }
.tetris-game .tg-rank-num { color: #aaa; font-weight: bold; font-size: 14px; }
.tetris-game .tg-rank-nick { flex: 1; min-width: 0; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tetris-game .tg-rank-score { text-align: right; color: var(--tg-accent); font-weight: bold; text-shadow: 0 0 8px rgba(233, 69, 96, 0.4); flex-shrink: 0; }
.tetris-game .tg-rank-empty { justify-content: center; color: #888; }
.tetris-game .tg-rank-flag { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }

/* 스트릭 뱃지 (랭킹 행 — streak >= 3 일 때만 JS 가 붙인다) */
.tetris-game .tg-rank-streak {
    flex-shrink: 0;
    font-size: 11px;
    color: #ffb020;
    background: rgba(255, 176, 32, 0.12);
    border: 1px solid rgba(255, 176, 32, 0.4);
    border-radius: 10px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* 게임 모드 토글 (일반 / 오늘의 도전) — 랭킹 패널과 같은 아케이드 톤(고정 다크) */
.tetris-game .tg-mode {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}
.tetris-game .tg-mode-btn {
    background: var(--tg-panel);
    color: #aaa;
    border: 2px solid #444;
    border-radius: 999px;
    padding: 8px 22px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s;
}
.tetris-game .tg-mode-btn:hover { color: #fff; border-color: var(--tg-accent); }
.tetris-game .tg-mode-btn.is-active {
    background: var(--tg-accent);
    border-color: var(--tg-accent);
    color: #fff;
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.45);
}

/* 오늘의 도전 안내 (모드 토글 아래) */
.tetris-game .tg-daily-info {
    text-align: center;
    font-size: 13px;
    color: #6c757d;
    margin: 0 0 12px;
}

/* 랭킹 기간 탭 (이번 주 / 역대) */
.tetris-game .tg-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
}
.tetris-game .tg-tab {
    background: var(--tg-panel);
    color: #aaa;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 7px 20px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s;
}
.tetris-game .tg-tab:hover { color: #fff; border-color: var(--tg-accent); }
.tetris-game .tg-tab.is-active {
    background: var(--tg-accent);
    border-color: var(--tg-accent);
    color: #fff;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.4);
}

/* 결과 공유 버튼 (게임오버 오버레이) */
.tetris-game #shareBtn {
    margin-top: 12px;
    background: transparent;
    color: #fff;
    border: 2px solid var(--tg-accent);
    padding: 11px 30px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}
.tetris-game #shareBtn:hover {
    background: var(--tg-accent);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}

/* 순위 피드백 줄 (rankResult 내부) */
.tetris-game #rankResult .tg-fb-gap { color: #ffd700; font-size: 13px; }
.tetris-game #rankResult .tg-fb-streak { color: #ffb020; font-size: 13px; }

/* 오버레이 내부 광고 — 어두운 오버레이에 맞춰 띠 색만 조정(광고 자체는 건드리지 않는다) */
.tetris-game #overlay .hl-ad {
    width: 100%;
    margin: 16px 0 0;
    background: rgba(255, 255, 255, 0.04);
    border-top-color: rgba(255, 255, 255, 0.14);
    border-bottom-color: rgba(255, 255, 255, 0.14);
}
.tetris-game #overlay .hl-ad::before { color: #8a90a5; }

/* ══════════════ 1:1 대결 (고스트 배틀) ══════════════ */

/* 도전장 안내 (수락 페이지 오버레이) */
.tetris-game .tg-duel-intro {
    max-width: 420px;
    color: #ffd700;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 14px;
}

/* 고스트 패널 — 데스크톱: 오른쪽 4번째 칼럼 */
.tetris-game .tg-duel-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 148px;
    position: relative;
}
.tetris-game .tg-duel-ghost-box h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tetris-game canvas#duelGhostCanvas {
    border: 1px solid #444;
    background: var(--tg-board);
    border-radius: 4px;
    display: block;
    margin: 0 auto 8px;
    max-width: 100%;
}
.tetris-game .tg-duel-ghost-score { color: #ffd700; }
.tetris-game .tg-duel-ghost-status {
    margin-top: 4px;
    font-size: 10px;
    letter-spacing: 1px;
    color: #8a90a5;
    text-transform: uppercase;
}

/* 방해줄 경고 플래시 */
.tetris-game .tg-duel-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(233, 69, 96, 0.92);
    color: #fff;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    padding: 6px 12px;
    border-radius: 8px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
    opacity: 0;
}
.tetris-game .tg-duel-flash.is-on { animation: tgDuelFlash 1.3s ease-out forwards; }
@keyframes tgDuelFlash {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    30% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* 대결 만들기 폼 (오버레이) — 랭킹 등록 폼과 같은 톤 */
.tetris-game .tg-duel-create { margin: 4px 0 18px; }
.tetris-game #duelNickInput,
.tetris-game #duelAcceptNick {
    background: #0f0f1a;
    border: 2px solid var(--tg-accent);
    color: #fff;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 15px;
    font-family: 'Courier New', monospace;
    text-align: center;
    width: 180px;
    max-width: 60vw;
    outline: none;
}
.tetris-game #duelNickInput::placeholder,
.tetris-game #duelAcceptNick::placeholder { color: #888; }
.tetris-game #duelCreateBtn {
    margin-left: 8px;
    background: #16213e;
    color: #fff;
    border: 2px solid var(--tg-accent);
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.tetris-game #duelCreateBtn:hover:not(:disabled) { background: var(--tg-accent); }
.tetris-game #duelCreateBtn:disabled { opacity: 0.55; cursor: default; }
.tetris-game #duelCreateResult { margin-top: 10px; font-size: 14px; min-height: 18px; }
.tetris-game #duelCreateResult.tg-ok { color: #00e676; }
.tetris-game #duelCreateResult.tg-err { color: #ff6b6b; }

/* 생성된 도전장 링크 상자 */
.tetris-game .tg-duel-link {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    max-width: 440px;
}
.tetris-game #duelLinkInput {
    flex: 1 1 100%;
    background: #0f0f1a;
    border: 2px solid #444;
    color: #ffd700;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    text-align: center;
    outline: none;
}
.tetris-game #duelCopyBtn,
.tetris-game #duelShareBtn {
    background: #16213e;
    color: #fff;
    border: 2px solid var(--tg-accent);
    padding: 9px 18px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.tetris-game #duelCopyBtn:hover,
.tetris-game #duelShareBtn:hover { background: var(--tg-accent); }

/* 수락자 닉네임 입력 (시작 전) */
.tetris-game .tg-duel-accept { margin: 4px 0 16px; }

/* 대결 결과 (승패 판정) */
.tetris-game .tg-duel-result { margin: 4px 0 18px; }
.tetris-game .tg-duel-result-title {
    font-size: 28px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 14px;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}
.tetris-game .tg-duel-result-title.is-win { color: #00e676; text-shadow: 0 0 12px rgba(0, 230, 118, 0.45); }
.tetris-game .tg-duel-result-title.is-lose { color: #ff6b6b; text-shadow: 0 0 12px rgba(255, 107, 107, 0.4); }
.tetris-game .tg-duel-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 16px;
}
.tetris-game .tg-duel-vs-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 110px;
}
.tetris-game .tg-duel-vs-nick {
    color: #8a90a5;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}
.tetris-game .tg-duel-vs-score {
    color: #fff;
    font-size: 26px;
    font-weight: bold;
    text-shadow: 0 0 10px var(--tg-accent);
}
.tetris-game .tg-duel-vs-mark {
    color: var(--tg-accent);
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 1px;
}
.tetris-game .tg-duel-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.tetris-game #duelRematchBtn,
.tetris-game #duelResultShareBtn {
    background: transparent;
    color: #fff;
    border: 2px solid var(--tg-accent);
    padding: 11px 24px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}
.tetris-game #duelRematchBtn:hover,
.tetris-game #duelResultShareBtn:hover {
    background: var(--tg-accent);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}

/* 모바일 — 고스트 패널을 보드 위 가로 스트립으로 (375px 에서 4칼럼은 무리) */
@media (max-width: 720px) {
    .tetris-game .game-wrapper.has-duel { flex-wrap: wrap; }
    .tetris-game .tg-duel-panel {
        flex: 1 1 100%;
        order: -1;
        min-width: 0;
    }
    .tetris-game .tg-duel-ghost-box {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 8px 10px;
        text-align: left;
    }
    .tetris-game .tg-duel-ghost-box h3 { margin-bottom: 0; max-width: 90px; }
    .tetris-game canvas#duelGhostCanvas {
        width: 60px;
        height: 120px;
        margin: 0;
        flex-shrink: 0;
    }
    .tetris-game .tg-duel-ghost-score { font-size: 18px; }
    .tetris-game .tg-duel-ghost-status { margin-top: 0; }
}
