:root {
    --bg: #1a0f0a;
    --bg2: #231510;
    --card: rgba(35, 22, 12, 0.85);
    --border: rgba(184, 134, 11, 0.2);
    --gold: #d4a017;
    --gold-light: #f5d76e;
    --red: #c0392b;
    --text: #f5e6d3;
    --muted: #a08060;
    --radius: 16px;
    --glow: 0 0 20px rgba(212, 160, 23, 0.3);
}

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

body {
    font-family: 'STKaiti', 'KaiTi', 'PingFang SC', serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.buddha-light {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(212,160,23,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
    0%,100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
}

/* Music Button */
.music-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.music-icon { font-size: 16px; }
.music-btn.playing { animation: pulse-glow 2s infinite; }

@keyframes pulse-glow {
    0%,100% { box-shadow: 0 0 5px rgba(212,160,23,0.3); }
    50% { box-shadow: 0 0 20px rgba(212,160,23,0.6); }
}

/* App */
.app {
    position: relative;
    z-index: 1;
    max-width: 520px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 60px 20px 40px;
}

/* Page transitions */
.page {
    animation: fadeUp 0.6s ease;
}

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

/* Header */
.page-header {
    text-align: center;
    margin-bottom: 32px;
}

.page-header .logo {
    font-size: 36px;
    margin-bottom: 8px;
    display: block;
    text-shadow: 0 0 30px rgba(212,160,23,0.5);
}

.page-header h1 {
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.page-header p {
    font-size: 13px;
    color: var(--muted);
}

/* Navigation Cards */
.nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.nav-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.nav-card:hover, .nav-card:active {
    border-color: var(--gold);
    box-shadow: var(--glow);
    transform: translateY(-2px);
}

.nav-card-icon { font-size: 28px; margin-bottom: 6px; display: block; }
.nav-card-name { font-size: 13px; font-weight: 700; color: var(--gold-light); }

/* Section Cards */
.section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
}

.section-card:hover {
    border-color: rgba(212,160,23,0.4);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold-light);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Masters */
.master-list {
    display: flex;
    gap: 10px;
}

.master-item {
    flex: 1;
    padding: 14px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.master-item.active {
    border-color: var(--gold);
    background: rgba(212,160,23,0.08);
    box-shadow: 0 0 15px rgba(212,160,23,0.2);
}

.master-item .m-avatar { font-size: 32px; }
.master-item .m-name { font-size: 12px; font-weight: 700; margin-top: 6px; color: var(--gold-light); }
.master-item .m-desc { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Input */
.input-area {
    width: 100%;
    min-height: 80px;
    padding: 14px;
    background: rgba(10,5,2,0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
}

.input-area:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 10px rgba(212,160,23,0.2); }
.input-area::placeholder { color: var(--muted); }

/* Action Button */
.action-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #8b4513, #6b3410, #8b4513);
    border: 1px solid var(--gold);
    color: var(--gold-light);
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(139,69,19,0.4);
    margin-top: 16px;
}

.action-btn:hover { box-shadow: var(--glow); transform: translateY(-1px); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Gua Display */
.gua-display {
    text-align: center;
    padding: 28px;
    background: radial-gradient(circle, rgba(212,160,23,0.08), transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 16px 0;
}

.gua-lines { font-size: 22px; font-family: monospace; letter-spacing: 6px; color: var(--gold); margin-bottom: 12px; }
.gua-name { font-size: 24px; font-weight: 900; color: var(--gold-light); text-shadow: 0 0 10px rgba(212,160,23,0.5); }
.gua-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Result */
.result-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
    line-height: 2;
    font-size: 14px;
    white-space: pre-wrap;
    backdrop-filter: blur(10px);
    animation: fadeUp 0.5s ease;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.result-header span { font-size: 28px; }
.result-header strong { font-size: 14px; color: var(--gold-light); }

/* Lottery */
.lottery-display {
    text-align: center;
    padding: 32px 20px;
    background: radial-gradient(circle, rgba(212,160,23,0.1), transparent);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    margin: 16px 0;
    box-shadow: 0 0 30px rgba(212,160,23,0.1);
}

.lottery-num { font-size: 52px; font-weight: 900; color: var(--gold-light); text-shadow: 0 0 20px rgba(212,160,23,0.5); }
.lottery-level { font-size: 16px; color: var(--red); margin: 8px 0; font-weight: 700; }
.lottery-poem { font-size: 15px; line-height: 2.2; font-style: italic; color: var(--text); }

/* Loading */
.loading-area { text-align: center; padding: 32px; }
.loading-dots { display: inline-flex; gap: 6px; }
.loading-dots i { width: 8px; height: 8px; background: var(--gold); border-radius: 50%; animation: ldot 1.4s infinite; }
.loading-dots i:nth-child(2) { animation-delay: 0.2s; }
.loading-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes ldot { 0%,80%,100%{transform:scale(0)}40%{transform:scale(1)} }

/* Pay Modal */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:9999; display:none; align-items:center; justify-content:center; }
.modal-overlay.show { display:flex; }

.pay-modal {
    background: linear-gradient(135deg, #2a1a0e, #1a0f0a);
    border: 1px solid var(--gold);
    border-radius: 20px;
    padding: 32px 24px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(212,160,23,0.1);
}

.pay-close { position:absolute; top:12px; right:16px; background:none; border:none; color:var(--muted); font-size:24px; cursor:pointer; }
.pay-buddha { font-size: 48px; margin-bottom: 12px; }
.pay-modal h3 { font-size: 20px; color: var(--gold-light); margin-bottom: 8px; }
.pay-desc { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

.pay-prices { display: flex; gap: 8px; margin-bottom: 20px; }
.pay-price {
    flex: 1;
    padding: 12px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.pay-price.active { border-color: var(--gold); background: rgba(212,160,23,0.1); box-shadow: 0 0 10px rgba(212,160,23,0.2); }
.pp-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.pp-amount { font-size: 18px; font-weight: 900; color: var(--gold-light); }

.pay-qr { margin: 16px auto; width: 180px; height: 180px; background: #fff; border-radius: 12px; padding: 8px; }
.pay-qr img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.pay-tip { font-size: 11px; color: var(--muted); margin: 12px 0; }
.pay-confirm {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--gold), #b8860b);
    border: none;
    border-radius: 10px;
    color: #1a0f0a;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

/* Buddha light click effect */
.click-light {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212,160,23,0.6) 0%, rgba(212,160,23,0) 70%);
    animation: clickFade 0.8s ease-out forwards;
}

@keyframes clickFade {
    0% { transform: translate(-50%,-50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(3); opacity: 0; }
}

/* Shake animation */
@keyframes shake {
    0%,100% { transform: rotate(0); }
    20% { transform: rotate(-8deg); }
    40% { transform: rotate(8deg); }
    60% { transform: rotate(-5deg); }
    80% { transform: rotate(5deg); }
}

.shaking { animation: shake 0.6s ease; }

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 20px;
    font-family: inherit;
    transition: all 0.2s;
}
.back-btn:hover { border-color: var(--gold); color: var(--gold-light); }

/* Free count badge */
.free-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(212,160,23,0.1);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 11px;
    color: var(--gold);
}

/* Responsive */
@media (max-width: 380px) {
    .master-list { flex-direction: column; }
    .nav-grid { grid-template-columns: repeat(2, 1fr); }
}
