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

:root {
    --bg: #000000;
    --text: #ffffff;
    --text-dim: #999999;
    --accent: #ffffff;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    cursor: default;
}

.grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    z-index: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    animation: grain 8s steps(10) infinite;
}

.karuta-selector-wrapper {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.karuta-selector {
    padding: 12px 24px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    font-family: inherit;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='rgba(255,255,255,0.7)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.karuta-selector:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.karuta-selector:focus {
    border-color: rgba(255, 255, 255, 0.4);
}

.karuta-selector option {
    background: #000;
    color: #fff;
    padding: 12px;
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -25%); }
    40% { transform: translate(-5%, 25%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 15%); }
    80% { transform: translate(3%, 35%); }
    90% { transform: translate(-10%, 10%); }
}

.nav {
    position: fixed;
    top: 40px;
    right: 40px;
    display: flex;
    gap: 20px;
    z-index: 100;
}

.nav-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    color: rgba(255, 255, 255, 0.7);
}

.nav-btn svg {
    width: 20px;
    height: 20px;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
}

.container {
    max-width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    position: relative;
    z-index: 1;
}

.counter {
    position: absolute;
    top: 50px;
    left: 50px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.yojijukugo-display {
    font-family: "Zen Maru Gothic", sans-serif;
    font-size: clamp(4rem, 15vw, 12rem);
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text);
    text-align: center;
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 40px;
    position: relative;
    transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.3),
        0 0 40px rgba(255, 255, 255, 0.15);
    animation: textGlow 4s ease-in-out infinite;
}

@keyframes textGlow {
    0%, 100% {
        text-shadow:
            0 0 20px rgba(255, 255, 255, 0.3),
            0 0 40px rgba(255, 255, 255, 0.15);
    }
    50% {
        text-shadow:
            0 0 25px rgba(255, 255, 255, 0.4),
            0 0 50px rgba(255, 255, 255, 0.2);
    }
}

.yojijukugo-display:empty {
    opacity: 0;
}

.status-minimal {
    position: absolute;
    bottom: 50px;
    left: 50px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.controls {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 10;
}

.ctrl-btn {
    width: 64px;
    height: 64px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    color: rgba(255, 255, 255, 0.8);
    position: relative;
}

.ctrl-btn svg {
    width: 24px;
    height: 24px;
}

.ctrl-btn::after {
    content: attr(data-key);
    position: absolute;
    bottom: -24px;
    font-size: 10px;
    letter-spacing: 0.1em;
    opacity: 0.5;
    font-weight: 500;
}

.ctrl-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

.ctrl-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.ctrl-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.ctrl-btn-primary {
    width: 80px;
    height: 80px;
    border-width: 2px;
}

.ctrl-btn-primary svg {
    width: 32px;
    height: 32px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 80px 60px 60px;
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

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

.modal-close {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
}

.modal-close:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
    transform: rotate(90deg);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

h2 {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 40px;
    color: var(--text-dim);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-row:last-of-type {
    border-bottom: none;
}

.setting-row label {
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--text);
}

.setting-row input[type="number"] {
    width: 80px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.setting-row input[type="number"]:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.02);
}

/* Card List */
.card-list {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding: 100px 40px 40px;
    overflow-y: auto;
    z-index: 999;
    transform: translateX(0);
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.card-list.hidden {
    transform: translateX(100%);
}

.card-list::-webkit-scrollbar {
    width: 2px;
}

.card-list::-webkit-scrollbar-track {
    background: transparent;
}

.card-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.card-list ul {
    list-style: none;
}

.card-list li {
    padding: 16px 0;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.card-list li:hover {
    color: var(--text);
    padding-left: 8px;
}

.card-list li.current {
    color: var(--text);
    font-weight: 500;
}

.card-list li.played {
    opacity: 0.3;
}

@media (max-width: 768px) {
    .karuta-selector-wrapper {
        top: 30px;
    }

    .karuta-selector {
        padding: 10px 32px 10px 16px;
        font-size: 12px;
    }

    .nav {
        top: 20px;
        right: 20px;
        gap: 12px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
    }

    .counter {
        top: 30px;
        left: 30px;
        font-size: 12px;
    }

    .status-minimal {
        bottom: 30px;
        left: 30px;
        font-size: 11px;
    }

    .yojijukugo-display {
        font-size: clamp(2.5rem, 12vw, 8rem);
    }

    .controls {
        bottom: 40px;
        gap: 12px;
    }

    .ctrl-btn {
        width: 56px;
        height: 56px;
    }

    .ctrl-btn-primary {
        width: 72px;
        height: 72px;
    }

    .modal-content {
        padding: 60px 40px 40px;
    }

    .card-list {
        width: 100%;
    }
}
