*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /*タブレット連打時の拡大防止 */
}

body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #bcd8f5 0%, #d8ecfd 50%, #c5e0f8 100%);
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Rounded Mplus 1c", sans-serif;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 1196px;
  height: 540px;
  background: linear-gradient(160deg, #e8f4ff 0%, #f5faff 100%);
  border: 3px solid #6ab8f0;
  border-radius: 24px;
  box-shadow: 0 12px 48px rgba(40,100,200,0.18), 0 2px 8px rgba(40,100,200,0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.rain-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.rdrop {
  position: absolute;
  width: 2px;
  background: linear-gradient(to bottom, transparent, #3f8fd8);
  border-radius: 2px;
  animation: rfall linear infinite;
  opacity: 0.3;
}

@keyframes rfall {
  from { transform: translateY(-40px); }
  to { transform: translateY(580px); }
}

.game-header {
  position: relative;
  z-index: 5;
  height: 50px;
  flex: 0 0 50px;
  background: linear-gradient(90deg, #1e72c8 0%, #3ea8f0 60%, #1e72c8 100%);
  border-bottom: 3px solid #1558a0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  padding: 0 16px;
}

.hd-left {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hd-center {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-align: center;
  letter-spacing: 1px;
  line-height: 1.15;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.hd-right {
  font-size: 18px;
  font-weight: bold;
  color: #fff8c0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  text-align: right;
}

.btn-reset {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.18);
  transition: background 0.12s, transform 0.12s, box-shadow 0.12s;
}

.btn-reset:hover {
  background: rgba(255,255,255,0.28);
}

.btn-reset:active {
  transform: translateY(2px);
  box-shadow: none;
}

.q-dots {
  display: flex;
  gap: 4px;
}

.q-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: 1.5px solid rgba(255,255,255,0.5);
  transition: background 0.3s, transform 0.2s;
}

.q-dot.done {
  background: #fff8a0;
  border-color: #f8d800;
}

.q-dot.active {
  background: #fff;
  border-color: #fff;
  transform: scale(1.3);
}

.game-main {
  flex: 1;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

#startScreen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
  z-index: 2;
}

.start-cloud {
  font-size: 64px;
  animation: floatBob 2s ease-in-out infinite;
}

@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.start-title {
  font-size: 30px;
  font-weight: bold;
  color: #1050a0;
  padding: 0 18px;
  text-align: center;
  text-shadow: 0 2px 8px rgba(60,120,220,0.15);
}

.btn-start {
  margin-top: 4px;
  padding: 14px 48px;
  font-size: 22px;
  font-weight: bold;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #2a7acc, #50b8f0);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 #1050a0, 0 8px 20px rgba(30,90,200,0.25);
  transition: all 0.12s;
  letter-spacing: 1px;
}

.btn-start:hover {
  background: linear-gradient(135deg, #3888dd, #60c0f8);
}

.btn-start:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #1050a0;
}

#gameScreen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

#gameScreen.show {
  display: flex;
}

.panels-wrap {
  flex: 1;
  display: flex;
  gap: 0;
  align-items: center;
  justify-content: center;
  padding: 10px 28px 24px;
  overflow: hidden;
}

.vs-divider {
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.vs-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f8d020, #f09000);
  border: 3px solid #fff;
  box-shadow: 0 3px 12px rgba(200,120,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.panel {
  flex: 0 1 390px;
  height: 360px;
  background: rgba(255,255,255,0.85);
  border: 3px solid rgba(120,190,240,0.5);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
  padding: 16px;
  user-select: none;
}

.panel:hover {
  transform: translateY(-4px) scale(1.015);
  border-color: #4aacf0;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 10px 30px rgba(40,120,220,0.18);
}

.panel:active {
  transform: scale(0.97);
}

.panel.correct {
  border-color: #28c060;
  background: rgba(160,240,190,0.55);
  pointer-events: none;
  animation: panelPop 0.4s ease;
}

.panel.wrong {
  border-color: #f03040;
  background: rgba(255,160,160,0.45);
  pointer-events: none;
  animation: panelShake 0.4s ease;
}

.panel.reveal {
  border-color: #28c060;
  background: rgba(200,255,210,0.5);
  pointer-events: none;
}

@keyframes panelPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  70% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

@keyframes panelShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

.panel-svg {
  width: 190px;
  height: 190px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.panel:hover .panel-svg {
  transform: scale(1.05);
}

.panel-svg img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.12));
}

.panel-name {
  font-size: 20px;
  font-weight: bold;
  color: #1a4080;
  letter-spacing: 1px;
}

.result-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 40px;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.panel.correct .result-badge,
.panel.wrong .result-badge,
.panel.reveal .result-badge {
  opacity: 1;
  transform: scale(1);
}

.sparkle {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  animation: sparkleFly 0.7s ease-out forwards;
  font-size: 20px;
}

@keyframes sparkleFly {
  0% { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: var(--tx) scale(0.3); }
}

.feedback-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%) scale(0);
  z-index: 30;
  background: rgba(255,255,255,0.97);
  border: 3px solid #a0d0f8;
  border-radius: 20px;
  padding: 18px 36px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
  opacity: 0;
  pointer-events: none;
}

.feedback-popup.show {
  transform: translate(-50%,-50%) scale(1);
  opacity: 1;
}

.fp-emoji {
  font-size: 36px;
}

.fp-text {
  font-size: 20px;
  font-weight: bold;
  color: #1a4080;
  margin-top: 4px;
}

#resultScreen {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(230,244,255,0.97);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

#resultScreen.show {
  display: flex;
}

.res-emoji {
  font-size: 68px;
  animation: floatBob 2s ease-in-out infinite;
}

.res-title {
  font-size: 30px;
  font-weight: bold;
  color: #1050a0;
}

.res-score {
  font-size: 44px;
  font-weight: bold;
  color: #1878d8;
  text-shadow: 0 0 16px rgba(40,140,240,0.3);
}

.res-msg {
  font-size: 16px;
  color: #4070a8;
}

.score-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.score-pip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #a0c8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.3s;
}

.score-pip.ok {
  background: #b0f0c0;
  border-color: #28c060;
}

.score-pip.miss {
  background: #ffd0d0;
  border-color: #f03040;
}

.btn-retry {
  margin-top: 8px;
  padding: 13px 44px;
  font-size: 20px;
  font-weight: bold;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #2a7acc, #50b8f0);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 #1050a0;
  transition: all 0.12s;
}

.btn-retry:hover {
  background: linear-gradient(135deg, #3888dd, #60c0f8);
}

.btn-retry:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #1050a0;
}
