:root {
    --bg-color: #E2EFE3;
    --card-bg: #FFFFFF;
    --primary-green: #426B4D;
    --primary-green-hover: #34583E;
    --text-dark: #263B2B;
    --text-muted: #5C715F;
    --cube-bg: #F2F6F2;
    --cube-hover: #E1EBE2;
    --cube-active: #B8D0BC;
    --border-color: #C7D6C9;
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.05);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    font-family: var(--font-sans);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-root {
    width: 100%;
    max-width: 850px;
    height: 560px;
    background-color: var(--bg-color);
    position: relative;
    box-shadow: var(--shadow-subtle);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    padding: 24px;
}

.screen.active {
    display: flex;
}

/* 공통 버튼 */
.primary-btn {
    background-color: var(--primary-green);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: var(--primary-green-hover);
}

.secondary-btn {
    background-color: var(--card-bg);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

.secondary-btn:hover {
    background-color: var(--cube-bg);
}

/* 1. 메인 화면 */
.main-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    position: relative;
    padding-bottom: 64px;
}

.main-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.main-logo {
    display: block;
    width: min(400px, 82vw);
    max-height: 160px;
    object-fit: contain;
    margin: 0 auto 16px;
}

.main-subtitle {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.main-menu-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 300px;
}

.main-footer {
    position: absolute;
    bottom: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

/* 2. 게임 화면 */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-dark);
}

.score-indicator {
    font-size: 16px;
    font-weight: 700;
}

.game-stats {
    display: flex;
    align-items: center;
    gap: 18px;
}

.timer-indicator {
    min-width: 58px;
    color: var(--primary-green-hover);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    text-align: right;
}

.problem-card {
    background-color: var(--card-bg);
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--border-color);
}

.cube-workspace {
    display: flex;
    gap: 12px;
    flex: 1;
    margin-bottom: 12px;
    min-height: 0;
}

.cube-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 10px;
    flex: 1;
    background-color: rgba(255, 255, 255, 0.4);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.cube-cell {
    background-color: var(--card-bg);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.04);
}

.cube-cell:hover {
    background-color: var(--cube-hover);
}

.cube-cell.selected {
    background-color: var(--cube-active);
    color: var(--primary-green-hover);
}

.cube-cell.is-decoration {
    cursor: default;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: none;
}

.cube-cell.is-empty {
    background: rgba(226, 239, 227, 0.55);
    border-color: rgba(199, 214, 201, 0.7);
    box-shadow: none;
    cursor: default;
}

.cube-cell.is-empty:hover {
    background: rgba(226, 239, 227, 0.55);
}

.cube-cell.is-decoration:hover {
    background: rgba(255, 255, 255, 0.55);
}

.cube-decoration {
    width: 82%;
    height: 82%;
    object-fit: contain;
    opacity: 0.72;
    pointer-events: none;
}

.progress-bar-track {
    width: 10px;
    background-color: var(--card-bg);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
}

.progress-bar-fill {
    width: 100%;
    background-color: var(--primary-green);
    height: 100%;
    transition: height 0.8s linear;
}

.game-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.control-btn {
    background-color: var(--primary-green);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.text-link-btn {
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0 8px 8px;
    white-space: nowrap;
    text-decoration: underline;
}

.text-link-btn:hover {
    color: var(--primary-green-hover);
}

/* 3. 결과 화면 */
.result-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.confetti-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.confetti-piece {
    position: absolute;
    top: var(--confetti-top);
    left: var(--confetti-left);
    width: 8px;
    height: 12px;
    border-radius: 2px;
    background-color: var(--confetti-color);
    opacity: 0;
    animation: confetti-burst var(--confetti-duration) ease-out var(--confetti-delay) forwards;
}

@keyframes confetti-burst {
    0% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate3d(var(--confetti-drift), var(--confetti-drop), 0) rotate(760deg);
    }
}

.result-center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    position: relative;
    isolation: isolate;
}

.result-mascot {
    position: absolute;
    z-index: -1;
    width: min(465px, 112.5%);
    height: 127.5%;
    object-fit: contain;
    opacity: 0.13;
    pointer-events: none;
}

.result-label {
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 2px;
    text-transform: lowercase;
}

.result-score-value {
    font-size: 64px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-actions {
    display: flex;
    gap: 10px;
    width: min(240px, 100%);
}

.action-replay-btn,
.action-home-btn {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    padding: 10px 16px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.action-home-btn {
    background-color: var(--card-bg);
    color: var(--primary-green-hover);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 600px) {
    .game-bottom-bar {
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .confetti-piece {
        animation: none;
        display: none;
    }
}

.action-replay-btn {
    background-color: var(--primary-green);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.result-side-panels {
    position: absolute;
    right: 0;
    top: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-box {
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 110px;
}

.panel-title {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.panel-sub-btn {
    display: block;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 6px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: inherit;
}

.panel-sub-btn:hover {
    background-color: var(--cube-bg);
}

.result-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* 모달 */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 450px;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-message {
    position: absolute;
    right: 16px;
    bottom: 12px;
    color: var(--primary-green-hover);
    font-size: 12px;
}

.modal-body {
    font-size: 13px;
    line-height: 1.55;
    max-height: min(65vh, 420px);
    overflow-y: auto;
}

.guide-language + .guide-language {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.guide-language h4 {
    margin: 10px 0 4px;
    color: var(--primary-green-hover);
}

.guide-language p {
    margin-bottom: 8px;
}

.guide-language ul,
.guide-language ol {
    padding-left: 22px;
    margin-bottom: 8px;
}

.guide-language li {
    margin-bottom: 4px;
}