:root {
    --color-bg: #2D2D2D;
    --color-card: #FFD166;
    --color-text: #FFFFFF;
    --color-correct: #7FB069;
    --color-wrong: #D96459;
    --color-blue: #2E5EAA;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

body.high-contrast {
    --color-bg: #000000;
    --color-text: #FFFFFF;
    --color-card: #FFFF00;
}

body.large-text {
    font-size: 18px;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    padding: 20px;
    position: absolute;
}

.screen.active {
    display: flex;
    z-index: 10;
}

.screen h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.btn-mode {
    width: 100%;
    padding: 20px;
    background: #404040;
    border: 2px solid #404040;
    border-radius: 12px;
    font-size: 1.1rem;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-category {
    padding: 15px 10px;
    background: #404040;
    border: 2px solid #404040;
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-mode:hover, .btn-category:hover {
    background: var(--color-card);
    color: #1A1A1A;
    border-color: var(--color-card);
    transform: translateY(-2px);
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 600px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 500px;
}

.btn-difficulty {
    padding: 25px 15px;
    background: #404040;
    border: 2px solid #404040;
    border-radius: 12px;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.btn-difficulty:hover {
    background: var(--color-card);
    color: #1A1A1A;
    border-color: var(--color-card);
}

.btn-settings {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #404040;
    border: none;
    border-radius: 50%;
    color: var(--color-text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.btn-settings:hover {
    background: var(--color-card);
    color: #1A1A1A;
}

.btn-primary {
    padding: 15px 40px;
    background: var(--color-card);
    color: #1A1A1A;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 30px;
}

.btn-primary:hover {
    background: #FFE082;
    transform: translateY(-2px);
}

.btn-icon {
    width: 45px;
    height: 45px;
    background: #404040;
    border: none;
    border-radius: 50%;
    color: var(--color-text);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--color-card);
    color: #1A1A1A;
}

/* Game Screen */
#gameScreen {
    padding: 15px;
    position: relative;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 0;
    margin-bottom: 20px;
    z-index: 5;
}

.left, .right {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stat {
    font-size: 1.2rem;
    font-weight: 600;
}

.timer-bar {
    width: 100%;
    height: 8px;
    background: #404040;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 30px;
}

#timerFill {
    height: 100%;
    background: var(--color-blue);
    width: 100%;
    transition: width 1s linear, background 0.3s;
}

.game-area {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Corners */
.corner {
    position: absolute;
    width: 50%;
    height: 50%;
    opacity: 0.05;
    pointer-events: none;
}

.corner.nw { top: 0; left: 0; background: #FF6B6B; }
.corner.ne { top: 0; right: 0; background: #4ECDC4; }
.corner.sw { bottom: 0; left: 0; background: #FFE66D; }
.corner.se { bottom: 0; right: 0; background: #95E1D3; }

/* Answers (no boxes) */
.answer {
    position: absolute;
    font-size: 3.9rem;
    font-weight: 700;
    color: var(--color-text);
    pointer-events: none;
    user-select: none;
    z-index: 1;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
	text-transform: uppercase;
}

.answer:hover {
    transform: scale(1.1);
}

.answer-nw { top: 12%; left: 12%; }
.answer-ne { top: 12%; right: 12%; }
.answer-sw { bottom: 12%; left: 12%; }
.answer-se { bottom: 12%; right: 12%; }

/* Card */
.card {
    position: absolute;
    width: 280px;
    height: 280px;
    background: var(--color-card);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    touch-action: none;
    z-index: 2;
    transition: transform 0.3s, opacity 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    will-change: transform;
}

.card:active {
    cursor: grabbing;
}

.card.paused {
    opacity: 0.5 !important;
    pointer-events: none !important;
    cursor: not-allowed;
    filter: grayscale(50%);
}

#character {
    font-size: 8rem;
    font-weight: bold;
    color: #1A1A1A;
    font-family: 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif;
    pointer-events: none;
}

/* End Screen */
.stats {
    background: #404040;
    border-radius: 15px;
    padding: 30px;
    width: 100%;
    max-width: 450px;
    margin: 20px 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.stat-row:last-child {
    border-bottom: none;
    font-weight: 600;
    background: rgba(255, 209, 102, 0.1);
    padding: 15px;
    border-radius: 8px;
}

.stat-row span:last-child {
    color: var(--color-card);
    font-weight: 600;
}

/* Pause Overlay */
.pause-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 50;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 20px;
}

.pause-overlay.active {
    display: flex;
}

.pause-text {
    font-size: 3rem;
    font-weight: bold;
    color: var(--color-card);
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: pulse 1.5s ease-in-out infinite;
}

.pause-hint {
    font-size: 1.2rem;
    color: var(--color-text);
    text-align: center;
    opacity: 0.8;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Particles */
.particle {
    position: absolute;
    font-size: 2rem;
    pointer-events: none;
    animation: float-up 0.8s ease-out forwards;
    z-index: 100;
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0.5);
    }
}

/* Feedback */
#feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: bold;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#feedback.correct {
    color: var(--color-correct);
}

#feedback.wrong {
    color: var(--color-wrong);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: #404040;
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    width: 100%;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.modal-content label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    cursor: pointer;
    font-size: 1.1rem;
}

.modal-content input, .modal-content select {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.modal-content select {
    padding: 8px;
    background: #1A1A1A;
    color: var(--color-text);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    margin-left: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .card {
        width: 220px;
        height: 220px;
    }
    
    #character {
        font-size: 6rem;
    }
    
    .answer {
        font-size: 3.6rem;
    }
    
    .corner {
        opacity: 0.08;
    }
    
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 100%;
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .card {
        width: 180px;
        height: 180px;
    }
    
    #character {
        font-size: 4.5rem;
    }
    
    .answer {
        font-size: 3.3rem;
    }
    
    .screen h1 {
        font-size: 2rem;
    }
    
    .btn-mode, .btn-category, .btn-primary {
        padding: 15px;
        font-size: 1rem;
    }
    
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 100%;
        padding: 0 10px;
    }
    
    .btn-category {
        padding: 12px 8px;
        font-size: 0.85rem;
    }
}
