:root {
    --bg-gradient-start: #fff0f5; /* Lavender Blush */
    --bg-gradient-end: #ffc0cb;   /* Pink */
    --primary-color: #c2185b;     /* Deep Pink / Raspberry */
    --text-color: #444;
    --scratch-color: #d1d1d1;     /* Silver/Grey for scratch layer */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* 禁止滚动 */
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
}

/* 阶段控制 */
.stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* 默认隐藏 */
    opacity: 0;
    transition: opacity 1s ease-in-out;
    pointer-events: none; /* 隐藏时不阻挡点击 */
}

.stage.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* 第一阶段：画布 */
#stage-canvas {
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.hint-text {
    /* 原来的 .hint-container 样式整合进来 */
    position: absolute;
    top: 15%;
    width: 100%;
    z-index: 20;
    pointer-events: none;
    display: flex;
    justify-content: center;
    /* 移除之前的 font 样式，因为现在是容器 */
    transition: opacity 0.5s ease; /* 为了 JS 的淡出效果 */
}

.handwriting-svg {
    width: 90%;
    max-width: 500px;
    height: auto;
    overflow: visible;
}

.handwriting-text {
    font-family: 'Zhi Mang Xing', cursive, 'Dancing Script';
    font-size: 35px;
    fill: transparent;
    stroke: var(--primary-color);
    stroke-width: 1.5px;
    stroke-dasharray: 600; /* 调整为更合适的值 */
    stroke-dashoffset: 600;
}

/* 第一行文字动画 */
.handwriting-text.line-1 {
    animation: drawText 3s forwards ease-in-out, fillText 1s forwards 2.5s;
}

/* 第二行文字动画 */
.handwriting-text.line-2 {
    font-size: 28px;
    animation: drawText 4s forwards 1.5s ease-in-out, fillText 1s forwards 5s;
}

@keyframes drawText {
    to { stroke-dashoffset: 0; }
}

@keyframes fillText {
    to { fill: var(--primary-color); }
}

/* 爱心表情特殊处理 */
.emoji-heart {
    fill-opacity: 1;
    stroke: none;
    opacity: 0;
    /* tspan transform support is flaky, use opacity fade in */
    animation: heartFadeIn 1s ease-out forwards 5.2s;
}

@keyframes heartFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#drawingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none; /* 禁止触摸默认行为 */
    z-index: 10;
}

/* 第二阶段：心跳与烟花 */
#stage-heart {
    justify-content: center;
    align-items: center;
}

.heart-wrapper {
    width: 100px;
    height: 100px;
    animation: heartbeat 1.2s infinite;
    z-index: 20; /* 在烟花之上 */
}

.heart-shape {
    fill: #ff4081;
    filter: drop-shadow(0 0 10px rgba(255, 64, 129, 0.6));
    width: 100%;
    height: 100%;
}

#fireworksCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* 第三阶段：刮刮乐 */
#stage-reward {
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.3); /* 轻微遮罩 */
    backdrop-filter: blur(5px);
}

.scratch-card-container {
    width: 85%;
    max-width: 350px;
    text-align: center;
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(194, 24, 91, 0.2);
    position: relative;
    transform: translateY(20px);
    opacity: 0;
    animation: floatIn 1s forwards 0.5s;
}

.reward-title {
    font-family: 'Dancing Script', cursive;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.scratch-area {
    position: relative;
    width: 100%;
    /* height removed to allow content to dictate height */
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    border: 2px dashed #fce4ec;
}

.prize-content {
    position: relative; /* Changed from absolute */
    width: 100%;
    min-height: 180px; /* Minimum height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff8fb;
    z-index: 1; /* 在 Canvas 之下 */
    padding: 20px 10px; /* Add padding to prevent content touching edges */
}

.emoji {
    font-size: 3rem;
    margin-bottom: 10px;
}

#prize-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    padding: 0 15px;
    margin-bottom: 15px;
}

#claim-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0; /* 刮开后显示 */
    transform: scale(0.8);
    transition: all 0.3s ease;
}

#claim-btn.visible {
    opacity: 1;
    transform: scale(1);
}

#scratchCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2; /* 盖在奖品上 */
    cursor: grab;
}

.instruction {
    margin-top: 15px;
    font-size: 0.9rem;
    color: #888;
}

/* 动画定义 */
@keyframes pulseText {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
    60% { transform: scale(1); }
}

@keyframes floatIn {
    to { transform: translateY(0); opacity: 1; }
}

/* 移动端适配 */
@media (max-height: 600px) {
    .hint-text { font-size: 1.5rem; top: 15%; }
    .scratch-card-container { padding: 15px; }
    .prize-content { min-height: 150px; }
}

/* 进度条样式 */
.progress-container {
    position: absolute;
    bottom: 15%; /* 放在底部，避免遮挡爱心 */
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    overflow: hidden;
    z-index: 30; /* 在烟花之上 */
    opacity: 0; /* 初始隐藏 */
    transition: opacity 0.5s ease;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 0 10px rgba(194, 24, 91, 0.5);
}
