@import url('https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
    --site-header-height: 90px;
    --bg-dark: #f8fafc;
    --bg-river: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --gold: #f59e0b;
    --gold-glow: #fbbf24;
    --gold-dark: #b45309;
    --eco-green: #059669;
    --eco-green-dark: #047857;
    --river-blue: #0284c7;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border-gold: rgba(245, 158, 11, 0.4);
    --border-subtle: #e2e8f0;
    --candle-glow: rgba(245, 158, 11, 0.35);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.07);
}

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

body {
    font-family: 'Prompt', 'Kanit', sans-serif;
    background: radial-gradient(circle at 50% 12%, #ffffff 0%, #f1f5f9 55%, #e2e8f0 100%);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Background ambient subtle glow */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(1.5px 1.5px at 150px 180px, #f59e0b, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 450px 240px, #059669, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 750px 320px, #f59e0b, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 1100px 80px, #0284c7, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 1200px 600px;
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
}

.main-wrapper {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(14px);
    border-bottom: 2px solid var(--gold);
    padding: 0.9rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(245, 158, 11, 0.25);
    background: #ffffff;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    display: block;
}

.brand-text h1 {
    font-family: 'Kanit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, #b45309, #d97706, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.brand-text p {
    font-size: 0.85rem;
    color: #059669;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-text p .badge-eco {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* Step Bar */
.steps-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    color: #64748b;
    transition: all 0.3s ease;
}

.step-item.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #f59e0b;
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.step-item.completed {
    background: #ecfdf5;
    border-color: #10b981;
    color: #047857;
}

.step-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
}

.step-item.active .step-number {
    background: #ffffff;
    color: #b45309;
}

.step-item.completed .step-number {
    background: #10b981;
    color: #fff;
}

.step-divider {
    color: #cbd5e1;
    font-size: 0.8rem;
}

/* Main Container */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Content Grid for Step 1 & 2 */
.builder-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 860px) {
    .builder-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Styling */
.custom-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-gold);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.custom-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.card-title {
    font-family: 'Kanit', sans-serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.8rem;
    line-height: 1.5;
}

/* Form Controls */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: #0f172a;
    margin-bottom: 0.6rem;
    letter-spacing: 0.3px;
}

.form-select, .form-input, .form-textarea {
    width: 100%;
    padding: 0.9rem 1.2rem;
    font-family: 'Prompt', sans-serif;
    font-size: 1.05rem;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    color: #0f172a;
    outline: none;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-select:hover, .form-input:hover, .form-textarea:hover {
    border-color: #f59e0b;
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
    background: #ffffff;
}

.form-select option {
    background: #ffffff;
    color: #0f172a;
    padding: 12px;
}

/* Info pill / description under dropdown */
.item-info-box {
    margin-top: 1rem;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    font-size: 0.9rem;
    color: #334155;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.item-info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.item-info-text strong {
    color: #b45309;
    display: block;
    margin-bottom: 0.2rem;
}

/* Selected Summary Badge */
.selected-badge-box {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.selected-badge-title {
    font-size: 0.85rem;
    color: #64748b;
}

.selected-badge-val {
    font-size: 1.05rem;
    font-weight: 600;
    color: #059669;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 1rem 1.5rem;
    font-family: 'Kanit', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.45);
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    font-family: 'Prompt', sans-serif;
    font-size: 0.95rem;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* 3D Canvas Preview Window */
.preview-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 1rem 1.2rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-badge-3d {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

.canvas-container {
    width: 100%;
    height: 380px;
    position: relative;
    background: radial-gradient(circle at 50% 35%, #ffffff 0%, #f1f5f9 60%, #e2e8f0 100%);
    cursor: grab;
    border-radius: 0 0 20px 20px;
    overflow: hidden;
}

.canvas-container:active {
    cursor: grabbing;
}

.canvas-tip {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 5px 16px;
    font-size: 0.78rem;
    color: #ffffff;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Page 3: Floating Scene - ภาพพื้นหลังวัดในจังหวัดอุบลราชธานี */
.loy-fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    z-index: 10;
    background-color: #0a1526;
    background-image: url('../images/ubon_temple_bg.svg');
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
}

#river-canvas, #river-canvas-demo {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 1;
}

/* ========================================================
   Page 3: Wish Card Overlay (กล่องตั้งจิตอธิษฐาน Responsive)
   ======================================================== */
.wish-card-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 460px;
    width: min(92vw, 460px);
    max-height: min(88vh, 700px);
    max-height: min(88dvh, 700px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 2px solid var(--gold);
    border-radius: 22px;
    padding: 1.6rem 1.8rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 0 35px rgba(244, 196, 48, 0.35);
    z-index: 25;
    transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #0f172a;
}

/* Custom Sleek Scrollbar */
.wish-card-overlay::-webkit-scrollbar {
    width: 5px;
}
.wish-card-overlay::-webkit-scrollbar-track {
    background: transparent;
}
.wish-card-overlay::-webkit-scrollbar-thumb {
    background: rgba(245, 158, 11, 0.4);
    border-radius: 10px;
}
.wish-card-overlay::-webkit-scrollbar-thumb:hover {
    background: rgba(245, 158, 11, 0.7);
}

.overlay-card-title {
    justify-content: center;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.3rem;
}

.overlay-card-subtitle {
    text-align: center;
    color: #475569;
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
    line-height: 1.45;
}

.wish-card-overlay .counter-mini-banner {
    padding: 0.45rem 0.8rem;
    margin-bottom: 0.75rem;
    font-size: 0.84rem;
}

.wish-card-overlay .selected-badge-box {
    margin-bottom: 0.75rem !important;
    padding: 0.55rem 0.85rem;
}

.wish-card-overlay .form-group {
    margin-bottom: 0.75rem;
}

.wish-card-overlay .form-label {
    color: #1e3a8a;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.wish-card-overlay .form-input,
.wish-card-overlay .form-textarea {
    background: #ffffff;
    color: #0f172a;
    border: 1.5px solid #cbd5e1;
    padding: 0.7rem 0.95rem;
    font-size: 0.95rem;
    border-radius: 10px;
}

.wish-card-overlay .form-textarea {
    resize: vertical;
    min-height: 64px;
    max-height: 120px;
}

.wish-card-overlay .form-input:focus,
.wish-card-overlay .form-textarea:focus {
    border-color: #f4c430;
    background: #ffffff;
    box-shadow: 0 0 12px rgba(244, 196, 48, 0.35);
}

.wish-form-submit-row {
    margin-top: 1rem;
}

.btn-float-submit {
    width: 100%;
    padding: 0.85rem 1.4rem;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: 12px;
}

.wish-card-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -40%) scale(0.92);
    pointer-events: none;
}

/* Floating Status Hud after floating - อยู่ใต้ Header ฝั่งขวา ไม่ทับซ้อนกับป้ายนับ */
.floating-hud {
    position: fixed;
    top: 120px; /* Fallback หากยังไม่ได้ประมวลผล Header */
    top: calc(var(--site-header-height, 90px) + 20px); /* อยู่ใต้ Header เมนูอย่างชัดเจน 100% */
    right: 24px; /* อยู่ฝั่งขวา ไม่ทับซ้อนกับป้ายนับสถิติทางฝั่งซ้าย */
    left: auto;
    transform: none;
    z-index: 90;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 2px solid var(--gold);
    border-radius: 24px;
    padding: 0.65rem 1.35rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    z-index: 80; /* อยู่ชั้นบน มองเห็นชัดเจน ไม่โดน Header บัง */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 25px rgba(245, 158, 11, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #0f172a;
}

.floating-hud.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.floating-hud-status {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.hud-lotus-icon {
    animation: float 2s infinite ease-in-out;
    font-size: 1.3rem;
}

.hud-status-text {
    font-size: 0.95rem;
    color: #b45309;
    font-weight: 700;
}

.floating-hud-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.floating-hud-actions .btn-secondary {
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
    border-radius: 10px;
}

.floating-hud-actions .btn-new-krathong {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: #10b981 !important;
    color: #047857 !important;
}

/* Wish Banner floating in 3D Scene */
.wish-banner-card {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    border: 2px solid var(--gold);
    border-radius: 20px;
    padding: 1.4rem 2.2rem;
    max-width: 620px;
    width: 90%;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.2), 0 0 30px rgba(244, 196, 48, 0.35);
    z-index: 25;
    text-align: center;
    opacity: 0;
    transform: translate(-50%, 40px);
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wish-banner-card.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.wish-text-display {
    font-size: 1.25rem;
    color: #0f172a;
    font-weight: 600;
    margin-bottom: 0.6rem;
    line-height: 1.6;
    text-shadow: none;
    font-style: italic;
}

.wish-author-display {
    font-size: 0.95rem;
    color: #b8860b;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wish-location-tag {
    font-size: 0.82rem;
    color: #27ae60;
    font-weight: 600;
    margin-top: 0.4rem;
}

/* Sound control */
.sound-toggle-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1.5px solid var(--gold);
    color: #b8860b;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.sound-toggle-btn:hover {
    transform: scale(1.1);
    background: var(--gold);
    color: #000;
}

/* Hide footer when floating scene is active */
body:has(.loy-fullscreen-container) .site-footer,
.page-view#page3.active-page ~ .site-footer {
    display: none !important;
}

/* Footer */
.site-footer {
    background: rgba(5, 10, 22, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.2rem 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.site-footer a {
    color: var(--gold);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-8px) rotate(1deg); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(244, 196, 48, 0.3); }
    50% { box-shadow: 0 0 35px rgba(244, 196, 48, 0.6); }
}

.glow-animation {
    animation: pulseGlow 3s infinite ease-in-out;
}

/* ========================================================
   Floating Krathong Counter Widget (ป้ายนับจำนวนผู้ร่วมลอยกระทง)
   ======================================================== */
.krathong-counter-badge {
    position: fixed;
    top: 120px; /* Fallback หากยังไม่ได้ประมวลผล Header */
    top: calc(var(--site-header-height, 90px) + 20px); /* อยู่ใต้ Header เมนูอย่างชัดเจน 100% ไม่โดนบัง */
    left: 24px; /* อยู่ฝั่งซ้าย */
    right: auto;
    transform: none;
    z-index: 90; /* ลำดับการแสดงผลสูง มองเห็นได้ชัดเจน */
    display: flex;
    align-items: center;
    gap: 0.95rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 2px solid var(--gold);
    border-radius: 20px;
    padding: 0.65rem 1.3rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 25px rgba(245, 158, 11, 0.35);
    transition: all 0.35s ease;
}

.krathong-counter-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.3), 0 0 35px rgba(245, 158, 11, 0.5);
}

.counter-icon-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #fef08a, #f59e0b);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    flex-shrink: 0;
}

.counter-sparkle {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 0.9rem;
    animation: sparkleSpin 3s infinite linear;
}

@keyframes sparkleSpin {
    0% { transform: scale(0.9) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(0.9) rotate(360deg); }
}

.counter-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.counter-label {
    font-size: 0.82rem;
    color: #475569;
    font-weight: 500;
    letter-spacing: 0.3px;
    line-height: 1.25;
    margin-bottom: 2px;
}

.counter-number-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    line-height: 1.15;
    margin-bottom: 4px;
}

.counter-digits {
    font-family: 'Kanit', sans-serif;
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.1;
    background: linear-gradient(135deg, #b45309, #d97706, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.counter-digits.bump {
    animation: counterBump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes counterBump {
    0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0)); }
    50% { transform: scale(1.28); filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.8)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0)); }
}

.counter-unit {
    font-size: 0.85rem;
    color: #059669;
    font-weight: 600;
}

/* counter-subtext: แสดงผลชัดเจน พอดี ไม่ทับซ้อน รองรับ Responsive */
.counter-subtext {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
    color: #065f46;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.22);
    border-radius: 8px;
    padding: 3px 8px;
    margin-top: 2px;
    line-height: 1.35;
    font-weight: 500;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
}

.counter-subtext .subtext-org {
    color: #1e3a8a;
    font-weight: 600;
}

.counter-subtext .subtext-dot {
    color: #94a3b8;
    font-weight: bold;
    font-size: 0.7rem;
}

.counter-subtext .subtext-eco {
    color: #059669;
    font-weight: 600;
}

/* Toast Badge เมื่อลอยกระทงสำเร็จ */
.counter-celebrate-toast {
    position: fixed;
    top: 215px; /* อยู่ใต้ป้ายนับสถิติ ไม่ทับซ้อนกัน */
    top: calc(var(--site-header-height, 90px) + 115px);
    left: 24px;
    z-index: 95;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    padding: 0.65rem 1.3rem;
    border-radius: 30px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(5, 150, 105, 0.4);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.counter-celebrate-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Counter Mini Banner inside Wish Form */
.counter-mini-banner {
    background: linear-gradient(135deg, rgba(254, 240, 138, 0.35), rgba(245, 158, 11, 0.18));
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 14px;
    padding: 0.55rem 1rem;
    margin-bottom: 1.1rem;
    text-align: center;
    font-size: 0.88rem;
    color: #78350f;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.counter-highlight {
    color: #b45309;
    font-weight: 700;
    font-size: 1.05rem;
}

/* ========================================================
   Responsive Media Queries for Mobile & Tablets
   ======================================================== */
@media (max-width: 860px) {
    .builder-grid {
        grid-template-columns: 1fr;
    }

    /* Tablet: จัดวางป้ายนับสถิติและ HUD ใต้ Header ไม่ทับซ้อนกัน */
    .krathong-counter-badge {
        top: 115px;
        top: calc(var(--site-header-height, 92px) + 16px);
        left: 16px;
        padding: 0.55rem 1rem;
        z-index: 90;
    }

    .floating-hud {
        top: 115px;
        top: calc(var(--site-header-height, 92px) + 16px);
        right: 16px;
        left: auto;
        transform: none;
        padding: 0.55rem 1.1rem;
        z-index: 90;
    }
}

@media (max-width: 640px) {
    /* ปรับแต่ง Header บนมือถือให้กะทัดรัด */
    .site-header {
        padding: 0.5rem 0.85rem;
    }
    .brand-logo {
        width: 44px;
        height: 44px;
    }
    .brand-text h1 {
        font-size: 1.05rem;
    }
    .brand-text p {
        font-size: 0.72rem;
    }
    .step-item {
        padding: 0.25rem 0.55rem;
        font-size: 0.72rem;
    }

    /* Counter Badge on Mobile: อยู่ใต้ Header เมนู มองเห็นชัดเจน 100% ไม่โดนบัง */
    .krathong-counter-badge {
        top: 115px; /* อยู่ใต้เมนู Header อย่างปลอดภัย */
        top: calc(var(--site-header-height, 90px) + 14px);
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        max-width: 420px;
        padding: 0.45rem 0.85rem;
        gap: 0.65rem;
        border-radius: 16px;
        align-items: center;
        z-index: 90;
    }
    .krathong-counter-badge:hover {
        transform: translateX(-50%) translateY(-2px);
    }
    .counter-icon-wrap {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }
    .counter-label {
        font-size: 0.75rem;
        line-height: 1.2;
        margin-bottom: 1px;
    }
    .counter-number-row {
        gap: 0.35rem;
        margin-bottom: 2px;
    }
    .counter-digits {
        font-size: 1.4rem;
        line-height: 1.1;
    }
    .counter-unit {
        font-size: 0.75rem;
    }

    /* counter-subtext บนมือถือ: แสดงผลชัดเจน พอดี ไม่ทับซ้อน */
    .counter-subtext {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        flex-wrap: wrap;
        font-size: 0.68rem;
        line-height: 1.3;
        padding: 2px 6px;
        border-radius: 6px;
        margin-top: 2px;
        width: fit-content;
        max-width: 100%;
    }
    .counter-subtext .subtext-org {
        font-size: 0.68rem;
    }
    .counter-subtext .subtext-eco {
        font-size: 0.68rem;
    }

    /* HUD ด้านบนบนมือถือ: วางเรียงใต้ป้ายนับสถิติ ไม่ซ้อนทับกัน */
    .floating-hud {
        top: 200px; /* วางต่อใต้ป้ายนับสถิติอย่างพอดี */
        top: calc(var(--site-header-height, 90px) + 96px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        max-width: 420px;
        padding: 0.6rem 0.9rem;
        flex-direction: column;
        gap: 0.5rem;
        border-radius: 16px;
        z-index: 90;
    }
    .floating-hud.visible {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%);
    }

    .floating-hud-actions {
        display: flex;
        gap: 0.4rem;
        width: 100%;
        justify-content: center;
    }
    .floating-hud-actions .btn-secondary {
        font-size: 0.78rem;
        padding: 0.4rem 0.7rem;
    }

    /* Toast แจ้งเตือนเมื่อลอยกระทงสำเร็จ */
    .counter-celebrate-toast {
        top: 200px;
        top: calc(var(--site-header-height, 90px) + 96px);
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
        width: calc(100% - 24px);
        max-width: 380px;
        font-size: 0.82rem;
        text-align: center;
        justify-content: center;
        z-index: 95;
    }
    .counter-celebrate-toast.show {
        transform: translateX(-50%) translateY(0);
    }

    /* Wish Card Overlay on Mobile: Fits screen perfectly, scrollable, no cut-off */
    .wish-card-overlay {
        width: calc(100vw - 20px);
        max-width: 420px;
        max-height: calc(100dvh - 180px);
        max-height: calc(100vh - 180px);
        top: calc(50% + 42px);
        padding: 1.05rem 1rem;
        border-radius: 18px;
        z-index: 75;
    }

    .overlay-card-title {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }

    .overlay-card-subtitle {
        font-size: 0.8rem;
        margin-bottom: 0.55rem;
    }

    .wish-card-overlay .counter-mini-banner {
        padding: 0.35rem 0.65rem;
        font-size: 0.78rem;
        margin-bottom: 0.55rem;
    }

    .wish-card-overlay .selected-badge-box {
        padding: 0.45rem 0.7rem;
        margin-bottom: 0.55rem !important;
    }

    .wish-card-overlay .form-group {
        margin-bottom: 0.55rem;
    }

    .wish-card-overlay .form-label {
        font-size: 0.82rem;
        margin-bottom: 0.2rem;
    }

    .wish-card-overlay .form-input,
    .wish-card-overlay .form-textarea {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .wish-card-overlay .form-textarea {
        min-height: 52px;
        max-height: 80px;
    }

    .wish-form-submit-row {
        margin-top: 0.65rem;
    }

    .btn-float-submit {
        padding: 0.75rem 1rem;
        font-size: 1.05rem;
    }

    /* Wish Banner Card on Mobile */
    .wish-banner-card {
        bottom: 20px;
        padding: 1rem 1.4rem;
        border-radius: 16px;
    }
    .wish-text-display {
        font-size: 1.05rem;
    }
}

/* Small Mobile Screens (width <= 380px) */
@media (max-width: 380px) {
    .krathong-counter-badge {
        padding: 0.4rem 0.65rem;
        gap: 0.55rem;
    }
    .counter-icon-wrap {
        width: 32px;
        height: 32px;
        font-size: 1.05rem;
    }
    .counter-label {
        font-size: 0.72rem;
    }
    .counter-digits {
        font-size: 1.25rem;
    }
    .counter-subtext {
        font-size: 0.63rem;
        padding: 1px 4px;
        gap: 0.2rem;
    }
    .counter-subtext .subtext-dot {
        display: none;
    }
    .floating-hud {
        top: 195px;
        top: calc(var(--site-header-height, 90px) + 92px);
        padding: 0.5rem 0.75rem;
    }
}

/* Landscape Mode on Mobile / Short Screens (height <= 540px) */
@media (max-height: 540px) {
    /* Header แนวนอนให้แบนและกะทัดรัด */
    .site-header {
        padding: 0.35rem 0.85rem;
    }
    .brand-logo {
        width: 36px;
        height: 36px;
    }
    .brand-text h1 {
        font-size: 0.95rem;
    }
    .brand-text p {
        font-size: 0.65rem;
    }
    .step-item {
        padding: 0.2rem 0.45rem;
        font-size: 0.68rem;
    }

    .krathong-counter-badge {
        top: 58px; /* ใต้ Header แนวนอนชัดเจน */
        top: calc(var(--site-header-height, 46px) + 8px);
        left: 10px;
        right: auto;
        transform: none;
        width: auto;
        max-width: 280px;
        padding: 0.35rem 0.7rem;
        border-radius: 12px;
        gap: 0.5rem;
        z-index: 90;
    }
    .counter-icon-wrap {
        width: 28px;
        height: 28px;
        font-size: 0.95rem;
    }
    .counter-label {
        font-size: 0.7rem;
    }
    .counter-digits {
        font-size: 1.15rem;
    }
    .counter-subtext {
        display: flex;
        align-items: center;
        gap: 0.2rem;
        font-size: 0.62rem;
        padding: 1px 4px;
        margin-top: 1px;
        line-height: 1.2;
    }

    .floating-hud {
        top: 58px; /* ฝั่งขวาใต้ Header แนวนอน ไม่ทับซ้อนกับป้ายนับ */
        top: calc(var(--site-header-height, 46px) + 8px);
        right: 10px;
        left: auto;
        transform: none;
        width: auto;
        max-width: 320px;
        padding: 0.35rem 0.75rem;
        border-radius: 12px;
        gap: 0.6rem;
        z-index: 90;
    }

    .counter-celebrate-toast {
        top: 115px;
        top: calc(var(--site-header-height, 46px) + 65px);
        left: 10px;
        font-size: 0.78rem;
        padding: 0.4rem 0.8rem;
    }

    .wish-card-overlay {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-height: calc(100dvh - 14px);
        max-height: calc(100vh - 14px);
        padding: 0.8rem 1.25rem;
        max-width: 480px;
        width: 94%;
        border-radius: 16px;
    }

    .overlay-card-title {
        font-size: 1.15rem;
        margin-bottom: 0.15rem;
    }

    .overlay-card-subtitle,
    .wish-card-overlay .counter-mini-banner {
        display: none;
    }

    .wish-card-overlay .selected-badge-box {
        padding: 0.35rem 0.7rem;
        margin-bottom: 0.45rem !important;
    }

    .wish-card-overlay .form-group {
        margin-bottom: 0.45rem;
    }

    .wish-card-overlay .form-textarea {
        min-height: 44px;
        max-height: 65px;
    }

    .wish-form-submit-row {
        margin-top: 0.5rem;
    }

    .btn-float-submit {
        padding: 0.6rem 1rem;
        font-size: 0.98rem;
    }
}
