/* =============================================
   스도쿠 게임 스타일
   테마: 다크 (#0f0f23) + 블루/퍼플 액센트
   ============================================= */

html { background: #0f0f23; }

.sd-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 */
.sd-game {
    width: 100%;
    height: 100dvh;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0f0f23;
}

/* Top Bar */
.sd-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    flex-shrink: 0;
}
.sd-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);
}
.sd-back:hover { color: #fff; }

.sd-info {
    display: flex;
    gap: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

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

/* ===== Intro ===== */
.state-intro .sd-content {
    justify-content: flex-start;
    padding-top: 32px;
}

.sd-intro-emoji { font-size: 72px; margin-bottom: 16px; }
.sd-intro-title {
    font-size: 36px;
    font-weight: 900;
    color: #818cf8;
    margin-bottom: 8px;
    letter-spacing: 2px;
}
.sd-intro-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
}
.sd-intro-desc strong { color: #818cf8; }

.sd-intro-features {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}
.sd-intro-features span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sd-difficulty-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 300px;
}
.sd-btn-diff {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 14px;
    color: #f0f0f0;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}
.sd-btn-diff:active { transform: scale(0.97); }
.sd-btn-diff:hover { background: rgba(129, 140, 248, 0.2); }
.sd-btn-diff .sd-diff-label { color: #818cf8; }
.sd-btn-diff .sd-diff-info {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
}

/* ===== Playing ===== */
.state-playing .sd-content {
    justify-content: flex-start;
    padding-top: 4px;
}

/* Difficulty label */
.sd-diff-display {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 6px;
}

/* Board */
.sd-board-wrapper {
    position: relative;
    width: 100%;
    max-width: 380px;
}

.sd-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    background: #1a1a3e;
    padding: 2px;
    border-radius: 8px;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid rgba(129, 140, 248, 0.3);
}

.sd-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e1e3a;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    border: 0.5px solid rgba(255, 255, 255, 0.06);
}

/* 3x3 box borders */
.sd-cell.sd-border-right { border-right: 2px solid rgba(129, 140, 248, 0.35); }
.sd-cell.sd-border-bottom { border-bottom: 2px solid rgba(129, 140, 248, 0.35); }

/* Given (original) numbers */
.sd-cell.sd-given {
    color: rgba(255, 255, 255, 0.85);
    cursor: default;
}

/* User-filled numbers */
.sd-cell.sd-filled {
    color: #818cf8;
}

/* Wrong number */
.sd-cell.sd-wrong {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Selected cell */
.sd-cell.sd-selected {
    background: rgba(129, 140, 248, 0.25);
}

/* Same number highlight */
.sd-cell.sd-same-num {
    background: rgba(129, 140, 248, 0.12);
}

/* Same row/col/box highlight */
.sd-cell.sd-related {
    background: rgba(255, 255, 255, 0.04);
}

/* Notes (memo) */
.sd-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}
.sd-note {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 500;
    color: rgba(129, 140, 248, 0.6);
    line-height: 1;
}

/* Controls */
.sd-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 380px;
    margin-top: 10px;
}

.sd-numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
}
.sd-num-btn {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 8px;
    color: #f0f0f0;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
}
.sd-num-btn:active { transform: scale(0.9); }
.sd-num-btn:hover { background: rgba(129, 140, 248, 0.2); }
.sd-num-btn.sd-num-done {
    opacity: 0.25;
    pointer-events: none;
}

.sd-action-btns {
    display: flex;
    gap: 6px;
}
.sd-action-btn {
    flex: 1;
    padding: 10px 0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
    text-align: center;
}
.sd-action-btn:active { transform: scale(0.95); }
.sd-action-btn:hover { background: rgba(255, 255, 255, 0.1); }
.sd-action-btn.sd-memo-active {
    background: rgba(129, 140, 248, 0.2);
    border-color: rgba(129, 140, 248, 0.4);
    color: #818cf8;
}
.sd-action-btn.sd-hint-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ===== Result ===== */
.state-result .sd-content {
    justify-content: flex-start;
    padding-top: 24px;
}

.sd-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;
    background: rgba(129, 140, 248, 0.08);
}
.sd-result-emoji { font-size: 40px; }
.sd-result-grade {
    font-size: 28px;
    font-weight: 900;
    margin-top: 2px;
}
.sd-result-label {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

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

.sd-result-detail {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

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

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

/* Gameover */
.state-gameover .sd-content {
    justify-content: flex-start;
    padding-top: 24px;
}

.sd-gameover-emoji { font-size: 64px; margin-bottom: 12px; }
.sd-gameover-title {
    font-size: 28px;
    font-weight: 900;
    color: #ef4444;
    margin-bottom: 8px;
}
.sd-gameover-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    text-align: center;
}
.sd-gameover-btns {
    display: flex;
    gap: 12px;
}
.sd-btn-gameover {
    padding: 16px 32px;
    background: linear-gradient(135deg, #818cf8, #6366f1);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.sd-btn-gameover:active { transform: scale(0.95); }

/* Ranking */
.sd-ranking-section {
    width: 100%;
    max-width: 380px;
    padding-bottom: 40px;
}
.sd-ranking-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    text-align: center;
}
.sd-ranking-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    justify-content: center;
}
.sd-rank-tab {
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.sd-rank-tab:hover { background: rgba(255, 255, 255, 0.1); }
.sd-rank-tab.sd-tab-active {
    background: rgba(129, 140, 248, 0.2);
    border-color: rgba(129, 140, 248, 0.4);
    color: #818cf8;
}
.sd-ranking-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.sd-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;
}
.sd-nickname-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.sd-nickname-input:focus { border-color: rgba(129, 140, 248, 0.5); }

.sd-btn-submit {
    padding: 10px 20px;
    background: #818cf8;
    color: #fff;
    font-size: 14px;
    border-radius: 10px;
}

.sd-rankings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sd-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;
}
.sd-rank-pos {
    width: 28px;
    text-align: center;
    font-weight: 700;
}
.sd-rank-name {
    flex: 1;
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sd-rank-grade {
    font-size: 12px;
    font-weight: 700;
    color: #818cf8;
}
.sd-rank-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    min-width: 50px;
    text-align: right;
}
.sd-no-ranking {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    padding: 16px;
}

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

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .sd-cell { font-size: 17px; }
    .sd-num-btn { font-size: 18px; }
    .sd-note { font-size: 8px; }
}

@media (max-width: 360px) {
    .sd-cell { font-size: 14px; }
    .sd-num-btn { font-size: 16px; border-radius: 6px; }
    .sd-note { font-size: 7px; }
    .sd-action-btn { font-size: 12px; padding: 8px 0; }
    .sd-board { border-radius: 6px; }
}

@media (min-height: 800px) {
    .state-playing .sd-content {
        padding-top: 8px;
    }
    .sd-controls {
        margin-top: 14px;
    }
}
