:root {
  --bg-primary: #000000; /* 純黒 = 加算式ディスプレイで透明 */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #ffb454;
  --accent-warm: #ffd166;
  --success: #00ff88;
  --danger: #ff4466;
  --focus-ring: #ffb454;
  --focus-glow: rgba(255, 180, 84, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 600; flex: 1; }
.header-meta { font-size: 13px; color: var(--text-secondary); }
#quiz .header h1, #quiz .header { justify-content: space-between; }
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Focus States --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}
.focusable[disabled] { opacity: 0.5; cursor: default; }

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary { background: var(--accent-primary); color: #0a0a0f; }
.nav-item.primary:focus { background: #ffc87d; }

/* --- Intro (home) --- */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 4px;
  text-align: center;
}
.intro-icon { font-size: 64px; }
.intro-text { font-size: 16px; color: var(--text-secondary); line-height: 1.5; }

/* --- Data Grid --- */
.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-card { background: var(--bg-card); border-radius: var(--radius-md); padding: 12px 14px; text-align: center; }
.mini-label { font-size: 12px; color: var(--text-secondary); }
.mini-value { font-size: 18px; font-weight: 600; margin-top: 2px; }

/* --- Quiz screen --- */
.quiz-meta { display: flex; gap: 8px; }
.quiz-question {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
}
.list-container { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  gap: 12px;
  width: 100%;
}
.list-item:focus { background: var(--bg-card); }
.list-item.correct { border-color: var(--success); background: rgba(0, 255, 136, 0.15); }
.list-item.wrong { border-color: var(--danger); background: rgba(255, 68, 102, 0.15); }

/* --- Result screen --- */
.result-content { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.result-icon { font-size: 64px; }
.result-score { font-size: 42px; font-weight: 700; color: var(--accent-primary); }
.result-message { font-size: 15px; color: var(--text-secondary); }
.badge-highscore { background: rgba(255, 209, 102, 0.2); color: var(--accent-warm); font-size: 14px; padding: 8px 16px; }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 180, 84, 0.2);
  color: var(--accent-primary);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
  max-width: 480px;
  text-align: center;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }

/* --- Utility --- */
.hidden { display: none !important; }
