/* =============================================
   워들(Wordle) 게임 스타일
   테마: 다크 (#0f0f23) + 초록/노랑/회색 피드백
   ============================================= */

html { background: #0f0f23; }

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

/* Top Bar */
.wd-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.wd-back {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}
.wd-back:hover { color: #fff; }
.wd-title {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #fff;
}

/* Content */
.wd-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

/* ===== INTRO STATE ===== */
.state-intro { background: #0f0f23; }
.state-intro .wd-content {
    justify-content: center;
    padding: 24px;
}

.wd-intro-emoji { font-size: 64px; margin-bottom: 16px; }
.wd-intro-title {
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    letter-spacing: 6px;
    margin-bottom: 12px;
}
.wd-intro-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.7;
    margin-bottom: 20px;
    text-align: center;
}
.wd-intro-desc strong { color: #6AAA64; }

.wd-intro-examples {
    width: 100%;
    max-width: 320px;
    margin-bottom: 24px;
}
.wd-example-row {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}
.wd-example-tile {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    border-radius: 4px;
    background: #3a3a5c;
    color: #fff;
}
.wd-example-tile.ex-correct { background: #6AAA64; }
.wd-example-tile.ex-present { background: #C9B458; }
.wd-example-tile.ex-absent { background: #787C7E; }
.wd-example-hint {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
    margin-bottom: 10px;
    padding-left: 4px;
}

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

/* ===== PLAYING STATE ===== */
.state-playing { background: #0f0f23; }
.state-playing .wd-content {
    justify-content: space-between;
    padding: 8px 16px 8px;
}

/* Board */
.wd-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    width: 100%;
    max-width: 330px;
    margin: 0 auto;
    padding: 8px 0;
}
.wd-tile {
    width: 100%;
    aspect-ratio: 1;
    max-width: 62px;
    max-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    border: 2px solid #3a3a5c;
    border-radius: 4px;
    box-sizing: border-box;
    text-transform: uppercase;
    transition: border-color 0.1s;
}
.wd-tile-filled {
    border-color: #565682;
    animation: wdPop 0.1s ease;
}
@keyframes wdPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.wd-tile-correct {
    background: #6AAA64;
    border-color: #6AAA64;
}
.wd-tile-present {
    background: #C9B458;
    border-color: #C9B458;
}
.wd-tile-absent {
    background: #787C7E;
    border-color: #787C7E;
}

/* Flip animation */
.wd-tile-flip {
    animation: wdFlip 0.5s ease forwards;
}
@keyframes wdFlip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

/* Row shake for invalid word */
.wd-row-shake {
    animation: wdShake 0.3s ease;
}
@keyframes wdShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* Row bounce for correct guess */
.wd-tile-bounce {
    animation: wdBounce 0.4s ease;
}
@keyframes wdBounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    60% { transform: translateY(-8px); }
}

/* Keyboard */
.wd-keyboard {
    width: 100%;
    max-width: 500px;
    padding: 0 4px 8px;
    flex-shrink: 0;
}
.wd-kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
}
.wd-key {
    min-width: 30px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #818384;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex: 1;
    max-width: 44px;
    text-transform: uppercase;
    transition: background-color 0.1s, transform 0.05s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.wd-key:active { transform: scale(0.95); }
.wd-key-wide {
    min-width: 56px;
    max-width: 65px;
    font-size: 12px;
}

.wd-key-correct {
    background: #6AAA64;
    color: #fff;
}
.wd-key-present {
    background: #C9B458;
    color: #fff;
}
.wd-key-absent {
    background: #3a3a3c;
    color: rgba(255, 255, 255, 0.6);
}

/* ===== WON / LOST STATE ===== */
.state-won { background: #0f0f23; }
.state-lost { background: #0f0f23; }
.state-result { background: #0f0f23; }
.state-won .wd-content,
.state-lost .wd-content,
.state-result .wd-content {
    justify-content: flex-start;
    padding-top: 16px;
}

/* Result */
.wd-result-badge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    background: rgba(106, 170, 100, 0.08);
}
.wd-result-emoji { font-size: 36px; }
.wd-result-grade {
    font-size: 14px;
    font-weight: 800;
    margin-top: 2px;
}
.wd-result-label {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}
.wd-result-sublabel {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
}

.wd-result-answer {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 16px;
}
.wd-result-answer strong {
    color: #6AAA64;
    font-size: 20px;
    letter-spacing: 3px;
}

/* Stats */
.wd-result-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}
.wd-stat { text-align: center; }
.wd-stat-val {
    display: block;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
}
.wd-stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

/* Tile pattern preview */
.wd-result-pattern {
    margin-bottom: 16px;
    text-align: center;
}
.wd-pattern-row {
    font-size: 22px;
    letter-spacing: 2px;
    line-height: 1.4;
}

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

.wd-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;
}
.wd-btn-retry {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Ranking */
.wd-ranking-section {
    width: 100%;
    max-width: 360px;
    padding-bottom: 40px;
}
.wd-ranking-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    text-align: center;
}
.wd-ranking-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.wd-nickname-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.wd-nickname-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.wd-nickname-input:focus { border-color: rgba(106, 170, 100, 0.5); }

.wd-btn-submit {
    padding: 10px 20px;
    background: #6AAA64;
    color: #fff;
    font-size: 14px;
    border-radius: 10px;
}

.wd-rankings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.wd-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;
}
.wd-rank-pos {
    width: 28px;
    text-align: center;
    font-weight: 700;
}
.wd-rank-name {
    flex: 1;
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wd-rank-attempts {
    color: #6AAA64;
    font-size: 14px;
    font-weight: 700;
}
.wd-no-ranking {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    padding: 16px;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .wd-board {
        max-width: 280px;
        gap: 4px;
    }
    .wd-tile {
        max-width: 52px;
        max-height: 52px;
        font-size: 24px;
    }
    .wd-key {
        height: 46px;
        font-size: 12px;
        min-width: 26px;
    }
    .wd-key-wide {
        min-width: 48px;
        max-width: 56px;
        font-size: 11px;
    }
    .wd-intro-title { font-size: 24px; }
}

@media (max-height: 640px) {
    .wd-board {
        max-width: 260px;
        gap: 3px;
    }
    .wd-tile {
        max-width: 46px;
        max-height: 46px;
        font-size: 22px;
    }
    .wd-key {
        height: 40px;
    }
    .wd-keyboard {
        padding-bottom: 4px;
    }
}
