:root {
    --dark-brown: #2e1f1c;
    --gold: #af9659;
    --dark-purple: #37262b;
    --slate-blue: #607683;
    --light-gray: #f5f5f5;
    --white: #ffffff;
    --text-color: #333333;
}

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

body {
    font-family: 'Pridi', serif;
    background-color: var(--slate-blue);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
    transition: all 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.overlay-active {
    overflow: hidden;
}

.container {
    max-width: 800px;
    margin: 0 auto 20px auto;
    background-color: var(--white);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.5s ease;
    flex: 1;
}

header {
    background-color: var(--gold);
    padding: 25px 20px;
    text-align: center;
    color: var(--dark-brown);
}

.title {
    font-size: 7rem;
    margin-bottom: 8px;
    font-weight: 700;
    line-height: 1em;
}

.main-content {
    padding: 25px;
}

/* แท็บแบบ Material Design */
.mode-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
    position: relative;
}

.mode-btn {
    flex: 1;
    padding: 12px 18px;
    border: none;
    background: transparent;
    font-family: 'Pridi', serif;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    position: relative;
    overflow: hidden;
}

.mode-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background-color: var(--gold);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.mode-btn.active {
    color: var(--dark-brown);
    font-weight: 600;
}

.mode-btn.active::after {
    width: 100%;
}

.mode-btn:hover {
    background-color: rgba(175, 150, 89, 0.1);
}

.mode-section {
    display: none;
}

.mode-section.active {
    display: block;
}

.input-area {
    background-color: var(--white);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#name-list {
    width: 100%;
    height: 140px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: 'Pridi', serif;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 18px;
    font-weight: 400;
}

.number-inputs {
    display: flex;
    gap: 15px;
    margin-bottom: 18px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark-brown);
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Pridi', serif;
    font-size: 3rem;
    font-weight: 400;
    text-align: center;
}

.options {
    margin-bottom: 18px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 400;
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 8px;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-container input:checked + .checkmark {
    background-color: var(--slate-blue);
    border-color: var(--slate-blue);
}

.checkbox-container input:checked + .checkmark::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.draw-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: var(--slate-blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Pridi', serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.draw-btn:hover {
    background-color: var(--dark-purple);
}

.history-log {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--light-gray);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #666;
    max-height: 150px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.history-log.hidden {
    display: none;
}

.history-item {
    padding: 5px 0;
    border-bottom: 1px solid #ddd;
}

.history-item:last-child {
    border-bottom: none;
}

/* Global footer outside container */
.global-footer {
    text-align: center;
    padding: 15px 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    width: 100%;
    max-width: 800px;
}

.global-footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.global-footer a:hover {
    color: rgba(255, 255, 255, 1);
    text-decoration: underline;
}

/* Fullscreen result overlay */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.result-overlay.active {
    opacity: 1;
    visibility: visible;
}

.result-overlay.final::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: linear-gradient(45deg, 
        #ff0000, #ff9900, #ffff00, #33ff00, 
        #0099ff, #6633ff, #cc00ff, #ff0000);
    background-size: 800% 800%;
    z-index: -1;
    animation: rainbowBorder 3s linear infinite;
    border-radius: 15px;
}

.fullscreen-result {
    font-size: 8vw;
    font-weight: 700;
    text-align: center;
    color: white;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    padding: 20px;
    max-width: 90%;
    word-break: break-word;
    transition: all 0.3s ease;
}

.fullscreen-result.drawing {
    font-size: 4vw; /* 50% ของ 8vw */
    color: white;
    animation: none;
}

.fullscreen-result.final {
    font-size: 16vw; /* 2 เท่าของ 8vw */
    animation: 
        continuousBounce 1.2s ease-in-out infinite,
        colorCycle 4s ease-in-out infinite;
}

/* Rainbow border animation */
@keyframes rainbowBorder {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Animation for result - กระโดดและเปลี่ยนสี */
@keyframes continuousBounce {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-15px);
    }
    50% {
        transform: translateY(0);
    }
    75% {
        transform: translateY(-8px);
    }
}

@keyframes colorCycle {
    0% {
        color: #ffffff; /* ขาว */
    }
    16% {
        color: #ffcccb; /* ชมพูอ่อน */
    }
    32% {
        color: #b5e9ff; /* ฟ้าอ่อน */
    }
    48% {
        color: #c8ffc8; /* เขียวอ่อน */
    }
    64% {
        color: #ffffb5; /* เหลืองอ่อน */
    }
    80% {
        color: #e0c3ff; /* ม่วงอ่อน */
    }
    100% {
        color: #ffffff; /* ขาว */
    }
}

/* Responsive design */
@media (max-width: 600px) {
    .title {
        font-size: 2.8rem;
    }
    
    .number-inputs {
        flex-direction: column;
        gap: 12px;
    }
    
    .mode-btn {
        padding: 10px 14px;
        font-size: 0.95rem;
    }
    
    .fullscreen-result {
        font-size: 12vw;
    }
    
    .fullscreen-result.drawing {
        font-size: 7vw; /* 50% ของ 12vw */
    }
    
    .fullscreen-result.final {
        font-size: 24vw; /* 2 เท่าของ 12vw */
    }
    
    .global-footer {
        font-size: 0.7rem;
        padding: 10px 0;
    }
}
