/* ============================================
   羊了个羊 - 浅色主题 + 无遮挡布局
   ============================================ */

:root {
    --bg: #F8F2EB;
    --card-bg: #FFFFFF;
    --accent: #7C3AED;
    --accent-light: rgba(124,58,237,0.08);
    --accent-border: rgba(124,58,237,0.2);
    --text: #2D1B69;
    --muted: #8B7FA8;
    --muted-light: #C8C0D8;
    --shadow: rgba(0,0,0,0.08);
    --radius: 12px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ===== 主容器 ===== */
.game-container {
    position: relative;
    width: 100%;
    max-width: 520px;
    height: 100vh;
    max-height: 860px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 8px;
    overflow: hidden;
}

/* ===== 顶栏 ===== */
.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 6px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
}

.game-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    gap: 8px;
}

.stat-box {
    background: var(--card-bg);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    padding: 3px 14px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-box.best {
    border-color: rgba(249,115,22,0.2);
}

.stat-label {
    display: block;
    font-size: 0.55rem;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #7C3AED, #3B82F6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-box.best .stat-value {
    background: linear-gradient(135deg, #F97316, #EF4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Canvas 容器 ===== */
.canvas-wrapper {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 2px 0;
}

canvas {
    display: block;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px var(--shadow), 0 0 0 1px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 480px;
    height: auto;
    background: #FDF9F4;
}

/* ===== 底部栏（存储槽 + 道具 + 提示） ===== */
.bottom-bar {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 4px 0 2px;
}

/* 存储槽行 */
.storage-row {
    width: 100%;
    display: flex;
    justify-content: center;
}

.storage-slots {
    display: flex;
    gap: 5px;
}

.storage-slot {
    width: 34px;
    height: 34px;
    background: var(--card-bg);
    border: 2px solid var(--accent-border);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.15s ease;
    box-shadow: 0 1px 4px var(--shadow);
}

.storage-slot.filled {
    border-color: var(--accent);
    animation: slotPop 0.25s ease;
}

.storage-slot.danger {
    border-color: #EF4444;
    animation: slotDanger 0.5s ease infinite;
}

@keyframes slotPop {
    0% { transform: scale(0.6); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes slotDanger {
    0%, 100% { border-color: rgba(239,68,68,0.4); }
    50% { border-color: rgba(239,68,68,0.8); }
}

/* 道具行 */
.props-row {
    display: flex;
    gap: 8px;
}

.prop-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    padding: 4px 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px var(--shadow);
    color: var(--text);
}

.prop-btn:active:not(.disabled) {
    transform: scale(0.93);
    background: var(--accent-light);
}

.prop-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: transparent;
    background: #F0EDF2;
}

.prop-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.prop-count {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 8px;
    padding: 0 6px;
    line-height: 14px;
}

.prop-btn.disabled .prop-count {
    color: var(--muted);
    background: transparent;
}

/* 提示文字 */
.instructions {
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 0.3px;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* ===== 层指示器 ===== */
.layer-indicator {
    position: absolute;
    top: 42px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 5;
}

.layer-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted-light);
    border: 1px solid rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

.layer-dot.active {
    background: var(--accent);
    box-shadow: 0 0 5px rgba(124,58,237,0.4);
    transform: scale(1.3);
}

/* ===== 游戏结束浮层 ===== */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,248,240,0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-over-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.game-over-title {
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #F97316, #EF4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%,100% { transform:translateX(0) }
    20% { transform:translateX(-5px) }
    40% { transform:translateX(5px) }
    60% { transform:translateX(-3px) }
    80% { transform:translateX(3px) }
}

.game-over-score {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 3px;
    text-align: center;
}

.game-over-score .final {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    display: block;
}

.game-over-stats {
    font-size: 0.75rem;
    color: var(--muted);
}
.game-over-stats span { color: #22C55E; font-weight: 700; }

.restart-btn {
    margin-top: 18px;
    padding: 10px 36px;
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    background: linear-gradient(135deg, #7C3AED, #3B82F6);
    color: white;
    transition: all 0.25s ease;
    box-shadow: 0 6px 20px rgba(124,58,237,0.3);
}

.restart-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(124,58,237,0.35);
}

.restart-btn:active {
    transform: translateY(0);
}

/* ===== 竖屏手机适配 ===== */
@media (max-width: 420px) and (orientation: portrait) {
    .game-container { padding: 4px 4px; max-height: 100vh; }
    .game-title { font-size: 0.8rem; }
    .stat-value { font-size: 0.9rem; }
    .stat-box { padding: 2px 8px; }
    .storage-slot { width: 28px; height: 28px; font-size: 0.8rem; }
    .prop-btn { padding: 3px 8px; }
    .prop-icon { font-size: 0.85rem; }
    .prop-count { font-size: 0.6rem; }
    .instructions { font-size: 0.6rem; }
    canvas { max-width: 100%; }
    .game-over-title { font-size: 1.4rem; }
    .game-over-score .final { font-size: 1.5rem; }
    .restart-btn { padding: 8px 28px; font-size: 0.85rem; }
}

/* ===== 更小屏竖屏适配 ===== */
@media (max-width: 360px) and (orientation: portrait) {
    .storage-slot { width: 24px; height: 24px; font-size: 0.7rem; }
    .storage-slots { gap: 3px; }
    .prop-btn { padding: 2px 6px; }
    .prop-icon { font-size: 0.75rem; }
}

/* ===== 横屏手机适配 ===== */
@media (max-width: 900px) and (orientation: landscape) {
    .game-container {
        max-width: 100%;
        max-height: 100vh;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 4px 6px;
        gap: 4px;
        justify-content: center;
        align-content: center;
    }
    .game-header {
        width: 100%;
        padding: 2px 0 4px;
        flex-shrink: 0;
    }
    .game-title { font-size: 0.8rem; }
    .stat-value { font-size: 0.85rem; }
    .stat-box { padding: 2px 8px; }
    .canvas-wrapper {
        flex: 1;
        min-height: 0;
        max-height: 70vh;
        padding: 0;
    }
    canvas {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
    }
    .bottom-bar {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        padding: 2px 4px;
        width: auto;
        flex-shrink: 0;
    }
    .storage-row { width: auto; }
    .storage-slots { gap: 3px; }
    .storage-slot { width: 24px; height: 24px; font-size: 0.7rem; border-radius: 6px; }
    .props-row { gap: 4px; }
    .prop-btn { padding: 2px 6px; border-radius: 7px; }
    .prop-icon { font-size: 0.75rem; }
    .prop-count { font-size: 0.55rem; }
    .instructions { display: none !important; }
    .layer-indicator {
        top: auto;
        bottom: 4px;
        right: 6px;
        flex-direction: row;
    }
    .layer-dot { width: 5px; height: 5px; }
    .game-over-title { font-size: 1.3rem; }
    .game-over-score .final { font-size: 1.4rem; }
    .restart-btn { padding: 7px 24px; font-size: 0.8rem; }
}
