:root {
    --bg: #f4efe6;
    --card: rgba(255, 251, 243, 0.82);
    --border: rgba(82, 66, 49, 0.24);
    --text: #3f2f1f;
    --muted: #6b5945;
    --accent: #3d76c5;
    --success: #34d399;
    --danger: #d46a79;
    --blur: 8px;
    --radius: 14px;
    --shadow: 0 12px 26px rgba(66, 47, 26, 0.18);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe Print", "Comic Sans MS", "Microsoft YaHei", sans-serif;
    background: radial-gradient(circle at 8% 12%, rgba(255, 229, 177, 0.4), transparent 36%),
                radial-gradient(circle at 88% 0%, rgba(210, 225, 255, 0.35), transparent 40%),
                var(--bg);
    color: var(--text);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#game-container {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    overflow: hidden;
}

#game-canvas {
    position: fixed;
    inset: 0;
    z-index: 4; /* 让 3D 火柴位于面板之上 */
    pointer-events: none; /* 不阻塞按钮输入 */
    width: 100%;
    height: 100%;
    display: block;
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.05), transparent 45%),
                rgba(0,0,0,0.06);
}

#game-ui {
    position: relative;
    z-index: 3;
    max-width: 980px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(var(--blur));
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow);
}

.game-header h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0.5px;
}

.game-header .stats {
    display: flex;
    gap: 12px;
    color: var(--muted);
    font-weight: 600;
    align-items: center;
}

#lang-toggle-game {
    padding: 4px 10px;
    min-width: 46px;
    line-height: 1.1;
}

#puzzle-container {
    position: relative;
    transform-style: preserve-3d;
    background:
        radial-gradient(circle at 20% 15%, rgba(255,255,255,0.5), transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(120,120,120,0.08), transparent 45%),
        repeating-linear-gradient(
            0deg,
            rgba(90,90,90,0.022) 0px,
            rgba(90,90,90,0.022) 1px,
            rgba(255,255,255,0.0) 1px,
            rgba(255,255,255,0.0) 5px
        ),
        #fbfcff;
    border: 1px solid rgba(150, 150, 150, 0.45);
    border-radius: 8px;
    padding: 18px;
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.28),
        0 12px 30px rgba(0,0,0,0.22),
        0 0 0 1px rgba(87, 56, 20, 0.12);
    color: #363636;
}

#puzzle-container.is-flipping {
    animation: paperFlip 0.86s cubic-bezier(0.45, 0.02, 0.2, 0.98);
}

@keyframes paperFlip {
    0% { transform: perspective(1200px) rotateY(0deg); filter: brightness(1); }
    40% { transform: perspective(1200px) rotateY(-88deg); filter: brightness(0.9); }
    58% { transform: perspective(1200px) rotateY(94deg); filter: brightness(1.05); }
    100% { transform: perspective(1200px) rotateY(0deg); filter: brightness(1); }
}

#paper-doodles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    mix-blend-mode: multiply;
    opacity: 0.92;
}

#equation-display {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 2;
    background: transparent;
    padding-left: 8px;
}

.puzzle-info {
    position: relative;
    z-index: 2;
    margin-bottom: 8px;
    font-family: "Segoe Print", "Microsoft YaHei", sans-serif;
    color: #3f3f3f;
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}

.puzzle-options {
    margin-top: 8px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}

.puzzle-options label {
    font-size: 13px;
    color: #3f3f3f;
}

.puzzle-options select {
    margin-left: 4px;
    border: 1px solid rgba(106, 82, 60, 0.42);
    background: rgba(255, 254, 249, 0.95);
    color: #4b3a28;
    border-radius: 8px;
    padding: 5px 8px;
}

#puzzle-instruction {
    margin: 0;
}

#answer-section {
    backdrop-filter: blur(var(--blur));
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    box-shadow: var(--shadow);
}

.input-group {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    align-items: center;
}

.answer-row {
    flex-wrap: nowrap;
}

.answer-label {
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
}

#hint-section {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

#hint-text {
    margin: 6px 0 0 0;
    color: var(--muted);
    font-size: 14px;
}

.input-group input {
    flex: 0 0 280px;
    max-width: 38vw;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid rgba(106, 82, 60, 0.36);
    background: rgba(255, 255, 255, 0.72);
    color: #3f2f1f;
    font-size: 14px;
}

.btn-primary, .btn-secondary {
    border: 1px solid rgba(82, 66, 49, 0.25);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
    cursor: pointer;
    color: #fffef7;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    font-family: "Segoe Print", "Microsoft YaHei", sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, #3e7dce, #4d65c8);
    box-shadow: 0 6px 18px rgba(60, 85, 160, 0.28);
}

.btn-secondary {
    background: rgba(117, 92, 63, 0.72);
    border: 1px solid rgba(94, 67, 45, 0.32);
}

.btn-primary:active, .btn-secondary:active { transform: translateY(1px); }

.controls {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
}

.feedback {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 600;
    background: rgba(255,255,255,0.55);
    border: 1px solid var(--border);
}

.feedback.success { border-color: rgba(52,211,153,0.6); color: var(--success); }
.feedback.error { border-color: rgba(212,106,121,0.6); color: var(--danger); }
.hidden { display: none; }

@media (max-width: 720px) {
    #game-ui { padding: 14px; }
    .input-group { flex-wrap: wrap; }
    .input-group input { flex: 1 1 200px; max-width: 100%; }
    .answer-label { width: 100%; }
}
