/* ==========================================================================
   KANA RAIN — NIHONGODOYA MINI-GAME STYLESHEET
   Neo-Brutalist Game UI with Watery Mist Palette
   ========================================================================== */

.kr-game-container {
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    padding: 0 12px 40px;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   PRE-GAME SETUP SCREEN
   -------------------------------------------------------------------------- */
.kr-card {
    background: #ffffff;
    border: 2.5px solid var(--ink, #111827);
    border-radius: 16px;
    box-shadow: 4px 4px 0px var(--ink, #111827);
    padding: 28px 24px;
    box-sizing: border-box;
    margin: 0 auto 24px;
}

.kr-setup-header {
    text-align: center;
    margin-bottom: 24px;
}

.kr-setup-title {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 2rem;
    font-weight: 800;
    color: var(--ink, #111827);
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.kr-setup-title i {
    color: #2563eb;
}

.kr-setup-subtitle {
    font-size: 0.98rem;
    color: var(--ink-muted, #475569);
    margin: 0;
    font-weight: 500;
}

.kr-option-group {
    margin-bottom: 20px;
}

.kr-option-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted, #475569);
    margin-bottom: 8px;
}

.kr-chips-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.kr-chip {
    flex: 1;
    min-width: 90px;
    padding: 10px 14px;
    border: 2px solid var(--ink, #111827);
    border-radius: 12px;
    background: #ffffff;
    color: var(--ink, #111827);
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 2px 2px 0px var(--ink, #111827);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
    text-align: center;
    user-select: none;
}

.kr-chip:hover {
    transform: translateY(-1px);
    box-shadow: 3px 3px 0px var(--ink, #111827);
    background: #f8fafc;
}

.kr-chip.active {
    background: var(--yellow, #fde047);
    color: var(--ink, #111827);
    box-shadow: 1px 1px 0px var(--ink, #111827);
    transform: translate(1px, 1px);
    border-color: var(--ink, #111827);
}

.kr-chip:focus-visible {
    outline: 2px solid var(--ink, #111827);
    outline-offset: 2px;
}

.kr-high-score-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-soft-aqua, #ecf8f6);
    border: 1.5px solid var(--teal, #0d9488);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--teal-hover, #0f766e);
}

.kr-high-score-banner span i {
    color: #f59e0b;
    margin-right: 6px;
}

/* --------------------------------------------------------------------------
   IN-GAME HUD (HEADS-UP DISPLAY)
   -------------------------------------------------------------------------- */
.kr-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    border: 2.5px solid var(--ink, #111827);
    border-radius: 14px;
    box-shadow: 3px 3px 0px var(--ink, #111827);
    padding: 10px 16px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.kr-hud-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kr-hud-item {
    display: flex;
    flex-direction: column;
}

.kr-hud-label {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-light, #64748b);
    line-height: 1;
    margin-bottom: 3px;
}

.kr-hud-val {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ink, #111827);
    line-height: 1.1;
}

.kr-multiplier-badge {
    background: var(--yellow-light, #fef9c3);
    border: 1.5px solid var(--ink, #111827);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink, #111827);
    box-shadow: 1px 1px 0px var(--ink, #111827);
    transition: transform 0.15s ease;
}

.kr-multiplier-badge.bounce {
    transform: scale(1.2);
}

.kr-lives-container {
    display: flex;
    gap: 4px;
    align-items: center;
}

.kr-heart {
    color: var(--coral, #ef4444);
    font-size: 1.15rem;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.kr-heart.lost {
    color: #cbd5e1;
    opacity: 0.45;
    transform: scale(0.85);
}

.kr-hud-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--ink, #111827);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink, #111827);
    box-shadow: 2px 2px 0px var(--ink, #111827);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.1s ease;
    padding: 0;
}

.kr-hud-btn:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 3px 3px 0px var(--ink, #111827);
}

.kr-hud-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px var(--ink, #111827);
}

/* --------------------------------------------------------------------------
   PLAYFIELD / GAME STAGE
   -------------------------------------------------------------------------- */
.kr-playfield-wrapper {
    position: relative;
    width: 100%;
}

.kr-playfield {
    position: relative;
    width: 100%;
    height: 480px;
    background-color: var(--bg-soft-blue, #f0f7fa);
    background-image:
        radial-gradient(var(--ink-light, #94a3b8) 0.75px, transparent 0.75px);
    background-size: 24px 24px;
    background-position: 0 0;
    border: 2.5px solid var(--ink, #111827);
    border-radius: 16px;
    box-shadow: 4px 4px 0px var(--ink, #111827);
    overflow: hidden;
    box-sizing: border-box;
    user-select: none;
    touch-action: manipulation;
}

/* Danger Line */
.kr-danger-line {
    position: absolute;
    bottom: 64px;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2.5px dashed var(--coral, #ef4444);
    z-index: 8;
    pointer-events: none;
}

.kr-danger-badge {
    position: absolute;
    right: 14px;
    top: -11px;
    background: var(--coral-light, #fee2e2);
    color: var(--coral, #ef4444);
    border: 1.5px solid var(--coral, #ef4444);
    font-size: 10px;
    font-weight: 800;
    padding: 1px 8px;
    border-radius: 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.4;
}

.kr-danger-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: linear-gradient(to bottom, rgba(239, 68, 68, 0.03), rgba(239, 68, 68, 0.14));
    pointer-events: none;
    z-index: 6;
}

/* --------------------------------------------------------------------------
   KANA DROP TILE COMPONENT
   -------------------------------------------------------------------------- */
.kr-tile {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 2px solid var(--ink, #111827);
    background: #ffffff;
    box-shadow: 2px 2px 0px var(--ink, #111827);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-sizing: border-box;
    cursor: default;
    will-change: transform;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.kr-tile-char {
    font-family: "Noto Sans JP", "Outfit", -apple-system, sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--ink, #111827);
    line-height: 1;
    pointer-events: none;
}

/* Active Target Styling */
.kr-tile.is-target {
    background: var(--yellow-light, #fef9c3);
    border: 2.5px solid var(--ink, #111827);
    box-shadow: 3px 3px 0px var(--ink, #111827), 0 0 0 3px rgba(253, 224, 71, 0.85);
    z-index: 12;
}

.kr-tile.is-target::before {
    content: "TARGET";
    position: absolute;
    top: -19px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink, #111827);
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.3;
    pointer-events: none;
    box-shadow: 1px 1px 0px rgba(0,0,0,0.2);
}

/* Pop/Burst when answered correctly */
.kr-tile.is-popped {
    animation: krPop 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
}

@keyframes krPop {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    45% {
        transform: scale(1.28);
        background: #ccfbf1;
        border-color: #0f766e;
        opacity: 0.95;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Missed / Danger line breach */
.kr-tile.is-missed {
    animation: krMiss 0.32s ease forwards;
    pointer-events: none;
}

@keyframes krMiss {
    0% {
        transform: scale(1);
        background: #fee2e2;
        border-color: #ef4444;
    }
    50% {
        transform: translateY(12px) scale(0.9);
        opacity: 0.8;
    }
    100% {
        transform: translateY(28px) scale(0.7);
        opacity: 0;
    }
}

/* Floating score text feedback */
.kr-floating-score {
    position: absolute;
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 15px;
    font-weight: 800;
    color: #0f766e;
    background: #ccfbf1;
    border: 1.5px solid #0f766e;
    border-radius: 6px;
    padding: 1px 6px;
    pointer-events: none;
    z-index: 20;
    box-shadow: 1px 1px 0px var(--ink, #111827);
    animation: krFloatScore 0.75s ease-out forwards;
}

@keyframes krFloatScore {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(0.9);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -16px) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -36px) scale(1);
    }
}

/* --------------------------------------------------------------------------
   INPUT CONTROLS (DESKTOP & MOBILE)
   -------------------------------------------------------------------------- */
.kr-controls-bar {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kr-desktop-input-wrap {
    position: relative;
    width: 100%;
}

.kr-text-input {
    width: 100%;
    min-height: 52px;
    border: 2.5px solid var(--ink, #111827);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 3px 3px 0px var(--ink, #111827);
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    color: var(--ink, #111827);
    box-sizing: border-box;
    padding: 0 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.kr-text-input:focus {
    outline: none;
    border-color: var(--ink, #111827);
    box-shadow: 4px 4px 0px var(--ink, #111827), 0 0 0 3.5px rgba(254, 224, 71, 0.55);
    transform: translateY(-1px);
}

.kr-text-input.wrong {
    animation: krShake 0.3s ease;
    border-color: var(--coral, #ef4444);
    box-shadow: 3px 3px 0px var(--coral, #ef4444);
}

@keyframes krShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Mobile Multiple Choice Grid */
.kr-choices-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
}

.kr-choice-btn {
    min-height: 52px;
    border: 2px solid var(--ink, #111827);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 2.5px 2.5px 0px var(--ink, #111827);
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ink, #111827);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
    user-select: none;
    touch-action: manipulation;
}

.kr-choice-btn:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 3.5px 3.5px 0px var(--ink, #111827);
}

.kr-choice-btn:active {
    transform: translate(1.5px, 1.5px);
    box-shadow: 1px 1px 0px var(--ink, #111827);
    background: var(--yellow-light, #fef9c3);
}

.kr-choice-btn.choice-wrong {
    background: #fee2e2;
    border-color: #ef4444;
    color: #dc2626;
}

.kr-choice-btn.choice-right {
    background: #ccfbf1;
    border-color: #0f766e;
    color: #0f766e;
}

.kr-input-mode-toggle {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.kr-mode-toggle-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-muted, #475569);
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 8px;
}

.kr-mode-toggle-btn:hover {
    color: var(--ink, #111827);
}

/* --------------------------------------------------------------------------
   PAUSE OVERLAY & CONFIRMATION MODAL
   -------------------------------------------------------------------------- */
.kr-overlay {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 16px;
    box-sizing: border-box;
}

.kr-modal {
    background: #ffffff;
    border: 2.5px solid var(--ink, #111827);
    border-radius: 16px;
    box-shadow: 6px 6px 0px var(--ink, #111827);
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-sizing: border-box;
    animation: krModalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes krModalPop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.kr-modal-title {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ink, #111827);
    margin: 0 0 8px 0;
}

.kr-modal-text {
    font-size: 0.95rem;
    color: var(--ink-muted, #475569);
    margin: 0 0 20px 0;
}

.kr-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --------------------------------------------------------------------------
   GAME OVER / RESULTS SCREEN
   -------------------------------------------------------------------------- */
.kr-gameover-card {
    background: #ffffff;
    border: 2.5px solid var(--ink, #111827);
    border-radius: 16px;
    box-shadow: 5px 5px 0px var(--ink, #111827);
    padding: 32px 24px;
    box-sizing: border-box;
    text-align: center;
    animation: krModalPop 0.25s ease-out;
}

.kr-gameover-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fee2e2;
    color: #dc2626;
    border: 1.5px solid #dc2626;
    border-radius: 9999px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.kr-gameover-title {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--ink, #111827);
    margin: 0 0 4px 0;
}

.kr-final-score {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 3rem;
    font-weight: 800;
    color: var(--ink, #111827);
    margin: 4px 0 18px 0;
    line-height: 1;
}

.kr-new-high-badge {
    display: inline-block;
    background: var(--yellow, #fde047);
    border: 1.5px solid var(--ink, #111827);
    border-radius: 6px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 20px;
    box-shadow: 1.5px 1.5px 0px var(--ink, #111827);
}

.kr-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.kr-stat-box {
    background: var(--bg-subtle, #f0f4f3);
    border: 1.5px solid var(--border-muted, #cbd5e1);
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
}

.kr-stat-box-num {
    font-family: var(--font-heading, 'Outfit', sans-serif);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--ink, #111827);
    line-height: 1.1;
}

.kr-stat-box-lbl {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--ink-muted, #475569);
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* Missed Kana Section */
.kr-missed-section {
    background: #fff;
    border: 1.5px solid var(--border-muted, #cbd5e1);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 24px;
    text-align: left;
}

.kr-missed-title {
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-muted, #475569);
    margin: 0 0 8px 0;
}

.kr-missed-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.kr-missed-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fee2e2;
    border: 1.5px solid #fca5a5;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #991b1b;
}

.kr-missed-item .char {
    font-size: 1.05rem;
}

.kr-gameover-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* --------------------------------------------------------------------------
   RESPONSIVE DESIGN (TABLET & MOBILE)
   -------------------------------------------------------------------------- */
@media (max-width: 680px) {
    .kr-game-container {
        padding: 0 8px 30px;
    }

    .kr-card {
        padding: 20px 16px;
    }

    .kr-setup-title {
        font-size: 1.6rem;
    }

    .kr-playfield {
        height: 420px;
    }

    .kr-tile {
        width: 48px;
        height: 48px;
    }

    .kr-tile-char {
        font-size: 22px;
    }

    .kr-danger-line {
        bottom: 56px;
    }

    .kr-danger-zone {
        height: 56px;
    }

    .kr-choices-grid {
        gap: 8px;
    }

    .kr-choice-btn {
        min-height: 48px;
        font-size: 1.05rem;
    }

    .kr-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .kr-stat-box {
        padding: 10px 4px;
    }

    .kr-stat-box-num {
        font-size: 1.15rem;
    }

    .kr-gameover-actions {
        flex-direction: column;
    }

    .kr-gameover-actions .brutal-btn {
        width: 100%;
    }
}
