/* ==========================================================================
   Hiragana Sensei - Design System & Stylesheet (Grid Layout)
   ========================================================================== */

/* Design Tokens & Variables */
:root {
    --bg-dark: #07050f;
    --bg-surface: rgba(20, 16, 38, 0.65);
    --card-glass: rgba(28, 22, 54, 0.45);
    --card-glass-hover: rgba(38, 30, 74, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    
    /* Colors */
    --primary: #9333ea;
    --primary-glow: rgba(147, 51, 234, 0.5);
    --secondary: #ec4899;
    --secondary-glow: rgba(236, 72, 153, 0.4);
    --cyan: #06b6d4;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    
    /* Text colors */
    --text-main: #f3f1f8;
    --text-muted: #9c97b0;
    
    /* Layout Constants */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base Reset & Configuration */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    height: -webkit-fill-available;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100%;
    height: -webkit-fill-available;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Ambient Glow Orbs */
.ambient-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -50px;
    left: -50px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* App Wrapper for Desktop Center-Fitting */
.app-frame {
    z-index: 10;
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 920px;
    display: flex;
    flex-direction: column;
    position: relative;
}

@media (min-width: 481px) {
    .app-frame {
        border-radius: 32px;
        border: 4px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 
                    0 0 40px rgba(147, 51, 234, 0.15);
        overflow: hidden;
        background: #080612;
    }
}

/* App Core Container */
.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(10, 8, 20, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
}

/* Header Styling */
.app-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-japanese {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 900;
    font-size: 24px;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 10px rgba(236, 72, 153, 0.2);
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.logo-text span {
    color: var(--secondary);
    font-weight: 800;
}

/* Main Display Workspace */
.app-main {
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.practice-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 16px;
}

/* Card Visual Core */
.card-area {
    display: flex;
    justify-content: center;
}

.card-outer {
    width: 100%;
    aspect-ratio: 1.3 / 1;
    background: linear-gradient(135deg, var(--card-glass), rgba(15, 10, 30, 0.6));
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transition: all 0.3s ease;
}

.card-outer.correct {
    border-color: var(--success);
    box-shadow: 0 0 30px var(--success-glow), inset 0 0 15px rgba(16, 185, 129, 0.1);
}

.card-outer.incorrect {
    border-color: var(--danger);
    box-shadow: 0 0 30px var(--danger-glow), inset 0 0 15px rgba(239, 68, 68, 0.1);
}

/* Character Display details */
.char-display-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.char-hiragana {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 175px;
    font-weight: 500;
    line-height: 1;
    color: var(--text-main);
    user-select: none;
    transition: transform 0.2s ease;
}

.char-correct-romaji {
    font-size: 24px;
    font-weight: 800;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 8px;
    line-height: 1.2;
    user-select: none;
    transition: transform 0.2s ease;
}

.char-correct-romaji:empty {
    display: none;
}

.clickable-advance {
    cursor: pointer;
}

.clickable-advance:hover, .clickable-advance:active {
    transform: scale(1.05);
}

/* Selection Grid Panels (Fully Visible, No Scrolling) */
.selection-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.selection-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selection-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding-left: 2px;
}

.selection-grid {
    display: grid;
    gap: 8px;
}

.grid-consonants {
    grid-template-columns: repeat(5, 1fr); /* 5x2 layout */
}

.grid-vowels {
    grid-template-columns: repeat(6, 1fr); /* 6x1 layout */
}

/* Rounded Button styles */
.btn-select {
    width: 100%;
    height: 44px;
    background: var(--card-glass);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-select:hover, .btn-select:active {
    background: var(--card-glass-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-select.selected {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 4px 12px var(--primary-glow);
    transform: scale(0.95);
}

/* Filters Panel Styling */
.filters-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.filter-grid {
    display: grid;
    gap: 6px;
    width: 100%;
}

.grid-consonant-filters {
    grid-template-columns: repeat(5, 1fr);
}

.grid-vowel-filters {
    grid-template-columns: repeat(6, 1fr);
}

.btn-filter {
    background: var(--card-glass);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    height: 32px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-filter:hover, .btn-filter:active {
    background: var(--card-glass-hover);
    color: var(--text-main);
}

.btn-filter.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.hidden {
    display: none !important;
}
