﻿* { box-sizing: border-box; 
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation; /*タブレット連打時の拡大防止 */
}
html { margin: 0; height: 100%; }
body {
  margin: 0;
  height: 100vh;
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  background: #f2f2f2;
  display: flex;
  justify-content: center;
  align-items: center;
}
.container {
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
}
.game-header {
  height: 50px;
  padding: 10px 18px;
  background: #ffffff;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid #ffe082;
}
.info {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 900;
  width: 100%;
  color: #5a3a1a;
}
.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
}
.header-score {
  margin-left: auto;
}
.game-main {
  position: relative;
  background: #ffffff;
  flex: 1;
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }
#title-screen { background: linear-gradient(160deg, #ffe0f0 0%, #fff9c4 50%, #d0f0ff 100%); }
.title-deco { display: flex; gap: 20px; margin-bottom: 24px; }
.title-circle {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.85);
  animation: bounce 1.4s ease-in-out infinite;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.13);
}
.title-circle:nth-child(2) { animation-delay: 0.2s; }
.title-circle:nth-child(3) { animation-delay: 0.4s; }
.title-circle:nth-child(4) { animation-delay: 0.6s; }
.title-circle:nth-child(5) { animation-delay: 0.8s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}
.title-main {
  margin: 0 0 10px;
  color: #ff6b6b;
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 4px 4px 0 #ffb3b3, 0 0 32px rgba(255, 107, 107, 0.28);
}
.title-sub {
  margin: 0 0 34px;
  color: #7c5c3a;
  font-size: 20px;
  line-height: 1.8;
  text-align: center;
  font-weight: 700;
}
.btn-start, .btn-quit, .btn-next, .btn-retry, .btn-home {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.btn-start {
  padding: 18px 64px;
  border-radius: 60px;
  background: linear-gradient(135deg, #ff6b6b, #ff9f43);
  color: #fff;
  font-size: 26px;
  box-shadow: 0 8px 0 #c94b2a, 0 12px 28px rgba(255, 100, 50, 0.35);
}
.btn-start:hover, .btn-retry:hover, .btn-home:hover { transform: translateY(-3px); }
.btn-start:active, .btn-retry:active, .btn-home:active { transform: translateY(3px); }
#play-screen {
  background: linear-gradient(140deg, #fff5d6 0%, #fce4ff 100%);
  justify-content: flex-start;
}
.play-header {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 32px 8px;
  flex-shrink: 0;
}
.progress-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 180px;
  min-height: 22px;
}
.progress-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d9f0ff;
  border: 2px solid #a9d5ea;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.85);
}
.progress-dot.active {
  background: #35d75f;
  border-color: #18ad42;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.45), 0 1px 4px rgba(24, 173, 66, 0.35);
}
.play-header .btn-quit { position: absolute; right: 32px; top: 8px; }
.btn-quit {
  padding: 9px 28px;
  border-radius: 40px;
  background: linear-gradient(135deg, #4ecdc4, #44a8a0);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 5px 0 #2a7a76, 0 7px 14px rgba(50, 180, 170, 0.24);
}
.btn-quit:hover { transform: translateY(-2px); }
.btn-quit:active { transform: translateY(3px); }
.play-body {
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}
.left-pane, .right-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.left-pane {
  gap: 14px;
  padding: 8px 28px 24px 36px;
  border-right: 3px dashed rgba(200, 160, 100, 0.35);
}
.right-pane { gap: 12px; padding: 8px 36px 24px 28px; }
.question-card {
  width: 100%;
  padding: 18px 32px;
  border: 3px solid #ffe082;
  border-radius: 28px;
  background: #fff;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}
.question-text { color: #5a3a1a; font-size: 26px; font-weight: 900; line-height: 1.5; }
.palette-title {
  color: #7c5c3a;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.75);
}
.equation-wrap { width: 100%; display: flex; justify-content: center; }
.equation-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.eq-circle, .result-circle {
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.85);
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.96);
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  flex-shrink: 0;
  transition: background 0.4s;
}
.eq-circle { width: 82px; height: 82px; }
.result-circle { width: 96px; height: 96px; border-width: 5px; font-size: 15px; }
.eq-op {
  color: #7c5c3a;
  font-size: 38px;
  font-weight: 900;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}
.palette-grid { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.color-btn {
  height: 72px;
  padding: 0 4px 7px;
  border: 4px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  color: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s, opacity 0.12s;
}
.color-btn:hover { transform: translateY(-4px) scale(1.06); }
.color-btn:active { transform: translateY(2px); }
.color-btn.selected {
  border-color: #fff;
  transform: translateY(-6px) scale(1.12);
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.15), 0 18px 32px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(255, 255, 255, 0.95) !important;
}
.color-btn:disabled {
  opacity: 0.25;
  cursor: default;
  filter: brightness(0.5);
  pointer-events: none;
}
.color-btn.choice-active {
  animation: choicePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  border-color: #fff !important;
}
@keyframes choicePop {
  0% { transform: scale(1); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1.08); }
}
.color-btn.correct-answer {
  border-color: #fff !important;
  box-shadow: 0 0 0 5px #fff700, 0 0 24px 8px rgba(255, 230, 0, 0.7), 0 8px 0 rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-8px) scale(1.18) !important;
}
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9;
}
.confetti-piece { position: absolute; top: -20px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(600px) rotate(720deg); opacity: 0; } }
.feedback-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  height: 72px;
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.feedback-bar.show { transform: translateY(0); }
.feedback-bar.correct { background: linear-gradient(90deg, #6bcb77, #4aa84a); }
.feedback-bar.wrong { background: linear-gradient(90deg, #ff8c8c, #e05555); }
.feedback-bar-left { display: flex; align-items: center; gap: 14px; }
.feedback-bar-icon {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.16);
}
.feedback-mark-correct::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 9px;
  width: 22px;
  height: 28px;
  border: solid #34a853;
  border-width: 0 8px 8px 0;
  border-radius: 3px;
  transform: rotate(42deg);
}
.feedback-mark-wrong::before, .feedback-mark-wrong::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 20px;
  width: 28px;
  height: 8px;
  border-radius: 999px;
  background: #e05555;
}
.feedback-mark-wrong::before { transform: rotate(45deg); }
.feedback-mark-wrong::after { transform: rotate(-45deg); }
.feedback-bar-text { color: #fff; font-size: 24px; font-weight: 900; text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25); }
.feedback-bar-detail { color: rgba(255, 255, 255, 0.92); font-size: 16px; font-weight: 700; }
.btn-next {
  padding: 10px 36px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 18px;
}
.btn-next:hover { background: rgba(255, 255, 255, 0.38); transform: scale(1.04); }
#result-screen {
  gap: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 217, 61, 0.48) 0 7%, transparent 18%),
    radial-gradient(circle at 82% 28%, rgba(77, 150, 255, 0.28) 0 8%, transparent 20%),
    radial-gradient(circle at 64% 82%, rgba(107, 203, 119, 0.32) 0 7%, transparent 19%),
    linear-gradient(160deg, #fff0c0 0%, #ffe0f0 52%, #dff6ff 100%);
  background-size: 180% 180%, 170% 170%, 190% 190%, 220% 220%;
  animation: resultBgFloat 9s ease-in-out infinite alternate;
}
#result-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.88) 0 5px, transparent 6px),
    radial-gradient(circle, rgba(255, 159, 67, 0.34) 0 4px, transparent 5px),
    radial-gradient(circle, rgba(78, 205, 196, 0.32) 0 4px, transparent 5px);
  background-position: 10% 20%, 72% 18%, 44% 76%;
  background-size: 220px 180px, 260px 210px, 240px 200px;
  animation: resultSparkleDrift 7s linear infinite;
  opacity: 0.72;
}
#result-screen > * {
  position: relative;
  z-index: 1;
}
@keyframes resultBgFloat {
  from { background-position: 0% 42%, 100% 20%, 40% 100%, 0% 50%; }
  to { background-position: 100% 58%, 0% 80%, 88% 0%, 100% 50%; }
}
@keyframes resultSparkleDrift {
  from { transform: translateY(0); }
  to { transform: translateY(-28px); }
}
.result-title { color: #ff6b6b; font-size: 44px; font-weight: 900; text-shadow: 3px 3px 0 #ffb3b3; }
.result-score-wrap {
  padding: 22px 64px;
  border: 4px solid #ffe082;
  border-radius: 28px;
  background: #fff;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.result-score-label { margin-bottom: 4px; color: #a08060; font-size: 18px; font-weight: 700; }
.result-score-num { color: #ff6b6b; font-size: 66px; font-weight: 900; line-height: 1; text-shadow: 3px 3px 0 #ffcdd2; }
.result-score-num span:last-child { font-size: 30px; }
.result-msg { color: #5a3a1a; font-size: 22px; font-weight: 900; }
.result-btns { display: flex; gap: 20px; }
.btn-retry, .btn-home { padding: 14px 46px; border-radius: 50px; color: #fff; font-size: 20px; }
.btn-retry { background: linear-gradient(135deg, #ff6b6b, #ff9f43); box-shadow: 0 6px 0 #c94b2a, 0 10px 22px rgba(255, 100, 50, 0.3); }
.btn-home { background: linear-gradient(135deg, #4ecdc4, #44a8a0); box-shadow: 0 6px 0 #2a7a76, 0 10px 22px rgba(50, 180, 170, 0.3); }
@media (max-width: 760px) {
  .container { height: 540px; }
  .title-main { font-size: 40px; }
  .title-circle { width: 44px; height: 44px; }
  .play-header { padding: 8px 12px; }
  .play-header .btn-quit { right: 12px; top: 6px; }
  .progress-dots { gap: 5px; min-width: 140px; }
  .progress-dot { width: 9px; height: 9px; border-width: 2px; }
  .play-body { grid-template-columns: 1fr; }
  .left-pane { gap: 10px; padding: 8px 14px; border-right: 0; }
  .right-pane { padding: 6px 14px 78px; }
  .question-card { padding: 10px 14px; }
  .question-text { font-size: 22px; }
  .palette-title { font-size: 18px; }
  .eq-circle { width: 56px; height: 56px; font-size: 11px; }
  .result-circle { width: 64px; height: 64px; font-size: 12px; }
  .eq-op { font-size: 24px; }
  .color-btn { height: 48px; border-radius: 12px; font-size: 11px; }
  .feedback-bar { height: 68px; padding: 0 12px; }
  .feedback-bar-text { font-size: 18px; }
  .feedback-bar-detail { font-size: 12px; }
}
