/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Noto Serif TC', 'Noto Serif SC', Georgia, serif;
    background: linear-gradient(135deg, #1a0505 0%, #2d0a0a 50%, #1a0505 100%);
    color: #f5e6d3;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ==================== LANGUAGE SELECTOR ==================== */
.language-selector {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
}

.language-dropdown {
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    font-family: inherit;
    background: #2d0a0a;
    color: #f0b30e;
    border: 2px solid #95002c;
    border-radius: 6px;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f0b30e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    transition: all 0.3s ease;
}

.language-dropdown:focus {
    border-color: #f0b30e;
    box-shadow: 0 0 10px rgba(240, 179, 14, 0.3);
}

.language-dropdown option {
    background: #2d0a0a;
    color: #f0b30e;
    padding: 10px;
}

/* ==================== SCREENS ==================== */
.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
    padding: 60px 20px 20px 20px;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ==================== OPENING SCREEN ==================== */
.opening-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    max-width: 400px;
    text-align: center;
    padding: 0 15px;
}

.deity-image {
    width: clamp(80px, 20vw, 180px);
    height: clamp(80px, 20vw, 180px);
    margin-bottom: 30px;
}

.deity-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(240, 179, 14, 0.3));
}

#app-title {
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    color: #f0b30e;
    text-shadow: 0 0 20px rgba(240, 179, 14, 0.5);
    margin-bottom: 8px;
    font-weight: 700;
}

.subtitle {
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    color: #c89b0b;
    margin-bottom: 30px;
}

/* ==================== BUTTONS ==================== */
.golden-btn {
    background: linear-gradient(135deg, #95002c 0%, #f0b30e 50%, #95002c 100%);
    background-size: 200% 200%;
    color: #ffffff;
    border: none;
    padding: 14px 28px;
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    font-family: inherit;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(240, 179, 14, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.golden-btn:hover {
    background-position: 100% 100%;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 179, 14, 0.4);
}

.golden-btn:active {
    transform: translateY(0);
}

.golden-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.main-btn {
    width: 100%;
    max-width: 300px;
    padding: 16px 32px;
    font-size: clamp(1rem, 4vw, 1.2rem);
}

.small-btn {
    padding: 12px 20px;
    font-size: clamp(0.9rem, 3vw, 1rem);
    min-width: 80px;
}

.secondary-btn {
    background: transparent;
    color: #c89b0b;
    border: 2px solid #95002c;
    padding: 12px 24px;
    font-size: clamp(0.9rem, 3vw, 1rem);
    font-family: inherit;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.secondary-btn:hover {
    background: rgba(149, 0, 44, 0.2);
    border-color: #f0b30e;
    color: #f0b30e;
}

/* ==================== DIVIDER ==================== */
.divider {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 24px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #95002c, transparent);
}

.divider span {
    padding: 0 16px;
    color: #a0926c;
    font-size: 0.9rem;
}

/* ==================== DIRECT INPUT SECTION ==================== */
.direct-input-section {
    width: 100%;
}

.input-label {
    display: block;
    color: #c89b0b;
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    margin-bottom: 12px;
}

.input-row {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.stick-number-input {
    flex: 1;
    min-width: 100px;
    padding: 12px 16px;
    font-size: clamp(1rem, 3.5vw, 1.1rem);
    font-family: inherit;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #95002c;
    border-radius: 8px;
    color: #f0b30e;
    outline: none;
    transition: all 0.3s ease;
}

.stick-number-input::placeholder {
    color: #a0926c;
}

.stick-number-input:focus {
    border-color: #f0b30e;
    box-shadow: 0 0 12px rgba(240, 179, 14, 0.3);
}

.stick-number-input::-webkit-outer-spin-button,
.stick-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stick-number-input[type=number] {
    -moz-appearance: textfield;
}

.input-error {
    color: #ff6b6b;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    margin-top: 10px;
}

.input-error.hidden {
    display: none;
}

/* ==================== STICK SCREEN (UPDATED COLORS) ==================== */
.stick-container-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

#shake-title {
    font-size: 1.6rem;
    color: #f0b30e;
    margin-bottom: 10px;
}

.instruction {
    color: #c89b0b;
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.stick-container {
    position: relative;
    width: 140px;
    height: 280px;
    margin: 0 auto 20px;
}

.stick-container.shaking {
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

.stick-container.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.sticks {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    height: 220px;
    width: 180px;
    overflow: hidden;
}

/* Sticks with RED TIP - UPDATED COLORS */
.stick {
    position: absolute;
    width: 8px;
    height: 200px;
    background: linear-gradient(to bottom, 
        #95002c 0%,           /* Deep maroon red tip */
        #c8003a 5%,           /* Bright red fade */
        #f0b30e 15%,          /* Gold transition */
        #d4a574 50%, 
        #95002c 100%
    );
    border-radius: 2px 2px 4px 4px;
    bottom: 0;
    transform-origin: bottom center;
}

.container-body {
    position: absolute;
    bottom: 0;
    left: 45%;
    transform: translateX(-50%);
    width: 160px;
    height: 220px;
}

.container-front {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #6b1f28 0%, #4a1420 50%, #2d0a10 100%);
    border-radius: 0 0 20px 20px;
    border: 3px solid #f0b30e;
    border-top: none;
}

.shake-indicator {
    margin-top: 20px;
}

.shake-btn {
    background: linear-gradient(135deg, #95002c 0%, #f0b30e 50%, #95002c 100%);
    color: #ffffff;
    border: none;
    padding: 16px 32px;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(240, 179, 14, 0.4);
}

.shake-btn:hover {
    transform: scale(1.05);
}

.shake-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ==================== DRAWN STICK - UPDATED COLORS ==================== */
.drawn-stick {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 250px;
    background: linear-gradient(to bottom, 
        #95002c 0%,           /* Deep maroon red tip */
        #c8003a 3%,           /* Bright red */
        #f0b30e 10%,          /* Gold transition */
        #d4a574 50%, 
        #95002c 100%
    );
    border-radius: 4px;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15px;
    box-shadow: 0 0 20px rgba(240, 179, 14, 0.6);
    opacity: 0;
    transition: all 1s ease;
}

.drawn-stick.rising {
    opacity: 1;
    transform: translateX(-50%) translateY(-80px);
}

.drawn-stick-number {
    writing-mode: vertical-rl;
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffffff;
}

/* ==================== SELECTED STICK DISPLAY - UPDATED COLORS ==================== */
.selected-stick {
    margin-top: 30px;
    text-align: center;
}

.selected-stick.hidden {
    display: none;
}

.stick-display {
    margin-bottom: 15px;
}

.stick-body {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 200px;
    background: linear-gradient(to bottom, 
        #95002c 0%,           /* Deep maroon red tip */
        #c8003a 2%,           /* Bright red */
        #f0b30e 8%,           /* Gold transition */
        #d4a574 50%, 
        #95002c 100%
    );
    border-radius: 6px;
    box-shadow: 0 0 30px rgba(240, 179, 14, 0.5);
}

.stick-number {
    writing-mode: vertical-rl;
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffffff;
}

.stick-label {
    font-size: 1.3rem;
    color: #f0b30e;
    margin-bottom: 20px;
}

/* ==================== RESULT SCREEN ==================== */
.result-wrapper {
    width: 100%;
    max-width: 800px;
    padding: 0 10px 40px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: linear-gradient(135deg, rgba(149, 0, 44, 0.3), rgba(240, 179, 14, 0.1));
    border: 1px solid #95002c;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
}

.result-label {
    font-size: clamp(0.9rem, 3vw, 1rem);
    color: #c89b0b;
}

.result-number {
    font-size: clamp(1.5rem, 5vw, 2rem);
    color: #f0b30e;
    font-weight: bold;
}

.result-topic {
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    color: #f5e6d3;
    margin-left: 10px;
}

.fortune-rank {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    font-weight: 600;
    background: linear-gradient(135deg, #f0b30e, #d49d0c);
    color: #1a0505;
    white-space: nowrap;
}

/* ==================== CHATBOT SECTION (UPDATED COLORS) ==================== */
.chatbot-section {
    margin-bottom: 24px;
}

.chatbot-container {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4), rgba(45, 10, 10, 0.3));
    border: 2px solid #95002c;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.chatbot-header {
    background: linear-gradient(135deg, rgba(149, 0, 44, 0.5), rgba(240, 179, 14, 0.2));
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 1px solid rgba(240, 179, 14, 0.2);
}

.chatbot-header h3 {
    color: #f0b30e;
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.question-counter {
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    color: #f0b30e;
    background: rgba(149, 0, 44, 0.4);
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid rgba(240, 179, 14, 0.3);
}

.chatbot-messages {
    height: clamp(250px, 45vh, 350px);
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for chatbot messages */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: rgba(149, 0, 44, 0.1);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(240, 179, 14, 0.3);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(240, 179, 14, 0.5);
}

.chatbot-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: clamp(0.9rem, 3vw, 1rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #95002c, #75001f);
    color: #f5e6d3;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(240, 179, 14, 0.15), rgba(149, 0, 44, 0.15));
    border: 1px solid rgba(240, 179, 14, 0.3);
    color: #f5e6d3;
    border-bottom-left-radius: 4px;
}

.chatbot-message.system {
    align-self: center;
    background: transparent;
    color: #a0926c;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    text-align: center;
    box-shadow: none;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #c89b0b;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* ==================== ENHANCED CHATBOT INPUT AREA ==================== */
.chatbot-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(26, 5, 5, 0.6), rgba(45, 10, 10, 0.4));
    border-top: 2px solid rgba(240, 179, 14, 0.2);
    align-items: center;
}

.chatbot-input {
    flex: 1;
    min-width: 0;
    padding: 14px 18px;
    font-size: clamp(0.95rem, 3vw, 1.05rem);
    font-family: inherit;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(149, 0, 44, 0.4);
    border-radius: 12px;
    color: #f5e6d3;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.chatbot-input::placeholder {
    color: #a0926c;
    font-style: italic;
}

.chatbot-input:focus {
    border-color: #f0b30e;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 
        inset 0 2px 6px rgba(0, 0, 0, 0.3),
        0 0 16px rgba(240, 179, 14, 0.3);
}

.chatbot-send-btn {
    padding: 14px 24px;
    font-size: clamp(0.95rem, 3vw, 1.05rem);
    font-family: inherit;
    font-weight: 600;
    background: linear-gradient(135deg, #95002c, #f0b30e, #95002c);
    background-size: 200% 200%;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    touch-action: manipulation;
    box-shadow: 0 4px 12px rgba(240, 179, 14, 0.4);
}

.chatbot-send-btn:hover {
    background-position: 100% 100%;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(240, 179, 14, 0.5);
}

.chatbot-send-btn:active {
    transform: translateY(0);
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==================== CONTENT SECTIONS ==================== */
.result-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.content-section,
.guidance-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(149, 0, 44, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
}

.guidance-section {
    margin-bottom: 24px;
}

.section-title {
    color: #f0b30e;
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(149, 0, 44, 0.3);
}

/* ==================== POEM BOX ==================== */
.poem-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.poem-line {
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    color: #f5e6d3;
    line-height: 1.8;
    text-align: center;
}

/* ==================== STORY & INTERPRETATION ==================== */
.story-box,
.interpretation-box {
	font-size: clamp(0.95rem, 3vw, 1.1rem);
    line-height: 1.8;
    color: #e5d6c3;
}

/* ==================== GUIDANCE BOX ==================== */
.guidance-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.guidance-line {
    font-size: clamp(0.95rem, 3vw, 1.1rem);
    color: #f5e6d3;
    line-height: 1.8;
    text-align: center;
}

/* ==================== QUESTIONS GRID ==================== */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.question-item {
    background: rgba(149, 0, 44, 0.15);
    border: 1px solid rgba(149, 0, 44, 0.3);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.question-item:hover {
    background: rgba(149, 0, 44, 0.25);
}

.question-item strong {
    display: block;
    color: #f0b30e;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    margin-bottom: 6px;
}

.question-item span {
    color: #e5d6c3;
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== LOADING (HIDDEN BY DEFAULT) ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 5, 5, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-overlay.hidden {
    display: none !important;
}

.loading-spinner {
    width: clamp(40px, 10vw, 50px);
    height: clamp(40px, 10vw, 50px);
    border: 4px solid rgba(149, 0, 44, 0.3);
    border-top-color: #f0b30e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #f0b30e;
    font-size: clamp(0.95rem, 3vw, 1.1rem);
}

/* ==================== UTILITIES ==================== */
.hidden {
    display: none !important;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */

/* Extra small devices (phones, less than 360px) */
@media screen and (max-width: 359px) {
    html {
        font-size: 12px;
    }
    
    .screen {
        padding: 50px 10px 15px 10px;
    }
    
    .language-selector {
        top: 5px;
        right: 5px;
    }
    
    .language-dropdown {
        padding: 5px 24px 5px 8px;
        font-size: 11px;
    }
    
    .opening-content {
        padding: 0 10px;
    }
    
    .deity-image {
        width: 70px;
        height: 70px;
        margin-bottom: 20px;
    }
    
    .result-wrapper {
        padding: 0 5px 30px;
    }
    
    .result-header {
        padding: 12px 15px;
    }
    
    .content-section,
    .guidance-section {
        padding: 12px 15px;
    }
    
    .chatbot-input-area {
        padding: 12px 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .chatbot-send-btn {
        width: 100%;
    }
    
    .questions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .question-item {
        padding: 10px 8px;
    }
    
    .action-buttons {
        gap: 10px;
    }
    
    .action-buttons .golden-btn,
    .action-buttons .secondary-btn {
        width: 100%;
        padding: 12px 20px;
    }
}

/* Small devices (phones, 360px to 599px) */
@media screen and (min-width: 360px) and (max-width: 599px) {
    html {
        font-size: 14px;
    }
    
    .screen {
        padding: 50px 15px 15px 15px;
    }
    
    .language-selector {
        top: 8px;
        right: 8px;
    }
    
    .language-dropdown {
        padding: 6px 28px 6px 10px;
        font-size: 12px;
    }
    
    .deity-image {
        width: 100px;
        height: 100px;
    }
    
    .input-row {
        flex-direction: column;
    }
    
    .input-row .golden-btn {
        width: 100%;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-right {
        align-self: flex-end;
    }
    
    .result-topic {
        display: block;
        margin-left: 0;
        margin-top: 4px;
    }
    
    .chatbot-messages {
        height: 240px;
    }
    
    .chatbot-input-area {
        flex-direction: column;
    }
    
    .chatbot-send-btn {
        width: 100%;
    }
    
    .questions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .action-buttons .golden-btn,
    .action-buttons .secondary-btn {
        width: 100%;
    }
}

/* Medium devices (tablets, 600px to 899px) */
@media screen and (min-width: 600px) and (max-width: 899px) {
    html {
        font-size: 15px;
    }
    
    .screen {
        padding: 60px 20px 20px 20px;
    }
    
    .opening-content {
        max-width: 450px;
    }
    
    .deity-image {
        width: 140px;
        height: 140px;
    }
    
    .result-wrapper {
        max-width: 700px;
    }
    
    .chatbot-messages {
        height: 300px;
    }
    
    .questions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .action-buttons {
        gap: 20px;
    }
}

/* Large devices (desktops, 900px to 1199px) */
@media screen and (min-width: 900px) and (max-width: 1199px) {
    .screen {
        padding: 70px 30px 30px 30px;
    }
    
    .result-wrapper {
        max-width: 750px;
    }
    
    .chatbot-messages {
        height: 340px;
    }
    
    .questions-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media screen and (min-width: 1200px) {
    .screen {
        padding: 80px 40px 40px 40px;
    }
    
    .result-wrapper {
        max-width: 850px;
    }
    
    .chatbot-messages {
        height: 380px;
    }
    
    .questions-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ==================== LANDSCAPE ORIENTATION ==================== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .screen {
        padding-top: 50px;
        min-height: auto;
    }
    
    .opening-content {
        justify-content: flex-start;
        padding-top: 10px;
    }
    
    .deity-image {
        width: 70px;
        height: 70px;
        margin-bottom: 10px;
    }
    
    .subtitle {
        margin-bottom: 15px;
    }
    
    .divider {
        margin: 15px 0;
    }
    
    .stick-container-wrapper {
        justify-content: flex-start;
        padding-top: 10px;
    }
    
    .stick-container {
        width: 100px;
        height: 200px;
        margin-bottom: 10px;
    }
    
    .chatbot-messages {
        height: 180px;
    }
}

/* ==================== HIGH DPI / RETINA DISPLAYS ==================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .deity-image img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .stick-container.shaking {
        animation: none;
    }
    
    .golden-btn:hover,
    .secondary-btn:hover,
    .shake-btn:hover {
        transform: none;
    }
    
    .chatbot-message {
        animation: none;
    }
}

/* ==================== TOUCH DEVICE OPTIMIZATIONS ==================== */
@media (hover: none) and (pointer: coarse) {
    .golden-btn:hover,
    .secondary-btn:hover,
    .shake-btn:hover,
    .question-item:hover,
    .chatbot-send-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .golden-btn:active {
        transform: scale(0.98);
    }
    
    .secondary-btn:active {
        background: rgba(149, 0, 44, 0.3);
    }
    
    .chatbot-send-btn:active {
        transform: scale(0.95);
    }
    
    /* Larger touch targets */
    .language-dropdown {
        min-height: 44px;
    }
    
    .golden-btn,
    .secondary-btn,
    .shake-btn,
    .chatbot-send-btn {
        min-height: 48px;
    }
    
    .chatbot-input {
        min-height: 50px;
    }
    
    .stick-number-input {
        min-height: 48px;
    }
}

/* ==================== SAFE AREA INSETS (for notched devices) ==================== */
@supports (padding: max(0px)) {
    .screen {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .language-selector {
        right: max(10px, env(safe-area-inset-right));
    }
    
    .chatbot-input-area {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .language-selector,
    .chatbot-section,
    .action-buttons {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .screen {
        min-height: auto;
        padding: 20px;
    }
    
    .result-header,
    .content-section,
    .guidance-section {
        background: white;
        border: 1px solid #ccc;
    }
    
    .fortune-rank {
        background: #f0f0f0;
    }
    
    #app-title,
    .section-title,
    .result-number {
        color: black;
    }
}

/* ==================== SITE CHROME ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10000;
    background: rgba(26, 5, 5, 0.94);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(149, 0, 44, 0.35);
}

.site-header-inner,
.site-footer-inner {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #f0b30e;
    text-decoration: none;
    font-family: 'Noto Serif TC', 'Noto Serif SC', Georgia, serif;
    font-weight: 700;
    white-space: nowrap;
}

.site-brand-mark {
    font-size: 1.25rem;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.site-nav a,
.site-footer a,
.section-links a {
    text-decoration: none;
}

.site-nav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: #caa861;
    transition: 0.2s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a.active {
    color: #f0b30e;
    background: rgba(240, 179, 14, 0.08);
    outline: none;
}

.site-controls {
    display: flex;
    align-items: center;
}

.site-shell {
    width: 100%;
}

.screen {
    padding: 118px 20px 40px 20px;
}

.opening-content,
.result-wrapper {
    width: min(100%, 1040px);
}

.page-summary {
    width: 100%;
    margin-top: 26px;
    padding: 18px;
    border: 1px solid rgba(149, 0, 44, 0.35);
    border-radius: 8px;
    background: rgba(20, 8, 10, 0.76);
    text-align: left;
}

.page-summary h2 {
    color: #f0b30e;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.page-summary p {
    color: #ecdcbc;
    font-size: 0.95rem;
}

.section-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.section-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(149, 0, 44, 0.35);
    border-radius: 8px;
    color: #f0b30e;
    background: rgba(240, 179, 14, 0.05);
}

.site-footer {
    border-top: 1px solid rgba(149, 0, 44, 0.28);
    padding: 20px 0 28px;
}

.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.site-footer p {
    color: #caa861;
    font-size: 0.9rem;
}

.site-footer-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.site-footer-links a {
    color: #f0b30e;
    font-size: 0.9rem;
}

@media (max-width: 860px) {
    .site-header-inner {
        padding: 14px 0;
        align-items: flex-start;
        flex-direction: column;
    }

    .site-nav {
        justify-content: flex-start;
    }

    .site-controls {
        width: 100%;
    }

    .language-dropdown {
        width: 100%;
    }

    .screen {
        padding-top: 156px;
    }
}

@media (max-width: 640px) {
    .screen {
        padding-top: 172px;
    }

    .page-summary {
        padding: 16px;
    }

    .section-links {
        flex-direction: column;
    }
}
