/* ==========================================
   Design System & Variable Declarations
   ========================================== */
:root {
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Theme Colors */
    --bg-dark: #0a0816;
    --bg-light-glow: #151130;
    --primary-neon: #ff4769;
    --primary-glow: rgba(255, 71, 105, 0.4);
    
    --accent-gold: #ffb938;
    --accent-gold-glow: rgba(255, 185, 56, 0.5);

    --accent-ice: #00d2ff;
    --accent-ice-glow: rgba(0, 210, 255, 0.5);

    --text-primary: #ffffff;
    --text-secondary: #9ea4c4;
    --text-muted: #676c8c;

    /* Glassmorphism Styles */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.4);
    --glass-blur: blur(20px);
}

/* ==========================================
   Base Elements Setup
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at top right, var(--bg-light-glow) 0%, var(--bg-dark) 70%);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

/* App Wrapper - Phone view constraints */
.app-container {
    width: 100%;
    max-width: 600px; /* 手機原生尺寸限制，在大螢幕下置中顯得精緻 */
    background: rgba(10, 8, 22, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    overflow-x: hidden;
}

/* ==========================================
   Typography & Headers
   ========================================== */
h1, h2, h3, .logo-badge, .draw-ball, .nav-tab, .value {
    font-family: var(--font-heading);
}

/* Header Area */
.app-header {
    margin-bottom: 24px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.logo-badge {
    background: linear-gradient(135deg, var(--primary-neon), #ff8a00);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 6px;
    letter-spacing: 1px;
    box-shadow: 0 0 10px var(--primary-glow);
}

.logo-area h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-sub {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: auto;
}

/* Glassmorphism Container Card */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 18px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    margin-bottom: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.glass-card h2 span {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ==========================================
   Latest Draw Results Card
   ========================================== */
.latest-card {
    border-left: 3px solid var(--primary-neon);
}

.card-eyebrow {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-weight: 500;
}

.pulse-indicator {
    width: 6px;
    height: 6px;
    background-color: #00ff66;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #00ff66;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 102, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 255, 102, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 102, 0); }
}

.latest-balls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ball-group {
    display: flex;
    gap: 6px;
}

.zone-divider {
    width: 1px;
    height: 24px;
    background-color: var(--glass-border);
}

/* Core Lottery Ball Styling */
.draw-ball {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #d8dde6 60%, #aeb4bf 100%);
    color: #1e2230;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    box-shadow: inset -2px -2px 6px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.3);
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

.draw-ball.special {
    background: radial-gradient(circle at 30% 30%, #ffe259 0%, #ffa751 100%);
    color: #3b2300;
    box-shadow: inset -2px -2px 6px rgba(0, 0, 0, 0.4), 0 0 12px var(--accent-gold-glow);
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* ==========================================
   Navigation Tabs
   ========================================== */
.app-nav {
    display: flex;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 4px;
    margin-bottom: 20px;
    justify-content: space-between;
}

.nav-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 4px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.nav-tab.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Tab Contents Toggle */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

/* ==========================================
   Tab 1: Interactive Ball Pad
   ========================================== */
.stats-control {
    background: linear-gradient(135deg, rgba(255, 71, 105, 0.06) 0%, rgba(0, 210, 255, 0.06) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.toggle-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.toggle-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-secondary);
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.toggle-btn.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Visual Legends */
.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.legend-bar {
    display: flex;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
}

.legend-item {
    padding: 2px 6px;
    border-radius: 4px;
}

.legend-item.cold { background: rgba(0, 198, 255, 0.2); color: var(--accent-ice); }
.legend-item.warm { background: rgba(255, 255, 255, 0.1); color: white; }
.legend-item.hot { background: rgba(255, 75, 43, 0.2); color: var(--primary-neon); }
.legend-item.special-hot { background: rgba(255, 185, 56, 0.2); color: var(--accent-gold); }

/* Ball Grid layout */
.balls-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr); /* 7 columns fit nicely in mobile view */
    gap: 12px 8px;
    justify-items: center;
}

.zone2-grid {
    grid-template-columns: repeat(8, 1fr); /* 8 columns for Zone 2 */
}

/* Pad Interactive Ball */
.pad-ball {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pad-ball .badge {
    font-size: 8px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: -1px;
    font-family: var(--font-body);
}

.pad-ball:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Zone 1 Selected States */
.pad-ball.selected-z1 {
    background: radial-gradient(circle at 30% 30%, #ff4b2b 0%, var(--primary-neon) 100%);
    border-color: var(--primary-neon);
    color: white;
    box-shadow: 0 0 14px var(--primary-glow), inset -2px -2px 4px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

.pad-ball.selected-z1 .badge {
    color: rgba(255, 255, 255, 0.8);
}

/* Zone 2 Selected States */
.pad-ball.selected-z2 {
    background: radial-gradient(circle at 30% 30%, #ffe259 0%, #ffa751 100%);
    border-color: var(--accent-gold);
    color: #3b2300;
    box-shadow: 0 0 14px var(--accent-gold-glow), inset -2px -2px 4px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}

.pad-ball.selected-z2 .badge {
    color: #523700;
}

/* Heatmap visual overlay states */
.pad-ball.heat-cold {
    border-color: rgba(0, 210, 255, 0.5);
    background: radial-gradient(circle at 30% 30%, rgba(0, 210, 255, 0.15) 0%, rgba(0, 114, 255, 0.25) 100%);
    color: var(--accent-ice);
}

.pad-ball.heat-medium {
    border-color: rgba(255, 255, 255, 0.2);
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.1) 100%);
    color: white;
}

.pad-ball.heat-hot {
    border-color: var(--primary-neon);
    background: radial-gradient(circle at 30% 30%, rgba(255, 75, 43, 0.25) 0%, rgba(255, 71, 105, 0.35) 100%);
    color: #ff758f;
    box-shadow: 0 0 10px rgba(255, 71, 105, 0.2);
}

.pad-ball.heat-special-hot {
    border-color: var(--accent-gold);
    background: radial-gradient(circle at 30% 30%, rgba(255, 226, 89, 0.25) 0%, rgba(255, 167, 81, 0.35) 100%);
    color: #ffca64;
    box-shadow: 0 0 10px rgba(255, 185, 56, 0.2);
}

/* Hand Selection Bar */
.selected-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-left: 3px solid var(--accent-gold);
}

.selected-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.selected-display {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.no-selection {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.selected-display .draw-ball {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

/* ==========================================
   Tab 2: Generator & Algorithm Options
   ========================================== */
.strategy-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.strategy-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    transition: all 0.2s ease;
}

.strategy-option:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
}

.strategy-option.active {
    background: rgba(255, 71, 105, 0.05);
    border-color: var(--primary-neon);
    box-shadow: inset 0 0 12px rgba(255, 71, 105, 0.1);
}

.option-icon {
    font-size: 24px;
}

.option-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.option-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Shared Buttons styling */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-neon) 0%, #ff6b4a 100%);
    border: none;
    border-radius: 14px;
    color: white;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: all 0.2s ease;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Pulsing effect for call-to-actions */
.animate-pulse {
    animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 105, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(255, 71, 105, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 71, 105, 0); }
}

/* Generated Outcome Card */
.generated-card {
    border: 1px solid var(--primary-neon);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.generated-balls-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 20px 0 16px 0;
}

.generated-balls-wrapper .draw-ball {
    width: 44px;
    height: 44px;
    font-size: 18px;
    /* ball drop bounce animation */
    animation: ballDrop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.5) both;
}

@keyframes ballDrop {
    0% { transform: translateY(-40px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Stagger animations for generated balls */
.generated-balls-wrapper .draw-ball:nth-child(1) { animation-delay: 0.05s; }
.generated-balls-wrapper .draw-ball:nth-child(2) { animation-delay: 0.1s; }
.generated-balls-wrapper .draw-ball:nth-child(3) { animation-delay: 0.15s; }
.generated-balls-wrapper .draw-ball:nth-child(4) { animation-delay: 0.2s; }
.generated-balls-wrapper .draw-ball:nth-child(5) { animation-delay: 0.25s; }
.generated-balls-wrapper .draw-ball:nth-child(6) { animation-delay: 0.3s; }
.generated-balls-wrapper .draw-ball:nth-child(8) { animation-delay: 0.4s; }

.result-strategy-badge {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    width: fit-content;
    margin: 0 auto;
}

/* ==========================================
   Tab 3: Auto-Checker (History Verification)
   ========================================== */
.checker-inputs {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.input-section label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.checker-ball-selector {
    display: grid;
    grid-template-columns: repeat(10, 1fr); /* More columns for smaller selector balls */
    gap: 6px;
    justify-items: center;
}

.zone2-pool {
    grid-template-columns: repeat(8, 1fr);
}

.select-ball {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-ball:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.select-ball.selected-z1 {
    background: var(--primary-neon);
    border-color: var(--primary-neon);
    color: white;
    box-shadow: 0 0 8px var(--primary-glow);
}

.select-ball.selected-z2 {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #3b2300;
    box-shadow: 0 0 8px var(--accent-gold-glow);
}

.checker-controls {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.checker-controls .btn-primary {
    flex: 3;
}

.checker-controls .btn-secondary {
    flex: 1;
}

/* Checker Results Layout */
.results-card {
    border-left: 3px solid #00ff66;
}

.results-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-box .label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-box .value {
    font-size: 16px;
    font-weight: 700;
}

.stat-box .value.highlight {
    color: #00ff66;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
}

.prizes-table {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
}

.table-header, .table-row {
    display: grid;
    grid-template-columns: 1.5fr 2fr 1fr;
    padding: 10px 14px;
    font-size: 13px;
}

.table-header {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
}

.table-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.table-row:last-child {
    border-bottom: none;
}

.table-row span:nth-child(3) {
    font-weight: 600;
    text-align: right;
}

.table-row.win-active {
    background: rgba(0, 255, 102, 0.04);
}

.table-row.win-active span:nth-child(3) {
    color: #00ff66;
}

/* ==========================================
   Tab 4: Historical List & Search
   ========================================== */
.search-card {
    padding: 12px;
}

.search-box {
    display: flex;
    gap: 10px;
}

.search-box input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: white;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

.search-box .btn-primary {
    width: auto;
    padding: 10px 20px;
    border-radius: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

/* History Row Item */
.history-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-period {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.history-date {
    font-size: 11px;
    color: var(--text-muted);
}

.history-item .draw-ball {
    width: 26px;
    height: 26px;
    font-size: 11px;
}

.history-item .ball-group {
    gap: 4px;
}

.load-more-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.load-more-container button {
    width: 100%;
    padding: 12px;
}

/* ==========================================
   Footer
   ========================================== */
.app-footer {
    margin-top: auto;
    padding: 24px 0 10px 0;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.app-footer p {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
