/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
    background: #f5f5f5;
    color: #333;
    -webkit-tap-highlight-color: transparent;
}

/* ==================== Page System ==================== */
.page {
    display: none;
    min-height: 100dvh;
    width: 100%;
}

.page.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease;
}

.page-inner {
    width: 100%;
    max-width: 420px;
    padding: 24px 20px;
    margin: 0 auto;
}

.center-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==================== Loading 頁 ==================== */
.loading-container {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    color: #888;
}

/* ==================== 填資料頁 ==================== */
.logo-area {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 12px;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

.logo-area h1 {
    font-size: 28px;
    color: #ff6b35;
    font-weight: 800;
}

.subtitle {
    font-size: 14px;
    color: #888;
    margin-top: 6px;
}

.form-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-group input:focus {
    border-color: #ff6b35;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #ff6b35, #ff4500);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    margin-top: 8px;
}

.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(255,107,53,0.4);
}

/* ==================== 刮刮樂頁 ==================== */
#page-scratch h1 {
    text-align: center;
    color: #ff6b35;
    font-size: 24px;
    margin-bottom: 4px;
}

#page-scratch .subtitle {
    text-align: center;
    margin-bottom: 20px;
}

.scratch-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-width: 360px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    background: #fff;
}

.scratch-hidden-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #ff6b35;
    text-align: center;
    padding: 20px;
    line-height: 1.5;
    z-index: 1;
}

#scratch-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    touch-action: none;
    cursor: crosshair;
}

.scratch-hint {
    text-align: center;
    font-size: 13px;
    color: #aaa;
    margin-top: 16px;
}

/* ==================== 中獎頁 ==================== */
#page-prize {
    background: linear-gradient(180deg, #fff8f0, #fff);
    position: relative;
    overflow: hidden;
}

.prize-title {
    text-align: center;
    font-size: 26px;
    color: #ff6b35;
    margin-bottom: 20px;
    animation: prizePopIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes prizePopIn {
    0%   { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.prize-image-container {
    width: 180px;
    height: 180px;
    margin: 0 auto 16px;
    border-radius: 20px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    animation: prizePopIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}

.prize-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prize-name {
    text-align: center;
    font-size: 22px;
    color: #333;
    margin-bottom: 20px;
    animation: prizePopIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s both;
}

.barcode-container {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
    animation: prizePopIn 0.5s ease 0.4s both;
}

.barcode-container svg {
    width: 100%;
    max-width: 280px;
    height: auto;
}

.barcode-number {
    font-size: 14px;
    color: #666;
    font-family: monospace;
    letter-spacing: 2px;
    margin-top: 8px;
}

.redeem-info {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 16px;
}

.redeem-info h3 {
    font-size: 16px;
    color: #ff6b35;
    margin-bottom: 12px;
}

.redeem-info ul {
    list-style: none;
    padding: 0;
}

.redeem-info li {
    font-size: 13px;
    color: #666;
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
}

.redeem-info li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #ff6b35;
}

.screenshot-hint {
    text-align: center;
    font-size: 13px;
    color: #aaa;
    padding-bottom: 20px;
}

/* ==================== 已參加過 / 錯誤頁 ==================== */
.used-icon {
    font-size: 72px;
    margin-bottom: 20px;
}

#page-used h1,
#page-error h1 {
    font-size: 22px;
    color: #333;
    margin-bottom: 12px;
}

.used-desc {
    font-size: 15px;
    color: #888;
    line-height: 1.6;
}

.used-info {
    margin-top: 24px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    text-align: left;
    width: 100%;
    max-width: 300px;
}

.used-info p {
    font-size: 14px;
    color: #666;
    padding: 4px 0;
}

.used-info strong {
    color: #333;
}

/* ==================== Confetti 動畫 ==================== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
    0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ==================== 銘謝惠顧特殊樣式 ==================== */
.no-prize .prize-title {
    color: #888;
}

/* ==================== 語言切換按鈕 ==================== */
.lang-switcher {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    gap: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    overflow: hidden;
}

.lang-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: #fff;
    color: #888;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.lang-btn.active {
    background: #ff6b35;
    color: #fff;
}

.lang-btn:not(.active):hover {
    background: #f5f5f5;
}

/* ==================== 清除紀錄按鈕 ==================== */
.btn-reset {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    background: #fff;
    border: 1px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: color 0.2s, border-color 0.2s;
}

.btn-reset:hover {
    color: #e74c3c;
    border-color: #e74c3c;
}

.btn-reset:active {
    background: #fef2f2;
}
