/* 災害分類アプリ v2.0
   外部ライブラリ・外部画像なし。オフラインで動作します。 */

:root {
  --bg: #eef8f7;
  --surface: #ffffff;
  --surface-soft: #f7fbfb;
  --ink: #17383d;
  --muted: #557176;
  --primary: #0f6f7a;
  --primary-dark: #084e56;
  --accent: #f3a712;
  --success: #24825b;
  --danger: #b4493f;
  --border: #b9d7d7;
  --focus: #7b3ff2;
  --shadow: 0 14px 34px rgba(23, 56, 61, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --max-width: 1280px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 34rem),
    var(--bg);
  font-family:
    "BIZ UDPGothic",
    "Yu Gothic UI",
    "Yu Gothic",
    "Hiragino Kaku Gothic ProN",
    system-ui,
    sans-serif;
  line-height: 1.65;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  transform: translateY(-160%);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: #fff;
  background: var(--ink);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 82px;
  padding: 0.75rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(15, 111, 122, 0.18);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #d9f0ef;
  font-size: 1.8rem;
}

.eyebrow,
.screen-kicker,
.hero-kicker {
  margin: 0;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  line-height: 1.25;
}

.header-actions {
  display: flex;
  gap: 0.45rem;
}

.icon-button {
  display: grid;
  place-items: center;
  min-width: 66px;
  min-height: 58px;
  padding: 0.35rem 0.55rem;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #edf6f6;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--primary);
}

.icon-button[aria-pressed="false"] {
  color: var(--muted);
  background: #ececec;
}

.button-label {
  font-size: 0.72rem;
  font-weight: 700;
}

.app-shell {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: appear 180ms ease-out;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 2rem;
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3.2rem);
  border: 1px solid rgba(15, 111, 122, 0.18);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #ffffff 0%, #e6f5f3 100%);
  box-shadow: var(--shadow);
}

.hero-copy h2 {
  max-width: 17ch;
  margin: 0.55rem 0 1rem;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.hero-copy p:last-child {
  max-width: 46rem;
  margin-bottom: 0;
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 600;
}

.disaster-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.disaster-preview span {
  display: grid;
  min-height: 76px;
  place-items: center;
  padding: 0.6rem;
  border: 2px solid #cfe5e3;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
}

.mode-grid,
.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.15rem;
  margin-top: 1.4rem;
}

.mode-card,
.stage-card {
  position: relative;
  display: flex;
  min-height: 230px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.55rem;
  padding: 1.4rem;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(23, 56, 61, 0.09);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.mode-card:hover,
.stage-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.mode-card strong,
.stage-card strong {
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.mode-card small,
.stage-card small {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.mode-icon,
.stage-icon {
  font-size: 2.6rem;
}

.mode-number,
.stage-number {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  color: rgba(15, 111, 122, 0.18);
  font-size: 4.6rem;
  font-weight: 900;
  line-height: 1;
}

.teacher-card {
  background: linear-gradient(145deg, #fff 0%, #fff8e8 100%);
}

.learning-note {
  margin-top: 1.2rem;
  padding: 1.15rem 1.35rem;
  border-left: 7px solid var(--accent);
  border-radius: 12px;
  background: #fffaf0;
}

.learning-note strong {
  font-size: 1.1rem;
}

.learning-note p {
  margin: 0.3rem 0 0;
}

.screen-heading,
.game-toolbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.2rem;
}

.screen-heading h2,
.game-title-block h2 {
  margin: 0.15rem 0 0;
  line-height: 1.25;
}

.back-button,
.text-button {
  min-height: 48px;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 12px;
  color: var(--primary-dark);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.back-button:hover,
.text-button:hover {
  background: #dcefee;
}

.stage-card {
  min-height: 260px;
}

.stage-card .category-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.stage-card .category-preview span {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  color: var(--primary-dark);
  background: #e6f3f2;
  font-size: 0.84rem;
  font-weight: 800;
}

.game-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(180px, 270px);
}

.stage-instruction {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-weight: 600;
}

.progress-panel {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 5px 14px rgba(23, 56, 61, 0.08);
  text-align: center;
}

.progress-panel span {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 900;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfeaea;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 220ms ease;
}

.teacher-panel {
  display: grid;
  grid-template-columns: minmax(200px, 1.2fr) 1fr 1fr auto;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 2px solid #efd28c;
  border-radius: var(--radius-md);
  background: #fff8e8;
}

.teacher-control {
  display: grid;
  gap: 0.25rem;
}

.teacher-control label {
  font-weight: 800;
}

.teacher-control select {
  min-height: 46px;
  padding: 0.5rem 0.75rem;
  border: 2px solid #c9b16f;
  border-radius: 10px;
  background: white;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 48px;
  font-weight: 700;
}

.toggle-row input {
  width: 23px;
  height: 23px;
}

.teacher-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.basis-banner {
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--primary);
}

.basis-banner strong {
  display: block;
  font-size: 1.2rem;
}

.workspace {
  display: grid;
  gap: 1.2rem;
}

.cards-area,
.categories-area {
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 56, 61, 0.07);
}

.section-label-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.85rem;
}

.section-label-row h3 {
  margin: 0;
  font-size: 1.25rem;
}

.section-label-row p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.disaster-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 0.75rem;
  min-height: 154px;
}

.all-placed-message {
  grid-column: 1 / -1;
  display: grid;
  min-height: 142px;
  place-items: center;
  margin: 0;
  border: 3px dashed var(--success);
  border-radius: 18px;
  color: var(--success);
  background: #e8f6ef;
  font-size: 1.25rem;
  font-weight: 900;
}

.disaster-card {
  position: relative;
  display: grid;
  min-height: 142px;
  place-items: center;
  align-content: center;
  gap: 0.25rem;
  padding: 0.8rem 0.5rem;
  border: 3px solid #b9d7d7;
  border-radius: 18px;
  background: var(--surface-soft);
  cursor: grab;
  text-align: center;
  user-select: none;
  touch-action: manipulation;
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.disaster-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.disaster-card.is-selected {
  border-color: var(--focus);
  box-shadow: 0 0 0 5px rgba(123, 63, 242, 0.15);
}

.disaster-card.is-correct {
  cursor: default;
  border-color: var(--success);
  background: #e8f6ef;
}

.disaster-card.is-dragging {
  opacity: 0.5;
}

.disaster-card.is-wrong {
  animation: shake 260ms ease;
  border-color: var(--danger);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-7px);
  }

  75% {
    transform: translateX(7px);
  }
}

.disaster-card .emoji {
  font-size: 2.35rem;
  line-height: 1;
}

.disaster-card .name {
  font-size: 1.12rem;
  font-weight: 900;
}

.disaster-card .answer-chip {
  margin-top: 0.15rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
}

.speech-button {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #e3f0ef;
  cursor: pointer;
}

.category-boxes {
  display: grid;
  gap: 0.85rem;
}

.category-boxes.columns-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.category-boxes.columns-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.category-box {
  min-height: 180px;
  padding: 1rem;
  border: 4px dashed var(--category-color, var(--primary));
  border-radius: 20px;
  background: color-mix(in srgb, var(--category-color, var(--primary)) 10%, white);
  cursor: pointer;
  text-align: center;
  transition: transform 130ms ease, background 130ms ease;
}

.category-box:hover,
.category-box.is-over {
  transform: translateY(-3px);
  background: color-mix(in srgb, var(--category-color, var(--primary)) 20%, white);
}

.category-box h4 {
  margin: 0;
  font-size: clamp(1.12rem, 2.2vw, 1.45rem);
}

.category-box p {
  margin: 0.35rem auto 0.7rem;
  color: var(--muted);
  font-weight: 600;
}

.category-count {
  display: inline-grid;
  min-width: 54px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--category-color, var(--primary));
  font-weight: 900;
}

.placed-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  min-height: 35px;
  margin-top: 0.75rem;
}

.placed-chip {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(23, 56, 61, 0.12);
}

.feedback-panel {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  width: min(720px, calc(100% - 2rem));
  padding: 1rem;
  border: 3px solid var(--success);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 56, 61, 0.25);
}

.feedback-panel[hidden] {
  display: none;
}

.feedback-panel.is-wrong {
  border-color: var(--danger);
}

.feedback-panel h3,
.feedback-panel p {
  margin: 0;
}

.feedback-icon {
  font-size: 2rem;
}

.feedback-panel button {
  min-height: 48px;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

.result-card {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: clamp(1.4rem, 5vw, 3rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-card h2 {
  margin: 0.3rem 0;
  font-size: clamp(2rem, 5vw, 3rem);
}

.result-icon {
  font-size: 4rem;
}

.result-summary {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.result-stats div {
  padding: 1rem;
  border-radius: 16px;
  background: #edf6f6;
}

.result-stats span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.result-stats strong {
  display: block;
  font-size: 2rem;
}

.review-list {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0 1.4rem;
  text-align: left;
}

.review-item {
  padding: 0.75rem 1rem;
  border-left: 6px solid var(--primary);
  border-radius: 10px;
  background: #f3f8f8;
}

.review-item strong {
  display: block;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 2px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  border: 2px solid var(--primary);
  color: var(--primary-dark);
  background: #fff;
}

.secondary-button:hover {
  background: #e4f2f1;
}

.hide-ruby rt {
  display: none;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 1000px) {
  .disaster-cards {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .teacher-panel {
    grid-template-columns: 1fr 1fr;
  }

  .teacher-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
  }

  .brand-icon,
  .eyebrow,
  .button-label {
    display: none;
  }

  .icon-button {
    min-width: 46px;
    min-height: 46px;
  }

  .app-shell {
    width: min(calc(100% - 1rem), var(--max-width));
    padding-top: 1rem;
  }

  .hero-panel,
  .mode-grid,
  .stage-grid,
  .game-toolbar {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    gap: 1.2rem;
  }

  .hero-copy h2 {
    max-width: none;
  }

  .mode-card,
  .stage-card {
    min-height: 180px;
  }

  .screen-heading {
    align-items: flex-start;
  }

  .progress-panel {
    width: 100%;
  }

  .section-label-row {
    display: block;
  }

  .section-label-row p {
    margin-top: 0.3rem;
  }

  .category-boxes.columns-3 {
    grid-template-columns: 1fr;
  }

  .feedback-panel {
    grid-template-columns: auto 1fr;
  }

  .feedback-panel button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .header-actions {
    gap: 0.2rem;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .disaster-preview,
  .disaster-cards,
  .category-boxes.columns-2,
  .teacher-panel,
  .result-stats {
    grid-template-columns: 1fr 1fr;
  }

  .disaster-card {
    min-height: 132px;
  }

  .teacher-panel {
    grid-template-columns: 1fr;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
