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

body {
  font-family: 'Noto Sans', sans-serif;
  background: white;
  color: #222;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;

  /* Improve touch behavior on mobile: avoid double-tap zoom and make taps more responsive */
  touch-action: manipulation;
  -ms-touch-action: manipulation;
}

/* Reduce tap highlighting and ensure interactive elements use manipulation for touch */
button,
a,
.choice-btn,
#start-btn,
#restart-btn,
#help-btn,
.choice-btn {
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  touch-action: manipulation;
}

#app {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
}

#title-screen {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 48px 24px;
}

#title-screen h1 {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.3;
}

/* 画面幅が狭いスマホ（480px以下）向けの調整 */
@media (max-width: 480px) {
  #title-screen h1 {
    font-size: 28px; /* 36pxから28pxに下げて「クイ／ズ」を回避 */
    letter-spacing: -1px; /* 文字間隔をわずかに詰めると収まりが良くなります */
  }
}

#title-screen p {
  font-size: 18px;
  color: #666;
}

#start-btn {
  padding: 20px 48px;
  font-size: 20px;
  font-weight: 600;
  background: #222;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Noto Sans', sans-serif;
  transition: transform 0.1s, background 0.2s;
  align-self: center;
}

#start-btn:hover {
  background: #000;
}

#start-btn:active {
  transform: scale(0.98);
}

#help-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: 2px solid #222;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  z-index: 10;
}

#help-btn:hover {
  background: #f8f8f8;
}

#help-btn:active {
  transform: scale(0.95);
}

#help-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

#help-content {
  background: white;
  border: 2px solid #222;
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: left;
  animation: slideUp 0.3s;
}

#help-content h2 {
  font-size: 24px;
  margin-bottom: 16px;
  text-align: center;
}

#help-content p {
  margin-bottom: 12px;
  line-height: 1.6;
  font-size: 15px;
}

#close-help-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  background: #222;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Noto Sans', sans-serif;
  transition: transform 0.1s, background 0.2s;
}

#close-help-btn:hover {
  background: #000;
}

#close-help-btn:active {
  transform: scale(0.98);
}

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

#question-card {
  position: relative; /* これが重要！中の絶対配置の基準になります */
  padding-top: 40px;  /* 右上に文字がくるので、中身が重ならないよう余白を確保 */
  
  background: #f8f8f8;
  border: 2px solid #222;
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

#question-text {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.4;
}

#question-type {
  font-size: 16px;
  color: #666;
  font-weight: 500;
}

#answer-section {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: center;
}

.choice-btn {
  padding: 20px;
  font-size: 18px;
  font-weight: 600;
  background: white;
  color: #222;
  border: 2px solid #222;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Noto Sans', sans-serif;
  transition: transform 0.1s, background 0.2s;
}

.choice-btn:active {
  transform: scale(0.98);
}

.choice-btn:hover:not(:disabled) {
  background: #f8f8f8;
}

#restart-btn {
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  background: #222;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Noto Sans', sans-serif;
  transition: transform 0.1s, background 0.2s;
}

#restart-btn:active {
  transform: scale(0.98);
}

#restart-btn:hover {
  background: #000;
}

#result-container {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#result {
  padding: 20px;
  border-radius: 8px;
  text-align: left;
  font-size: 16px;
  font-weight: 500;
  animation: fadeIn 0.3s;
  opacity: 0;
  transition: opacity 0.3s;
}

#result.show {
  opacity: 1;
}

#result.correct {
  background: #e8f5e9;
  border: 2px solid #4caf50;
  color: #2e7d32;
}

#result.incorrect {
  background: #ffebee;
  border: 2px solid #f44336;
  color: #c62828;
}

/* Thin progress bar at top */
#top-progress {
  width: 100%;
  padding: 10px 0 0 0;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
#top-progress-track {
  width: 100%;
  max-width: 500px;
  height: 10px;
  background: #eee;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e6e6e6;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.02);
}
#top-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  width: 0%;
  transition: width 0.25s ease;
}

#progress {
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: #666;
}

#complete-screen {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px 0;
}

#final-score {
  font-size: 32px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 480px) {
  /* Slightly smaller question text to save vertical space */
  #question-text {
    font-size: 22px;
  }

  /* Ensure answer buttons are touch-friendly but more compact */
  .choice-btn {
    padding: 14px;
    font-size: 16px;
  }

  /* Compact layout for answer section on narrow screens */
  #answer-section {
    flex-direction: column;
    gap: 10px;
    padding: 0 12px;
  }

  /* Compact the complete/result screen so everything fits */
  #complete-screen {
    gap: 12px;
    padding: 16px 8px;
  }

  #final-score {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
  }

  /* Make the results list smaller and allow wrapping */
  #complete-screen .share-btn {
    padding: 12px 20px;
    font-size: 14px;
  }

  #complete-screen > div[style], /* inline result block */
  #final-score,
  .amazon-link {
    font-size: 12px;
  }

  .amazon-link {
    display: block;
    padding: 8px;
    margin-top: 10px;
  }

  /* result lines (問1: ○ ...) smaller and tighter */
  #complete-screen .share-btn,
  #complete-screen .share-btn + * {
    font-size: 14px;
  }

  /* result text area */
  #complete-screen div[style] {
    max-height: 160px;
    overflow: auto;
    white-space: pre-line;
    padding-right: 8px;
  }

  /* Reduce padding on help modal */
  #help-content {
    padding: 18px;
    max-width: 360px;
  }

  /* Keep top progress visible but thin */
  #top-progress {
    padding-top: 6px;
  }
}

/* タイトル画面フッター */
.title-footer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #666;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

/* Left block (production + site) */
.title-footer .footer-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* small label */
.title-footer .brand {
  font-weight: 600;
  color: #222;
  font-size: 13px;
}

/* operator name */
.title-footer .operator {
  font-weight: 700;
  color: #111;
}

/* site link kept subtle */
.title-footer .site {
  color: #666;
  text-decoration: none;
  font-weight: 500;
}

.title-footer .site:hover {
  color: #000;
  text-decoration: underline;
}

/* Right block (support link) placed under the left block when stacked */
.title-footer .footer-right {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

.title-footer .support {
  background: transparent;
  border: 1px solid #e6e6e6;
  padding: 6px 10px;
  border-radius: 8px;
  color: #222;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

.title-footer .support:hover {
  background: #f6f6f6;
  border-color: #ddd;
  color: #000;
}

/* 例：Amazonリンクをちょっとだけ目立たせる */
.amazon-link {
    display: inline-block;
    padding: 10px;
    background-color: #fff9e6; /* 薄い黄色 */
    border: 1px solid #ffd814; /* Amazonカラー */
    border-radius: 8px;
    text-decoration: none;
    margin-top: 15px;
}

.share-btn {
    display: inline-block;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    background: #000;
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-family: 'Noto Sans', sans-serif;
    transition: transform 0.1s, background 0.2s;
    cursor: pointer;
}

.share-btn:hover {
    background: #333;
}

.share-btn:active {
    transform: scale(0.98);
}

/* IDと作成者を右上に配置 */
.meta-info {
  position: absolute;
  top: 10px;    /* カードの上端から10px */
  right: 15px;  /* カードの右端から15px */
  
  display: flex;
  flex-direction: column; /* 縦に並べる */
  align-items: flex-end;   /* 右揃え */
  
  line-height: 1.2;
  pointer-events: none;    /* クリックの邪魔をしないように */
}

#question-id {
  font-size: 0.7rem;
  color: #bbb;
  font-family: monospace; /* 数字を見やすく */
}

#author-display {
  font-size: 0.65rem;
  color: #ccc;
}

#pwa-guide-container {
    position: fixed;
    bottom: 25px;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.pwa-guide-box {
    pointer-events: auto;
    width: 85%; /* さらに横幅を抑える */
    max-width: 320px; /* iPhone SEの幅に合わせる */
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 10px;
    padding: 10px 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pwa-guide-title {
    font-size: 13px; /* さらに小さく */
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
}

.pwa-guide-text {
    font-size: 11px;
    color: #666;
    margin: 0;
}