/* =============================================
   테트리스 게임 스타일
   테마: 다크 + 네온
   ============================================= */

html { background: #0f0f23; }

.tt-body {
    overflow: hidden;
    height: 100dvh;
    max-width: 520px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #f0f0f0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Game Area */
.tt-game {
    width: 100%;
    height: 100dvh;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0f0f23;
}

/* Top Bar */
.tt-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    z-index: 10;
    flex-shrink: 0;
}
.tt-back {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}
.tt-back:hover { color: #fff; }
.tt-info-badge {
    font-size: 13px;
    font-weight: 600;
    color: #60A5FA;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.2);
}

/* Play Area (canvas + side panels) */
.tt-play-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 8px;
    padding: 0 8px;
    flex-shrink: 0;
}

/* Side panels */
.tt-side-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 70px;
}
.tt-panel-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}
.tt-panel-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.tt-panel-value {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

/* Next canvas */
#ttNextCanvas {
    width: 60px;
    height: 60px;
    display: block;
    margin: 4px auto 0;
    border-radius: 4px;
}

/* Canvas Wrapper */
.tt-canvas-wrap {
    flex-shrink: 0;
}
.tt-canvas-wrap canvas {
    display: block;
    border-radius: 4px;
    border: 1px solid #2d2d44;
}

/* Mobile Touch Controls */
.tt-controls {
    display: none;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.tt-ctrl-btn {
    width: 56px;
    height: 56px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s;
}
.tt-ctrl-btn:active {
    background: rgba(96, 165, 250, 0.3);
    border-color: rgba(96, 165, 250, 0.5);
}
.tt-ctrl-wide {
    width: auto;
    padding: 0 20px;
    font-size: 14px;
    letter-spacing: 2px;
}

/* Content area */
.tt-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 20px;
    overflow-y: auto;
}

/* ===== INTRO ===== */
.state-intro .tt-play-area { display: none; }
.state-intro .tt-controls { display: none !important; }
.state-intro .tt-info-badge { display: none; }
.state-intro .tt-content {
    justify-content: center;
    padding-top: 0;
}

.tt-intro-emoji { font-size: 72px; margin-bottom: 16px; }
.tt-intro-title {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}
.tt-intro-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
}
.tt-intro-desc strong { color: #60A5FA; }

.tt-best {
    background: rgba(96, 165, 250, 0.1);
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.tt-challenge {
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    font-size: 16px;
    color: #60A5FA;
    text-align: center;
}
.tt-challenge strong { font-size: 22px; }

.tt-rules {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}
.tt-rule-chip {
    padding: 6px 14px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.tt-btn-start {
    display: inline-block;
    padding: 16px 48px;
    background: linear-gradient(135deg, #60A5FA, #3B82F6);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.tt-btn-start:active { transform: scale(0.95); }

/* ===== COUNTDOWN ===== */
.state-countdown { background: #0f0f1a; }
.state-countdown .tt-play-area { display: none; }
.state-countdown .tt-controls { display: none !important; }
.state-countdown .tt-info-badge { display: none; }
.state-countdown .tt-content {
    justify-content: center;
    padding: 0;
}
.tt-countdown-wrap { text-align: center; }
.tt-countdown-num {
    font-size: 120px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    animation: ttCountPop 0.5s ease-out;
}
.tt-countdown-num.tt-countdown-pop {
    animation: ttCountPop 0.5s ease-out;
}
.tt-countdown-label {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 16px;
}
@keyframes ttCountPop {
    0% { transform: scale(1.6); opacity: 0.3; }
    50% { transform: scale(0.95); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== PLAYING ===== */
.state-playing .tt-content { display: none; }

/* ===== PAUSE overlay ===== */
.tt-pause-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 35, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
}
.tt-pause-text {
    font-size: 28px;
    font-weight: 900;
    color: #60A5FA;
    margin-bottom: 20px;
}

/* ===== GAMEOVER overlay ===== */
.tt-gameover-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 35, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: ttFadeIn 0.3s ease;
}
@keyframes ttFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tt-gameover-text {
    font-size: 32px;
    font-weight: 900;
    color: #EF4444;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.tt-gameover-score {
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
}
.tt-gameover-score small { font-size: 18px; color: rgba(255,255,255,0.5); }

.tt-gameover-detail {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 24px;
}

.tt-btn-result {
    padding: 16px 48px;
    background: linear-gradient(135deg, #60A5FA, #3B82F6);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.tt-btn-result:active { transform: scale(0.95); }

/* ===== RESULT — 공통 game-result.css 사용 ===== */
.state-result .tt-play-area { display: none; }
.state-result .tt-controls { display: none !important; }
.state-result .tt-info-badge { display: none; }
.state-result .tt-content {
    justify-content: flex-start;
    padding-top: 20px;
}

/* Toast */
.tt-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.tt-toast-show {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .state-playing .tt-controls {
        display: flex;
    }
}

@media (max-width: 480px) {
    .tt-body { max-width: 100%; }
    .tt-game { max-width: 100%; }
    .tt-side-panel { min-width: 56px; }
    .tt-panel-value { font-size: 16px; }
    .tt-panel-label { font-size: 9px; }
    .tt-intro-title { font-size: 24px; }
    .tt-intro-emoji { font-size: 56px; }
    .tt-gameover-score { font-size: 40px; }
    .tt-ctrl-btn { width: 50px; height: 50px; font-size: 20px; }
    .tt-ctrl-wide { padding: 0 16px; font-size: 12px; }
    #ttNextCanvas { width: 50px; height: 50px; }
}

@media (max-width: 360px) {
    .tt-play-area { gap: 4px; padding: 0 4px; }
    .tt-side-panel { min-width: 48px; gap: 4px; }
    .tt-panel-box { padding: 6px; }
    .tt-panel-value { font-size: 14px; }
    .tt-ctrl-btn { width: 44px; height: 44px; font-size: 18px; border-radius: 10px; }
    .tt-controls { gap: 6px; padding: 8px 12px; }
}
