/* ==========================================================================
   HiraganaType CSS Design System (Premium Glassmorphic Dark Theme)
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #090a12;
  --bg-secondary: #121424;
  --panel-bg: rgba(22, 25, 49, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --accent: #7c3aed; /* Violet */
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.35);
  
  --correct: #10b981; /* Emerald Green */
  --correct-glow: rgba(16, 185, 129, 0.25);
  
  --error: #ef4444; /* Ruby Red */
  --error-glow: rgba(239, 68, 68, 0.25);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Fonts */
  --font-sans: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
  --font-japanese: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
  
  /* Borders & Shadows */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base resets & layouts
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Ambient Background Orbs */
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.3;
  pointer-events: none;
}
.orb-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  top: -100px;
  left: -100px;
  animation: floatOrb 20s infinite alternate ease-in-out;
}
.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
  bottom: -150px;
  right: -100px;
  animation: floatOrb 25s infinite alternate-reverse ease-in-out;
}
.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #ec4899 0%, transparent 70%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.15;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 80px) scale(1.1); }
}

/* App Containers */
.app-container {
  width: 100%;
  max-width: 1100px;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-col: column;
  flex-direction: column;
  justify-content: space-between;
}

/* Glassmorphism Panel Class */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-glow);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.app-header {
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-radius: var(--radius-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.logo-text {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-badge {
  font-size: 1.4rem;
  animation: pulse-glow 2s infinite alternate;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   Buttons UI
   ========================================================================== */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}
.btn-secondary.active {
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent-light);
  border-color: rgba(124, 58, 237, 0.4);
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(167, 139, 250, 0.5);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-glow {
  position: relative;
  overflow: hidden;
}
.btn-glow::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  transition: 0.5s;
  pointer-events: none;
}
.btn-glow:hover::after {
  left: 120%;
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent-light);
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: background var(--transition-fast);
}
.btn-text:hover {
  background: rgba(167, 139, 250, 0.12);
}

/* ==========================================================================
   Screen & Navigation
   ========================================================================== */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.screen {
  display: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.screen.active {
  display: block;
  opacity: 1;
  animation: fadeIn 0.4s ease-out forwards;
}

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

.text-center { text-align: center; }
.flex-col { display: flex; flex-direction: column; }
.justify-between { justify-content: space-between; }
.flex-grow { flex-grow: 1; }

/* ==========================================================================
   SETUP SCREEN (LANDING)
   ========================================================================== */
.hero-section {
  margin: 20px 0 40px;
}
.hero-section h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
  background: linear-gradient(to right, #ffffff, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.15rem;
  max-width: 650px;
  margin: 0 auto;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}
.setup-card {
  padding: 32px;
  min-height: 420px;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title i {
  color: var(--accent-light);
}

/* Modes Selection */
.mode-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}
.mode-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.mode-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}
.mode-card.active {
  background: rgba(124, 58, 237, 0.12);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.15);
}

.mode-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: all var(--transition-fast);
}
.mode-card.active .mode-icon {
  background: var(--accent);
  color: white;
}

.mode-info h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.mode-info p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Custom Selection Box */
.custom-selection-box {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 20px;
  display: none; /* Controlled by JS */
}
.custom-selection-box.active {
  display: block;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.selection-header h4 {
  font-size: 0.95rem;
  color: var(--text-main);
}
.selection-actions {
  display: flex;
  gap: 12px;
}

.custom-kana-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 8px;
}
/* Scrollbar custom for kana pool */
.custom-kana-grid::-webkit-scrollbar {
  width: 5px;
}
.custom-kana-grid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.custom-kana-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Premium Custom Checkboxes */
.check-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: all var(--transition-fast);
}
.check-container:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}
.check-container input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Time & Style Options */
.time-options, .romaji-style-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 32px;
}
.romaji-style-options {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 24px;
}
.btn-time, .btn-style {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
}
.btn-time:hover, .btn-style:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}
.btn-time.active, .btn-style.active {
  background: rgba(124, 58, 237, 0.15);
  border-color: var(--accent);
  color: var(--accent-light);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.1);
}

/* Rules / Guides */
.rules-container {
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  padding: 20px;
  border-radius: var(--radius-md);
}
.rules-container h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rules-container ul {
  list-style: none;
}
.rules-container li {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}
.rules-container li:last-child {
  margin-bottom: 0;
}
.badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 18px;
  height: 18px;
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent-light);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
  margin-top: 2px;
}

/* ==========================================================================
   GAME SCREEN
   ========================================================================== */
.stats-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 18px 24px;
  margin-bottom: 24px;
}
.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-sans);
}

.text-accent { color: var(--accent-light); }
.text-correct { color: var(--correct); }
.text-error { color: var(--error); }

/* Hidden Keyboard Capture */
.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  z-index: -999;
}

/* Display Arena */
.display-container {
  position: relative;
  min-height: 240px;
  padding: 36px 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
  overflow: hidden;
  cursor: text;
}

/* Focus alert overlay */
.focus-alert {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 11, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.focus-alert.active {
  opacity: 1;
  pointer-events: auto;
}
.focus-alert i {
  font-size: 2.5rem;
  color: var(--accent-light);
}
.focus-alert span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

/* Translation and meaning tips */
.translation-tip {
  margin-bottom: 24px;
  min-height: 24px;
  text-align: center;
  transition: opacity var(--transition-normal);
}
.jp-translation-text {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 500;
}

/* Kana Display Grid Area */
.typing-text-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 6px;
  max-width: 90%;
  margin-bottom: 30px;
}

/* Kana Character Block Stylings */
.kana-char {
  font-family: var(--font-japanese);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-main); /* Default neutral is white */
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.kana-char.neutral {
  color: #ffffff; /* Explicitly white */
}

.kana-char.correct {
  color: var(--correct);
  text-shadow: 0 0 10px var(--correct-glow);
}

.kana-char.error {
  color: var(--error);
  text-shadow: 0 0 10px var(--error-glow);
  animation: shake 0.25s ease-in-out;
}

.kana-char.active {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.kana-char.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 20%;
  width: 60%;
  height: 4px;
  background: var(--accent-light);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-light);
  animation: pulse-glow 1.5s infinite alternate;
}

/* Keyboard animations & error shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

@keyframes pulse-glow {
  0% { opacity: 0.4; box-shadow: 0 0 2px var(--accent-light); }
  100% { opacity: 1; box-shadow: 0 0 12px var(--accent-light); }
}

/* Romaji input and guide */
.active-input-feedback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.current-romaji-input {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-main);
  min-height: 32px;
  text-transform: lowercase;
}
.current-romaji-input::after {
  content: '|';
  color: var(--accent-light);
  animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
  50% { opacity: 0; }
}

.romaji-guide-tip {
  font-size: 0.88rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateY(5px);
  transition: all var(--transition-normal);
}
.romaji-guide-tip.visible {
  opacity: 1;
  transform: translateY(0);
}
.romaji-guide-tip .kbd-key {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-weight: bold;
  color: var(--text-main);
  font-size: 0.8rem;
}

/* Game Controls buttons */
.game-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 30px;
}


/* ==========================================================================
   RESULTS SCREEN
   ========================================================================== */
#results-screen {
  padding: 16px;
}
.results-container {
  max-width: 650px;
  margin: 0 auto;
  padding: 42px;
  position: relative;
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
#confetti-canvas {
  width: 100%;
  height: 100%;
}

.results-header {
  margin-bottom: 32px;
  z-index: 2;
  position: relative;
}
.result-badge {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: inline-block;
  animation: floatOrb 4s infinite alternate ease-in-out;
}
#result-title {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.text-muted { color: var(--text-muted); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 36px;
  z-index: 2;
  position: relative;
}
.result-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.result-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
}
.text-success { color: var(--correct); }

.results-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 2;
  position: relative;
}

/* ==========================================================================
   MODALS (KANA CHART)
   ========================================================================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 9, 18, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal.active {
  display: flex;
  animation: fadeIn 0.3s ease forwards;
}

.modal-content {
  width: 90%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 16px;
}
.modal-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header h2 i {
  color: var(--accent-light);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}
.btn-close:hover {
  color: var(--text-main);
}

.modal-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px 0;
}
/* Modal body scrollbar */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.chart-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 10px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 8px 16px;
  font-size: 0.92rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
}
.tab-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}
.tab-btn.active {
  background: rgba(124, 58, 237, 0.12);
  color: var(--accent-light);
}

/* Kana Grid Layout inside Modal */
.chart-grid-container {
  display: none;
}
.chart-grid-container.active {
  display: grid;
  gap: 12px;
}

#chart-gojuon.active {
  grid-template-columns: repeat(5, 1fr);
}
#chart-dakuon.active {
  grid-template-columns: repeat(5, 1fr);
}
#chart-yoon.active {
  grid-template-columns: repeat(3, 1fr);
}

/* Kana Card items */
.chart-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.chart-card:hover {
  background: rgba(124, 58, 237, 0.15);
  border-color: var(--accent);
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.15);
}
.chart-card.empty {
  opacity: 0.1;
  pointer-events: none;
  background: transparent;
  border: none;
}

.chart-kana {
  font-family: var(--font-japanese);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.chart-romaji {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: lowercase;
}

.modal-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
  margin-top: 12px;
}

/* ==========================================================================
   Responsive Design Breakpoints
   ========================================================================== */
@media (max-width: 900px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
  .hero-section h1 {
    font-size: 2.2rem;
  }
}

@media (max-width: 680px) {
  .stats-header {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kana-char {
    font-size: 2.2rem;
  }

  #chart-gojuon.active, #chart-dakuon.active {
    grid-template-columns: repeat(5, 1fr);
  }
  .chart-kana {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 12px 16px;
  }
  .header-actions span {
    display: none;
  }
  .btn-large {
    padding: 12px 20px;
    font-size: 1rem;
  }
  .display-container {
    padding: 24px 16px;
  }
  .kana-char {
    font-size: 1.8rem;
  }
}

/* ==========================================================================
   Study Library Styles (Word Bank & Sentence Bank)
   ========================================================================== */
.library-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.lib-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 8px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.lib-tab-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.lib-tab-btn.active {
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: var(--accent-light);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.1);
}

.library-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

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

/* Search Box */
.search-box-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Word Bank & Sentence Bank grids */
.bank-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  max-height: 48vh;
  overflow-y: auto;
  padding: 8px 4px;
}

/* Scrollbar styling for library grids */
.bank-list-grid::-webkit-scrollbar {
  width: 6px;
}
.bank-list-grid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.bank-list-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Bank Cards */
.bank-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bank-card:hover {
  background: rgba(124, 58, 237, 0.12);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.bank-card-kana {
  font-family: var(--font-japanese);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: white;
}

.bank-card-romaji {
  font-size: 0.8rem;
  color: var(--accent-light);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: lowercase;
}

.bank-card-meaning {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  line-height: 1.3;
}

/* Row display override for sentence list */
#sentence-bank-grid {
  grid-template-columns: 1fr;
}

.bank-row-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  gap: 16px;
}

.bank-row-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 55%;
}

.bank-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  max-width: 45%;
}

@media (max-width: 680px) {
  .bank-row-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .bank-row-right {
    align-items: flex-start;
    text-align: left;
    max-width: 100%;
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
    padding-top: 8px;
    width: 100%;
  }
}

/* ==========================================================================
   Admin Control Panel Styles
   ========================================================================== */
.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.admin-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.3);
}

.admin-stat-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-light);
  text-shadow: 0 0 10px var(--accent-glow);
}

.admin-stat-lbl {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: 6px;
}

.admin-form {
  padding: 24px;
  border-radius: var(--radius-md);
  background: rgba(22, 25, 49, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-form h3 {
  font-size: 1.15rem;
  margin-bottom: 20px;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  background: rgba(10, 11, 20, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(10, 11, 20, 0.6);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Specific select dropdown arrow styling override */
select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba%28255,255,255,0.6%29' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

select.form-control option {
  background-color: var(--bg-secondary);
  color: white;
}

.admin-form-message {
  margin-top: 14px;
  font-size: 0.88rem;
  min-height: 20px;
  text-align: center;
  font-weight: 500;
  transition: all 0.3s ease;
}
