* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation; /*タブレット連打時の拡大防止 */
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100vh;
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  background: #87ceeb;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 1196px;
  height: 540px;
  margin: 0 auto;
  background: #fff;
  border: 2px solid #333;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-header {
  position: relative;
  height: 50px;
  flex: 0 0 50px;
  padding: 0 16px;
  background: linear-gradient(90deg, #ff6b35, #ff9f2e);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #fff;
}

.container.is-title .game-header,
.container.is-title .timer-bar-wrap {
  display: none;
}

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: #fff7b0;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 2px 2px 0 #c45000;
}

.header-left {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.header-left > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  text-shadow: none;
  white-space: nowrap;
}

.timer-readout {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.game-main {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #0a5a9a;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
}

.screen.is-active {
  display: flex;
}

.screen-title,
.screen-result {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1a90d4 0%, #0f6eb5 42%, #0a4f8a 100%);
}

.water-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.18), transparent 18%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.12), transparent 20%),
    linear-gradient(180deg, #1a90d4 0%, #1278b8 38%, #083f6e 100%);
}

.bubble {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  animation: bubbleRise linear infinite;
}

@keyframes bubbleRise {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.65;
  }
  100% {
    transform: translateY(-560px) scale(1.35);
    opacity: 0;
  }
}

.title-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.title-banner {
  padding: 12px 38px;
  margin-bottom: 16px;
  background: #ff6b35;
  border: 5px solid #ffd700;
  border-radius: 18px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.title-main {
  margin: 0;
  color: #ffd700;
  font-size: 52px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 3px 3px 0 #c45000, 5px 5px 0 rgba(0, 0, 0, 0.25);
}

.title-sub {
  margin: 0 0 24px;
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.deco-fish-row {
  display: flex;
  gap: 18px;
  margin-bottom: 26px;
}

.deco-fish {
  position: relative;
  width: 70px;
  height: 50px;
  animation: decoSwim 2s ease-in-out infinite;
}

.deco-fish::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 12px;
  width: 42px;
  height: 26px;
  border-radius: 50%;
  background: var(--fish-color);
}

.deco-fish::after {
  content: "";
  position: absolute;
  right: 0;
  top: 11px;
  width: 28px;
  height: 28px;
  background: var(--fish-color);
  clip-path: polygon(0 50%, 100% 0, 76% 50%, 100% 100%);
}

.deco-red { --fish-color: #ff6b6b; }
.deco-orange { --fish-color: #ffb347; animation-delay: 0.25s; }
.deco-blue { --fish-color: #69d0ff; animation-delay: 0.5s; }
.deco-purple { --fish-color: #b47fff; animation-delay: 0.75s; }
.deco-green { --fish-color: #66c988; animation-delay: 1s; }

@keyframes decoSwim {
  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }
  50% {
    transform: translateY(-8px) rotate(5deg);
  }
}

.level-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.level-label {
  margin: 0;
  color: #ffd700;
  font-size: 18px;
  font-weight: 900;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.level-buttons,
.result-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
}

button {
  font-family: inherit;
}

.btn-level,
.btn-result,
.btn-quit {
  border: 0;
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-level {
  min-width: 136px;
  padding: 14px 24px;
  border-radius: 999px;
  color: #fff;
  font-size: 21px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
}

.btn-level:hover,
.btn-result:hover {
  transform: translateY(-3px);
}

.btn-level:active,
.btn-result:active,
.btn-quit:active {
  transform: translateY(2px);
}

.btn-easy { background: #4fb95f; }
.btn-normal { background: #f28a20; }
.btn-hard { background: #e84d4d; }

.screen-play {
  background: #0a5a9a;
}

.pond-area {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #1a8fd1 0%, #1278b8 52%, #0a5a9a 100%);
}

.wave-overlay {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  animation: waveSway 3s ease-in-out infinite;
}

@keyframes waveSway {
  0%,
  100% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(1.02) translateX(-5px);
  }
}

.target-display {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: min(540px, calc(100% - 32px));
  padding: 8px 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #111;
  font-weight: 900;
  text-shadow: none;
}

.target-label {
  white-space: nowrap;
}

.target-sample {
  flex: 0 0 58px;
  width: 58px;
  height: 42px;
}

.target-sample svg {
  display: block;
  width: 100%;
  height: 100%;
}

.btn-quit {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 8px 18px;
  border: 3px solid #ff5050;
  border-radius: 999px;
  background: #fff;
  color: #ff5050;
  font-size: 15px;
  box-shadow: 0 3px 0 #c03030;
}

.btn-quit.is-hidden {
  visibility: hidden;
}

.timer-bar-wrap {
  flex: 0 0 12px;
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.22);
  border-top: 3px solid #ffd700;
}

.timer-bar {
  width: 100%;
  height: 100%;
  border-radius: 0 6px 6px 0;
  background: linear-gradient(90deg, #5bc86a, #ffd700, #ff5050);
  transition: width 0.1s linear;
}

.fish {
  position: absolute;
  cursor: pointer;
  touch-action: manipulation;
  transition: filter 0.1s;
}

.fish:hover {
  filter: brightness(1.18);
}

.fish.caught {
  animation: catchPop 0.4s ease-out forwards;
  pointer-events: none;
}

@keyframes catchPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.6) rotate(20deg);
  }
  100% {
    transform: scale(0) rotate(40deg);
    opacity: 0;
  }
}

.fish.wrong {
  animation: wrongShake 0.4s ease-out forwards;
  pointer-events: none;
}

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

.ripple {
  position: absolute;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
  animation: rippleOut 0.6s ease-out forwards;
}

@keyframes rippleOut {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.combo-popup {
  position: absolute;
  z-index: 50;
  color: #ffd700;
  font-size: 28px;
  font-weight: 900;
  text-shadow: 2px 2px 0 #c04500, 0 0 10px rgba(255, 200, 0, 0.8);
  pointer-events: none;
  animation: comboFloat 0.8s ease-out forwards;
}

@keyframes comboFloat {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-60px) scale(1.35);
    opacity: 0;
  }
}

.result-card {
  position: relative;
  z-index: 1;
  min-width: 330px;
  padding: 34px 56px;
  border: 4px solid #ffd700;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.result-title {
  margin: 0 0 8px;
  color: #ff6b35;
  font-size: 34px;
  font-weight: 900;
}

.result-score-label {
  margin: 0 0 4px;
  color: #777;
  font-size: 16px;
  font-weight: 800;
}

.result-score {
  margin: 0 0 8px;
  color: #ff6b35;
  font-size: 68px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 2px 2px 0 #c04500;
}

.score-unit {
  margin-left: 4px;
  font-size: 26px;
  text-shadow: none;
  vertical-align: baseline;
}

.result-comment {
  margin: 0 0 24px;
  color: #333;
  font-size: 22px;
  font-weight: 800;
}

.btn-result {
  min-width: 130px;
  padding: 13px 26px;
  border-radius: 999px;
  color: #fff;
  font-size: 19px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.22);
}

.btn-retry { background: #4fb95f; }
.btn-home { background: #1a90d4; }


@media (max-width: 640px) {
  .game-header {
    padding: 0 10px;
    font-size: 12px;
  }

  .header-left {
    gap: 8px;
    font-size: 11px;
  }

  .header-title {
    font-size: 16px;
  }

  .btn-quit {
    padding: 7px 12px;
    font-size: 13px;
  }

  .title-main {
    font-size: 38px;
  }

  .title-banner {
    padding: 10px 22px;
  }

  .deco-fish-row {
    gap: 6px;
    transform: scale(0.82);
  }

  .level-buttons,
  .result-buttons {
    gap: 10px;
    flex-wrap: wrap;
  }

  .btn-level {
    min-width: 106px;
    padding: 12px 16px;
    font-size: 17px;
  }

  .target-display {
    top: 12px;
    min-width: calc(100% - 20px);
    gap: 8px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .target-sample {
    flex-basis: 48px;
    width: 48px;
    height: 35px;
  }

  .result-card {
    width: calc(100% - 32px);
    min-width: 0;
    padding: 28px 18px;
  }
}
