:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #161822;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #818cf8;
  --accent-hover: #6366f1;
  --danger: #f43f5e;
  --success: #10b981;
  --glass-bg: rgba(22, 24, 34, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(129, 140, 248, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(244, 63, 94, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

header.app-header {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInDown 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

header.app-header h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--accent-color), #48bfe3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header.app-header p {
  color: var(--text-secondary);
  font-size: 1.15rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* The original global h1 rule is now specific to header.app-header h1 */
/* The original header p rule is now specific to header.app-header h2 */

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
}

.controls {
  padding: 2.5rem;
  margin-bottom: 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s both;
}

.mode-selector {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  transition: all 0.3s ease;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
}

.radio-label:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.radio-label input {
  display: none;
}

.radio-label:has(input:checked) {
  background: rgba(129, 140, 248, 0.1);
  border-color: rgba(129, 140, 248, 0.3);
  color: var(--text-primary);
}

.custom-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  position: relative;
  transition: all 0.3s ease;
}

.radio-label input:checked + .custom-radio {
  border-color: var(--accent-color);
}

.radio-label input:checked + .custom-radio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
}

.filters {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.input-group {
  flex: 1;
  min-width: 250px;
  max-width: 400px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="text"], select {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  font-size: 1.05rem;
  transition: all 0.3s ease;
}

select {
  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='%23f8fafc' 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 1rem center;
  background-size: 1em;
  padding-right: 2.5rem;
}

select option {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1.05rem;
}

input[type="text"]::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
  background: rgba(0, 0, 0, 0.5);
}

.results-section {
  animation: fadeIn 1s ease-out 0.3s both;
}

.sort-note {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: right;
  padding-right: 0.5rem;
  font-style: italic;
}

.results-count {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  text-align: right;
  padding-right: 0.5rem;
}

.kanji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 0.75rem;
}

.kanji-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kanji-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  transition: height 0.3s ease;
}

.kanji-card.not-allowed::before {
  background: linear-gradient(90deg, #f43f5e, #fda4af);
}

.kanji-card.allowed-joyo::before {
  background: linear-gradient(90deg, #10b981, #6ee7b7);
}

.kanji-card.allowed-jinmeiyo::before {
  background: linear-gradient(90deg, #0d9488, #5eead4);
}

.kanji-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.2);
  background: #1e2230;
}

.kanji-card:hover::before {
  height: 6px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

.badge-joyo {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-jinmeiyo {
  background-color: rgba(13, 148, 136, 0.15);
  color: #2dd4bf;
  border: 1px solid rgba(13, 148, 136, 0.3);
}

.badge-ng {
  background-color: rgba(244, 63, 94, 0.15);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.stroke-count {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.kanji-character {
  font-size: 4.5rem;
  font-weight: 700;
  text-align: center;
  margin: 0.25rem 0;
  line-height: 1.1;
  text-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.2s ease;
}

.kanji-card:hover .kanji-character {
  transform: scale(1.05);
}

.kanji-info {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.kanji-info-text {
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.kanji-meta-info {
  margin-top: 0.35rem;
  color: #a5b4fc;
  font-weight: 600;
  font-size: 0.65rem;
  text-align: center;
  background: rgba(129, 140, 248, 0.15);
  padding: 0.15rem 0.25rem;
  border-radius: 4px;
  white-space: normal;
  word-break: break-word;
  border: 1px solid rgba(129, 140, 248, 0.2);
}

.load-more-btn {
  display: block;
  margin: 2rem auto;
  padding: 0.75rem 2rem;
  background-color: transparent;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.load-more-btn:hover {
  background-color: var(--accent-color);
  color: #fff;
}

/* Animations */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeIn {
  from { opacity: 0; blur: 10px; }
  to { opacity: 1; blur: 0px; }
}

@media (max-width: 768px) {
  .app-container {
    padding: 1.5rem 1rem;
  }
  
  h1 { font-size: 2.2rem; }
  
  .controls {
    padding: 1.5rem;
  }
  
  .mode-selector {
    flex-direction: column;
    align-items: stretch;
  }
  
  .radio-label {
    justify-content: center;
  }
}

/* Info Container */
.info-panel {
  grid-column: 1 / -1;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.info-label {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-bottom-right-radius: 8px;
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 3rem;
  padding-bottom: 2rem;
  opacity: 0.7;
}
