/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== PTCore 共通サイトヘッダー ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.site-header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-back-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .82rem;
  font-weight: 600;
  color: #1a56db;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background .15s;
}
.site-back-link:hover { background: #eff6ff; }
.site-back-link svg   { flex-shrink: 0; }
.site-header-title {
  font-size: .9rem;
  font-weight: 700;
  color: #1e293b;
}
.site-logo-link {
  font-size: .9rem;
  font-weight: 900;
  text-decoration: none;
  letter-spacing: -.5px;
}
.site-logo-pt   { color: #1a56db; }
.site-logo-core { color: #1e293b; }

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans',
               'Yu Gothic', Meiryo, sans-serif;
  background: #eef2f7;
  color: #1e2d40;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ===== App Shell ===== */
.app-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 24px 0 16px;
  border-bottom: 2px solid #c8d8ea;
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 1.9rem;
  font-weight: 800;
  color: #0d2444;
  letter-spacing: 0.03em;
}

.subtitle {
  font-size: 0.82rem;
  color: #6b8299;
  margin-top: 5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ===== Score Panel ===== */
.score-panel {
  display: flex;
  justify-content: space-around;
  background: #ffffff;
  border-radius: 14px;
  padding: 18px 12px;
  margin-bottom: 18px;
  box-shadow: 0 2px 10px rgba(13, 36, 68, 0.10);
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 72px;
}

.score-label {
  font-size: 0.70rem;
  color: #7b92a8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.score-value {
  font-size: 2rem;
  font-weight: 800;
  color: #0d2444;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ===== Question Panel ===== */
.question-panel {
  background: linear-gradient(135deg, #0d2444 0%, #1a4070 100%);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(13, 36, 68, 0.25);
}

.question-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7fb4e0;
  margin-bottom: 8px;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  color: #ffffff;
}

/* ===== Feedback ===== */
.feedback {
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.feedback.correct {
  background: #ecfdf5;
  color: #166534;
  border: 2px solid #4ade80;
}

.feedback.incorrect {
  background: #fff1f2;
  color: #991b1b;
  border: 2px solid #f87171;
}

.feedback.hidden {
  display: none;
}

/* ===== Image Wrapper ===== */
.image-wrapper {
  background: #ffffff;
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 18px;
  box-shadow: 0 2px 10px rgba(13, 36, 68, 0.10);
  overflow: hidden;
}

.image-container {
  position: relative;
  display: block;
  width: 100%;
  user-select: none;
  cursor: crosshair;
  border-radius: 8px;
  overflow: hidden;
}

#dermatome-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ===== Sensory Point Circles ===== */
.sensory-point {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.88);
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1.5px rgba(220, 38, 38, 0.5), 0 2px 6px rgba(0,0,0,0.30);
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: all;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.15s ease;
  z-index: 10;
}

.sensory-point::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
}

.sensory-point:hover {
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.6), 0 4px 12px rgba(0,0,0,0.35);
}

/* Label tooltip on hover */
.point-label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 36, 68, 0.88);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  letter-spacing: 0.04em;
}

.sensory-point:hover .point-label {
  opacity: 1;
}

/* State: correct answer */
.sensory-point.correct {
  background: #16a34a;
  border-color: #fff;
  box-shadow: 0 0 0 2px #4ade80, 0 0 16px rgba(22, 163, 74, 0.55);
  transform: translate(-50%, -50%) scale(1.15);
  animation: popIn 0.3s cubic-bezier(.22,.68,0,1.4);
}

/* State: wrong (the one the user clicked) */
.sensory-point.wrong {
  background: #dc2626;
  border-color: #fff;
  box-shadow: 0 0 0 2px #f87171, 0 0 16px rgba(220, 38, 38, 0.55);
  transform: translate(-50%, -50%) scale(1.15);
  animation: shake 0.35s ease;
}

/* State: revealed as correct answer after wrong click */
.sensory-point.reveal {
  background: #16a34a;
  border-color: #fff;
  box-shadow: 0 0 0 3px #4ade80, 0 0 20px rgba(22, 163, 74, 0.65);
  transform: translate(-50%, -50%) scale(1.2);
  animation: popIn 0.35s cubic-bezier(.22,.68,0,1.4);
}

/* Show label permanently on correct/wrong/reveal states */
.sensory-point.correct .point-label,
.sensory-point.wrong .point-label,
.sensory-point.reveal .point-label {
  opacity: 1;
}

@keyframes popIn {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.4; }
  60%  { transform: translate(-50%, -50%) scale(1.35); }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) scale(1.1); }
  25%       { transform: translate(calc(-50% - 5px), -50%) scale(1.1); }
  75%       { transform: translate(calc(-50% + 5px), -50%) scale(1.1); }
}

/* ===== Button ===== */
.button-area {
  text-align: center;
  margin-bottom: 24px;
}

.next-button {
  display: inline-block;
  background: linear-gradient(135deg, #0d2444 0%, #1a4070 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 15px 48px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(13, 36, 68, 0.30);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.next-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(13, 36, 68, 0.35);
  filter: brightness(1.1);
}

.next-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(13, 36, 68, 0.25);
}

.next-button:disabled {
  opacity: 0.40;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: 0 2px 6px rgba(13, 36, 68, 0.12);
}

/* ===== Results Overlay ===== */
.results-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 36, 68, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.results-overlay.hidden {
  display: none;
}

.results-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 40px 32px 36px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(13, 36, 68, 0.35);
}

.results-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0d2444;
  margin-bottom: 28px;
  letter-spacing: 0.03em;
}

.results-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.results-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.results-stat--divider {
  font-size: 2rem;
  color: #c8d8ea;
  font-weight: 300;
  padding-bottom: 20px;
}

.results-stat-value {
  font-size: 2.6rem;
  font-weight: 800;
  color: #0d2444;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.results-stat:last-child .results-stat-value {
  color: #1a4070;
}

.results-stat-label {
  font-size: 0.70rem;
  color: #7b92a8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.results-message {
  font-size: 1.05rem;
  font-weight: 600;
  color: #2d4a6a;
  margin-bottom: 28px;
  line-height: 1.5;
}

.restart-button {
  display: inline-block;
  background: linear-gradient(135deg, #0d2444 0%, #1a4070 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 14px 40px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(13, 36, 68, 0.30);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.restart-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(13, 36, 68, 0.35);
  filter: brightness(1.1);
}

.restart-button:active {
  transform: translateY(0);
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: #93aab8;
  letter-spacing: 0.03em;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app-header h1 {
    font-size: 1.45rem;
  }

  .score-value {
    font-size: 1.65rem;
  }

  .question-text {
    font-size: 1.0rem;
  }

  .feedback {
    font-size: 0.95rem;
  }

  .sensory-point {
    width: 10px;
    height: 10px;
  }

  .next-button {
    padding: 13px 36px;
    font-size: 0.98rem;
  }
}

@media (max-width: 360px) {
  .sensory-point {
    width: 9px;
    height: 9px;
  }
}
