/* ========== Reset & Base ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  color: #e8eef7;
  background: #0a0d14;
  user-select: none;
  -webkit-user-select: none;
}

/* ========== Viewport ========== */
#viewport {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(80, 130, 220, 0.25), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(180, 80, 200, 0.18), transparent 60%),
    linear-gradient(180deg, #0c1220 0%, #060810 100%);
}
#canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* ========== HUD ========== */
#hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  z-index: 10;
  pointer-events: none;
}
.hud-block {
  background: rgba(15, 22, 38, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(120, 160, 230, 0.25);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex; flex-direction: column;
  min-width: 90px;
}
.hud-block:first-child {
  background: linear-gradient(135deg, rgba(60, 90, 180, 0.55), rgba(120, 60, 180, 0.45));
  border-color: rgba(160, 200, 255, 0.35);
}
.hud-label {
  font-size: 11px;
  color: #9bb0d0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.hud-block:first-child .hud-label {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  letter-spacing: 0.12em;
}
.hud-sub { font-size: 11px; color: #c8d3ea; }
.hud-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}

/* ========== Bottom HUD ========== */
#hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 22px;
  z-index: 10;
}
.instruction {
  background: rgba(15, 22, 38, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(120, 160, 230, 0.3);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  display: flex; gap: 10px; align-items: center;
  max-width: 90vw;
}
.instruction i { color: #6dc1ff; }
.actions {
  display: flex; gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ========== Buttons ========== */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s, background 0.15s;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, #4a7dff, #8a4dff);
  color: #fff;
  box-shadow: 0 4px 18px rgba(90, 120, 255, 0.35);
}
.btn-primary:not(:disabled):hover {
  box-shadow: 0 6px 24px rgba(120, 140, 255, 0.55);
}
.btn-secondary {
  background: linear-gradient(135deg, #29c98b, #1a9b78);
  color: #fff;
  box-shadow: 0 4px 18px rgba(40, 200, 130, 0.35);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e8eef7;
}
.btn-ghost:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.14);
}
.btn-big {
  padding: 16px 36px;
  font-size: 17px;
  border-radius: 14px;
}

/* ========== Camera hint ========== */
#camera-hint {
  position: absolute;
  right: 16px;
  bottom: 100px;
  background: rgba(15, 22, 38, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(120, 160, 230, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: #b0c0dd;
  z-index: 5;
  line-height: 1.7;
}
#camera-hint i { color: #6dc1ff; width: 18px; text-align: center; }

/* ========== Overlays ========== */
.overlay {
  position: absolute; inset: 0;
  background: rgba(5, 8, 16, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Loading */
.loading-card {
  text-align: center;
  padding: 40px;
}
.loading-card h2 { font-size: 22px; margin-bottom: 8px; color: #fff; }
.loading-card p { color: #9bb0d0; font-size: 14px; }
.spinner {
  width: 60px; height: 60px;
  border: 4px solid rgba(120, 160, 230, 0.2);
  border-top-color: #6dc1ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Start card */
.start-card {
  background: linear-gradient(160deg, rgba(30, 40, 70, 0.95), rgba(15, 20, 35, 0.95));
  border: 1px solid rgba(120, 160, 230, 0.3);
  border-radius: 20px;
  padding: 40px 44px;
  max-width: 520px;
  width: 90vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.start-card h1 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 32px;
  background: linear-gradient(135deg, #6dc1ff, #c87dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}
.start-card h1 i { color: #6dc1ff; -webkit-text-fill-color: #6dc1ff; }
.tagline { color: #b8c5de; font-size: 14px; margin-bottom: 28px; }
.rules {
  list-style: none;
  text-align: left;
  margin-bottom: 28px;
}
.rules li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(120, 160, 230, 0.12);
  font-size: 14px;
  color: #d4ddee;
  display: flex; gap: 12px; align-items: flex-start;
}
.rules li:last-child { border-bottom: none; }
.rules li i {
  background: linear-gradient(135deg, #4a7dff, #8a4dff);
  color: #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  font-style: normal;
  font-weight: 700;
}

/* Result card */
.result-card {
  background: linear-gradient(160deg, rgba(30, 40, 70, 0.95), rgba(15, 20, 35, 0.95));
  border: 1px solid rgba(120, 160, 230, 0.3);
  border-radius: 20px;
  padding: 36px 40px;
  max-width: 460px;
  width: 90vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.result-card.correct { border-color: rgba(80, 220, 140, 0.55); }
.result-card.wrong { border-color: rgba(255, 120, 120, 0.45); }
.result-icon {
  font-size: 56px;
  margin-bottom: 10px;
}
.result-card.correct .result-icon { color: #4ddc8a; }
.result-card.wrong .result-icon { color: #ff7d7d; }
.result-card h2 { font-size: 26px; margin-bottom: 6px; }
.result-card p { color: #b8c5de; font-size: 13px; margin-bottom: 22px; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
  padding: 16px;
  background: rgba(8, 12, 22, 0.5);
  border-radius: 12px;
}
.stat-label {
  display: block;
  font-size: 11px;
  color: #8a9ab8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stat-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}


/* ========== Difficulty（難易度表示） ========== */

/* HUD 内の難易度星マーク */
.hud-difficulty-stars {
  font-size: 17px;
  letter-spacing: 2px;
  line-height: 1.3;
  color: #c8d3ea;
  display: block;
}

/* HUD 内の難易度ラベル（やさしい / ふつう / むずかしい） */
.hud-difficulty-name {
  font-size: 10px;
  color: #9bb0d0;
  letter-spacing: 0.04em;
  display: block;
  margin-top: 1px;
}

/* レベル別カラー（HUD・結果モーダル共通） */
.difficulty-easy   { color: #4ddc8a; }
.difficulty-normal { color: #ffcc44; }
.difficulty-hard   { color: #ff6655; }

/* 結果モーダル内の難易度バッジ */
.result-difficulty {
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 2px;
  padding: 6px 18px;
  border-radius: 99px;
  margin-bottom: 16px;
}
.result-difficulty.difficulty-easy {
  background: rgba(77, 220, 138, 0.12);
  border: 1px solid rgba(77, 220, 138, 0.35);
}
.result-difficulty.difficulty-normal {
  background: rgba(255, 204, 68, 0.12);
  border: 1px solid rgba(255, 204, 68, 0.35);
}
.result-difficulty.difficulty-hard {
  background: rgba(255, 102, 85, 0.12);
  border: 1px solid rgba(255, 102, 85, 0.35);
}
/* ========== Responsive ========== */
@media (max-width: 640px) {
  #hud-top { padding: 10px; gap: 6px; flex-wrap: wrap; }
  .hud-block { padding: 6px 10px; min-width: auto; }
  .hud-label { font-size: 9px; }
  .hud-value { font-size: 15px; }
  .hud-block:first-child .hud-label { font-size: 11px; }
  #camera-hint { display: none; }
  .btn { padding: 10px 16px; font-size: 13px; }
  .start-card { padding: 28px 22px; }
  .start-card h1 { font-size: 24px; }
}
