:root {
  --blue: #4fc3d9;
  --blue-dark: #2fa9c0;
  --bg: #f4fbfc;
  --text: #234;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.top {
  text-align: center;
  padding: 20px 16px 6px;
}
.top h1 { margin: 0; font-size: 1.6rem; cursor: pointer; }
.top h1:active { opacity: 0.6; }
.top .level { margin: 4px 0 0; color: var(--blue-dark); font-weight: bold; font-size: 0.95rem; }
.top .sub { margin: 2px 0 0; color: #567; }

.tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  flex-wrap: wrap;
}
.tab-btn {
  border: none;
  background: #e0eef1;
  color: #345;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}
.tab-btn.active { background: var(--blue); color: white; }
.tab-btn:active { transform: scale(0.95); }

/* Each tab group (Cards１/Cards２ share a color, Game１/Game２ share a color, etc.)
   starts out pale and switches to its own deeper shade once tapped/active, so it's
   easy to see at a glance which section you're in. */
.tab-cards { background: #d7f0f5; }
.tab-cards.active { background: var(--blue); }

.tab-sight { background: #fdead3; }
.tab-sight.active { background: #f2a65a; }

.tab-conv { background: #e1f3e1; }
.tab-conv.active { background: #7fbf7f; }

.tab-quiz { background: #fbe1e6; }
.tab-quiz.active { background: #e17f8f; }

.tab-game { background: #ece7f8; }
.tab-game.active { background: #9b8bd4; }

main { max-width: 480px; margin: 0 auto; padding: 0 16px 40px; }

.panel { display: none; }
.panel.active { display: block; }

/* --- Home / logo screen shown before any tab is tapped --- */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 60px 20px;
}
.home-logo {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.home-hint {
  margin: 0;
  color: var(--blue-dark);
  font-weight: bold;
  font-size: 1.05rem;
  text-align: center;
}

/* --- 1枚ずつ表示するカードビューア --- */
.viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.progress {
  font-weight: bold;
  color: var(--blue-dark);
  font-size: 1rem;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 3 / 4;
  border-radius: 20px;
  overflow: hidden;
  background: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  cursor: pointer;
}
.stage.wide {
  max-width: 440px;
  aspect-ratio: 16 / 9;
}
.stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
  display: block;
}

.text-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 4.68rem;
  font-weight: bold;
  color: white;
  gap: 10px;
}
.text-stage .speaker {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 1.6rem;
  opacity: 0;
}
.text-stage.revealed .speaker { opacity: 1; }
.text-stage .placeholder {
  font-size: 3.2rem;
}
.text-stage .tap-caption {
  font-size: 1rem;
  font-weight: normal;
  opacity: 0.9;
}

.caption {
  min-height: 1.4em;
  color: var(--blue-dark);
  font-weight: bold;
  font-size: 0.95rem;
  text-align: center;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-btn {
  border: none;
  background: white;
  border: 2px solid var(--blue);
  color: var(--blue-dark);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
}
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.nav-btn:active:not(:disabled) { transform: scale(0.92); }

.replay-btn {
  border: none;
  background: var(--blue);
  color: white;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
}
.replay-btn:active { transform: scale(0.96); }

/* --- Memory matching game --- */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.shuffle-btn {
  border: none;
  background: var(--blue);
  color: white;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}
.shuffle-btn:active { transform: scale(0.96); }

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
}

.game-tile {
  border: none;
  background: none;
  padding: 0;
  aspect-ratio: 3 / 4;
  perspective: 800px;
  cursor: pointer;
}

.game-tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s;
  transform-style: preserve-3d;
}
.game-tile.flipped .game-tile-inner,
.game-tile.matched .game-tile-inner {
  transform: rotateY(180deg);
}

.game-tile-back,
.game-tile-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.game-tile-back {
  background: var(--blue);
  font-size: 2rem;
}
.game-tile-back img {
  width: 68%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
}
.game-tile-front {
  background: white;
  transform: rotateY(180deg);
}
.game-tile-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-tile.matched {
  opacity: 0.5;
}
