/* =============================================
   피아노 타일 게임 스타일
   ============================================= */

html { background: #000; }

body {
    overflow: hidden;
    height: 100dvh;
    max-width: 480px;
    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 */
.pt-game {
    width: 100%;
    height: 100dvh;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Top Bar */
.pt-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    flex-shrink: 0;
}
.pt-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);
}
.pt-back:hover { color: #fff; }
.pt-info-badge {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
}

/* Content */
.pt-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    overflow-y: auto;
}

/* ===== States ===== */

/* Intro */
.state-intro { background: #0f0f1a; }
.state-intro .pt-content {
    justify-content: flex-start;
    padding-top: 40px;
}

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

.pt-intro-keys {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.8;
    text-align: center;
    margin-bottom: 20px;
}
.pt-intro-keys kbd {
    display: inline-block;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: inherit;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.pt-best {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.pt-btn-start {
    display: inline-block;
    padding: 16px 48px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
    margin-top: 8px;
}
.pt-btn-start:active { transform: scale(0.95); }

/* Countdown */
.state-countdown { background: #0f0f1a; }
.state-countdown .pt-content {
    justify-content: center;
    padding: 0;
}
.pt-countdown-wrap {
    text-align: center;
}
.pt-countdown-num {
    font-size: 120px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    animation: ptCountPop 0.5s ease-out;
}
.pt-countdown-num.pt-countdown-pop {
    animation: ptCountPop 0.5s ease-out;
}
.pt-countdown-label {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 16px;
}
@keyframes ptCountPop {
    0% { transform: scale(1.6); opacity: 0.3; }
    50% { transform: scale(0.95); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Playing */
.state-playing { background: #0a0a12; }
.state-playing .pt-content {
    justify-content: flex-start;
    padding: 0;
    overflow: hidden;
}

.pt-play-field {
    width: 100%;
    position: relative;
    overflow: hidden;
}

.pt-row {
    position: absolute;
    left: 0;
    width: 100%;
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pt-tile {
    flex: 1;
    height: 100%;
    cursor: pointer;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    transition: none;
}
.pt-tile:last-child {
    border-right: none;
}

.pt-tile-white {
    background: #0d0d1a;
}
.pt-tile-black {
    background: #ffffff;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}
.pt-tile-tapped {
    background: #3a3a5a;
    box-shadow: none;
}
.pt-tile-miss {
    background: #ef4444 !important;
    box-shadow: none !important;
}

/* Key hint labels on tiles */
.pt-key-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
}
.pt-tile-black .pt-key-hint {
    color: rgba(0, 0, 0, 0.25);
}

/* Game Over flash */
.pt-gameover-flash {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(239, 68, 68, 0.3);
    z-index: 20;
    pointer-events: none;
    animation: ptFlash 0.4s ease-out forwards;
}
@keyframes ptFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Result */
.state-result { background: #0f0f1a; }
.state-result .pt-content {
    justify-content: flex-start;
    padding-top: 32px;
    overflow-y: auto;
}

.pt-result-badge {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.pt-result-emoji { font-size: 40px; }
.pt-result-grade {
    font-size: 28px;
    font-weight: 900;
    margin-top: 2px;
}
.pt-result-label {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}
.pt-result-pct {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.pt-result-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    justify-content: center;
}
.pt-stat {
    text-align: center;
}
.pt-stat-val {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
}
.pt-stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.pt-new-record {
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.pt-gameover-reason {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 16px;
}

/* Buttons */
.pt-result-btns {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}
.pt-btn-share, .pt-btn-retry {
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.pt-btn-share:active, .pt-btn-retry:active { transform: scale(0.95); }

.pt-btn-share {
    padding: 16px 32px;
    background: #FEE500;
    color: #191919;
    font-size: 17px;
    box-shadow: 0 4px 16px rgba(254, 229, 0, 0.3);
    flex: 1;
    min-width: 160px;
    border-radius: 12px;
}
.pt-btn-retry {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Ranking */
.pt-ranking-section {
    width: 100%;
    max-width: 360px;
    padding-bottom: 40px;
}
.pt-ranking-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    text-align: center;
}
.pt-rankings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pt-rank-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    font-size: 13px;
}
.pt-rank-pos {
    width: 28px;
    text-align: center;
    font-weight: 700;
}
.pt-rank-name {
    flex: 1;
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pt-rank-grade {
    font-size: 12px;
    font-weight: 600;
}
.pt-rank-score {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    min-width: 48px;
    text-align: right;
}
.pt-no-ranking {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    padding: 16px;
}

/* Toast */
.pt-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;
}
.pt-toast-show {
    opacity: 1;
    pointer-events: auto;
}
