/* =============================================
     CSS Variables
  ============================================= */
  :root {
    --color-primary:       #00A59F;
    --color-primary-dark:  #007f7b;
    --color-primary-light: #e0f5f5;
    --color-primary-pale:  #f0fafa;
    --color-white:         #ffffff;
    --color-gray-50:       #f8f9fa;
    --color-gray-200:      #e0e0e0;
    --color-gray-600:      #616161;
    --color-gray-800:      #212121;
    --color-text:          #1a1a1a;
    --font-family:         'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    --border-radius-sm:    6px;
    --shadow-sm:           0 2px 8px rgba(0,0,0,0.08);
    --shadow-md:           0 4px 20px rgba(0,0,0,0.12);
    --transition:          0.25s ease;
  }

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

  /* =============================================
     Navigation Bar
  ============================================= */
  #navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-gray-200);
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  }
  .navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 24px;
    max-width: 1200px;
    margin: 0 auto;
  }
  .navbar-logo {
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.03em;
    white-space: nowrap;
    text-decoration: none;
  }
  .navbar-logo span {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
  }
  .navbar-nav { display: flex; gap: 8px; list-style: none; }
  .navbar-nav a {
    font-family: var(--font-family);
    font-size: 0.875rem; font-weight: 500;
    color: var(--color-gray-600);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
  }
  .navbar-nav a:hover, .navbar-nav a.active {
    color: var(--color-primary);
    background: var(--color-primary-pale);
  }
  .hamburger {
    display: none; flex-direction: column; gap: 5px;
    cursor: pointer; padding: 8px; background: none; border: none;
  }
  .hamburger span {
    display: block; width: 24px; height: 2px;
    background: var(--color-gray-800); border-radius: 2px;
    transition: all var(--transition);
  }
  .hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .mobile-menu {
    display: none; position: absolute;
    top: 64px; left: 0; right: 0;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-md);
    padding: 16px 24px; z-index: 999;
  }
  .mobile-menu.open { display: flex; flex-direction: column; gap: 4px; }
  .mobile-menu a {
    font-family: var(--font-family); font-size: 0.95rem; font-weight: 500;
    color: var(--color-gray-600); padding: 12px 16px;
    border-radius: var(--border-radius-sm); text-decoration: none;
    transition: color var(--transition), background var(--transition);
  }
  .mobile-menu a:hover { color: var(--color-primary); background: var(--color-primary-pale); }
  @media (max-width: 768px) {
    .navbar-nav { display: none; }
    .hamburger  { display: flex; }
    #navbar     { position: relative; }
  }

  /* =============================================
     Body / Layout
  ============================================= */
  body {
    font-family: 'Noto Sans JP', sans-serif;
    background: #f7f5f0;
    min-height: 100vh;
    display: block;
  }
  #quiz-page-body {
    min-height: calc(100vh - 64px - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
  }
  #quiz-wrap {
    width: 100%;
    max-width: 600px;  /* 選択肢テキストが長いので少し広く */
    position: relative;
  }
  .screen { display: none; flex-direction: column; align-items: center; gap: 1.5rem; }
  .screen.active { display: flex; }

  /* =============================================
     Start Screen
  ============================================= */
  #start-screen { text-align: center; }
  #start-screen h1 {
    font-family: 'Noto Serif JP', serif;
    font-size: 2.2rem; font-weight: 700;
    color: #1a1a1a; line-height: 1.5;
  }
  #start-screen p { font-size: 15px; color: #666; line-height: 1.9; }
  .start-btn {
    margin-top: 0.5rem;
    padding: 14px 52px;
    background: #1a1a1a; color: #fff;
    border: none; border-radius: 12px;
    font-size: 16px; font-family: 'Noto Sans JP', sans-serif;
    font-weight: 500; cursor: pointer; transition: opacity 0.15s;
  }
  .start-btn:hover { opacity: 0.78; }

  /* =============================================
     Quiz Screen
  ============================================= */
  #quiz-screen { gap: 1.4rem; }
  .progress-bar-wrap {
    width: 100%; height: 4px;
    background: #ddd; border-radius: 2px; overflow: hidden;
  }
  .progress-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.4s ease;
  }
  .q-meta {
    width: 100%; display: flex;
    justify-content: space-between;
    font-size: 12px; color: #888;
  }
  .q-card {
    width: 100%; background: #fff;
    border: 1px solid #e8e4dc; border-radius: 16px;
    padding: 2rem 1.5rem; text-align: center;
    min-height: 150px; display: flex;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  }
  .q-text {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.15rem; font-weight: 400;
    color: #1a1a1a; line-height: 1.9;
  }

  /* =============================================
     Choice Buttons — Dynamic
     2択: 横並び / 3択以上: 縦並び
  ============================================= */
  .btn-row {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    /* 方向は JS で .horizontal / .vertical を付与 */
  }
  .btn-row.horizontal { flex-direction: row; }
  .btn-row.vertical   { flex-direction: column; }

  .ans-btn {
    flex: 1;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid #ccc;
    background: #fff;
    color: #1a1a1a;
    text-align: left;           /* 選択肢テキストは左寄せが読みやすい */
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.12s, border-color 0.12s, transform 0.1s;
    line-height: 1.5;
  }
  /* 横並び(2択)の場合は中央寄せ */
  .btn-row.horizontal .ans-btn { text-align: center; justify-content: center; }

  .ans-btn:hover:not(:disabled) { background: #f5f5f5; }
  .ans-btn:active               { transform: scale(0.98); }
  .ans-btn:disabled             { cursor: not-allowed; }

  /* 選択肢ラベル (A/B/C/D) */
  .choice-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
    transition: background 0.12s, color 0.12s;
  }
  /* 横並び(2択)ではラベル非表示（回答前） */
  .btn-row.horizontal .choice-label { display: none; }
  /* 回答後は○×を常に表示（2択横並びも含む） */
  .ans-btn.correct .choice-label,
  .ans-btn.wrong .choice-label,
  .ans-btn.highlight-correct .choice-label {
    display: inline-flex !important;
    font-size: 1.1rem;
    width: 32px; height: 32px;
  }

  /* 正解 / 不正解 */
  .ans-btn.correct {
    background: #eaf7ed; border-color: #5cb877; color: #2e7d32;
  }
  .ans-btn.correct .choice-label {
    background: #5cb877; color: #fff;
  }
  .ans-btn.wrong {
    background: #fdecea; border-color: #e57373; color: #c62828;
  }
  .ans-btn.wrong .choice-label {
    background: #e57373; color: #fff;
  }
  /* 正解を教えるためのハイライト（選択後、不正解時に正解に色付け） */
  .ans-btn.highlight-correct {
    background: #eaf7ed; border-color: #5cb877; color: #2e7d32;
    opacity: 0.8;
  }
  .ans-btn.highlight-correct .choice-label {
    background: #5cb877; color: #fff;
  }

  /* =============================================
     Result Screen
  ============================================= */
  #result-screen {
    text-align: center;
    animation: rankIn 0.7s ease forwards;
    position: relative; padding: 1rem 0;
  }
  @keyframes rankIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: none; }
  }
  .rank-badge {
    width: 120px; height: 80px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
    animation: pulse 2s infinite ease-in-out;
    background: transparent;
  }
  .rank-badge img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: lighten; }
  @keyframes pulse {
    0%,100% { box-shadow: 0 0 0 10px rgba(180,180,180,0.15), 0 0 0 22px rgba(180,180,180,0.07); }
    50%      { box-shadow: 0 0 0 16px rgba(180,180,180,0.20), 0 0 0 32px rgba(180,180,180,0.09); }
  }
  .rank-label {
    display: inline-block;
    font-size: 11px; font-weight: 500; letter-spacing: 0.12em;
    padding: 3px 16px; border-radius: 20px;
    background: #ede8df; color: #888;
  }
  .rank-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 2.4rem; font-weight: 700; color: #1a1a1a; line-height: 1.3;
  }
  .rank-score { font-size: 13px; color: #aaa; letter-spacing: 0.06em; }
  .rank-msg {
    font-size: 15px; color: #333; line-height: 1.9;
    padding: 1.2rem 1.5rem;
    background: #fff; border-radius: 14px;
    border: 1px solid #e8e4dc; max-width: 440px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  }
  .stars { display: flex; gap: 6px; justify-content: center; font-size: 22px; }
  .star { animation: starPop 0.4s ease backwards; }
  .star:nth-child(1) { animation-delay: 0.15s; }
  .star:nth-child(2) { animation-delay: 0.28s; }
  .star:nth-child(3) { animation-delay: 0.41s; }
  .star:nth-child(4) { animation-delay: 0.54s; }
  @keyframes starPop {
    from { opacity: 0; transform: scale(0) rotate(-30deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
  }
  .retry-btn {
    padding: 12px 36px; border-radius: 10px;
    background: transparent; border: 1px solid #bbb; color: #1a1a1a;
    font-family: 'Noto Sans JP', sans-serif; font-size: 14px;
    cursor: pointer; transition: background 0.12s;
  }
  .retry-btn:hover { background: #f0f0f0; }
  .confetti-canvas {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none; z-index: 999;
  }

  /* =============================================
     Footer
  ============================================= */
  footer {
    background: var(--color-primary-dark);
    color: rgba(255,255,255,0.75);
    text-align: center; padding: 24px;
    font-family: var(--font-family); font-size: 0.8rem;
  }
  footer a {
    color: rgba(255,255,255,0.9); text-decoration: none;
    transition: color var(--transition);
  }
  footer a:hover { color: #fff; }

  /* =============================================
     Scroll-to-top
  ============================================= */
  #scroll-top {
    position: fixed; bottom: 32px; right: 32px;
    width: 48px; height: 48px;
    background: var(--color-primary); color: #fff;
    border: none; border-radius: 50%; cursor: pointer;
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    box-shadow: var(--shadow-md); z-index: 900;
  }
  #scroll-top.visible { opacity: 1; pointer-events: auto; }
  #scroll-top:hover   { transform: translateY(-4px); }

  /* Category badge */
  .q-category-badge {
    display: inline-block;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--color-primary);
    letter-spacing: 0.05em;
  }


  .test-heading-image {
    text-align: center;
    line-height: 1;
    margin-bottom: 18px;
  }

  .test-title-image {
    display: block;
    width: min(100%, 560px);
    height: auto;
    margin: 0 auto;
  }

  @media (max-width: 768px) {
    .test-heading-image {
      margin-bottom: 14px;
    }

    .test-title-image {
      width: min(100%, 88vw);
    }
  }


  .navbar-nav li { position: relative; list-style: none; }
  .navbar-nav { align-items: center; }
  .navbar-nav > li { display: flex; align-items: center; }
  .nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-gray-600);
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    appearance: none;
    -webkit-appearance: none;
    line-height: 1;
  }
  .nav-dropdown-toggle::after {
    content: '▾';
    font-size: 0.72rem;
    line-height: 1;
    transform: translateY(1px);
  }
  .nav-dropdown:hover > .nav-dropdown-toggle,
  .nav-dropdown:focus-within > .nav-dropdown-toggle {
    color: var(--color-primary);
    background: var(--color-primary-pale);
  }
  .nav-dropdown {
    position: relative;
    padding-bottom: 8px;
    margin-bottom: -8px;
  }
  .nav-dropdown-menu {
    position: absolute;
    top: calc(100% - 2px);
    left: 0;
    min-width: 220px;
    background: rgba(255,255,255,.98);
    border: 1px solid var(--color-gray-200);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15,23,42,.12);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1100;
    transition: opacity .18s ease, visibility .18s ease;
  }
  .nav-dropdown-menu a {
    display: block;
    white-space: nowrap;
    padding: 10px 12px;
    border-radius: 10px;
  }
  .nav-dropdown:hover .nav-dropdown-menu,
  .nav-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .mobile-menu-group {
    padding: 8px 0 4px;
    border-top: 1px solid var(--color-gray-200);
    margin-top: 6px;
  }
  .mobile-menu-group-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--color-gray-600);
    padding: 8px 16px 6px;
  }
  .mobile-submenu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 10px;
  }
  @media (max-width: 768px) {
    .nav-dropdown-menu { display: none !important; }
  }
