* {
  box-sizing: border-box;
}

:root {
  --bg: #edf2f7;
  --panel: #ffffff;
  --text: #172033;
  --muted: #617083;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --slate: #64748b;
  --green: #16a34a;
  --red: #dc2626;
  --gold: #f59e0b;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px;

  background:
    radial-gradient(circle at top, #ffffff 0%, var(--bg) 56%);

  color: var(--text);

  font-family:
    Arial,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    Meiryo,
    sans-serif;
}

button,
select {
  font: inherit;
}

.container {
  width: 100%;
  max-width: 1050px;

  margin: 15px auto;
  padding: 30px;

  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 22px;

  box-shadow: 0 20px 55px rgba(30, 41, 59, 0.14);
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow,
.modal-eyebrow {
  margin: 0 0 7px;

  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(27px, 4vw, 40px);
  line-height: 1.25;
}

.mobile-break {
  display: none;
}

.description {
  margin: 14px 0 22px;
  color: var(--muted);
  line-height: 1.7;
}

.sound-button {
  flex: 0 0 auto;
  padding: 10px 14px;

  border: 1px solid #cbd5e1;
  border-radius: 999px;

  background: #f8fafc;
  color: #334155;

  font-weight: 700;
  cursor: pointer;
}

.settings-panel {
  display: grid;
  grid-template-columns: auto 170px minmax(0, 1fr);
  align-items: center;
  gap: 13px;

  margin-bottom: 20px;
  padding: 14px 18px;

  background: #f8fafc;
  border-radius: 14px;
}

.settings-panel label {
  font-weight: 800;
}

select {
  padding: 10px 13px;

  border: 1px solid #94a3b8;
  border-radius: 9px;

  background: white;
  cursor: pointer;
}

select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.difficulty-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.status-area {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;

  margin-bottom: 20px;
}

.status-box {
  min-width: 0;
  padding: 14px 10px;

  background: linear-gradient(145deg, #f8fafc, #edf2f7);
  border: 1px solid #e2e8f0;
  border-radius: 13px;

  text-align: center;
}

.status-label {
  display: block;

  margin-bottom: 5px;

  color: var(--muted);
  font-size: 13px;
}

.status-number {
  font-size: clamp(25px, 4vw, 34px);
  font-weight: 900;
}

.life-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.life-display {
  color: #ef4444;
  font-size: 28px;
  letter-spacing: 3px;
}

.button-area,
.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;

  margin-bottom: 19px;
}

.start-button,
.reset-button {
  min-width: 215px;
  padding: 13px 20px;

  border: none;
  border-radius: 11px;

  color: white;
  font-weight: 800;

  cursor: pointer;

  transition:
    transform 0.1s,
    opacity 0.2s,
    background-color 0.2s;
}

.start-button {
  background: var(--blue);
}

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

.reset-button {
  background: var(--slate);
}

.reset-button:hover {
  background: #475569;
}

.start-button:active,
.reset-button:active,
.sound-button:active {
  transform: scale(0.97);
}

.start-button:disabled,
.reset-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.game-area {
  position: relative;
  width: 100%;
  height: 500px;

  overflow: hidden;

  background:
    linear-gradient(rgba(255, 255, 255, 0.23), rgba(255, 255, 255, 0.23)),
    repeating-linear-gradient(
      45deg,
      #dcfce7,
      #dcfce7 22px,
      #d1fae5 22px,
      #d1fae5 44px
    );

  border: 3px solid #86efac;
  border-radius: 18px;

  cursor: crosshair;
  user-select: none;
  touch-action: manipulation;
}

.stage-strip {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;

  display: flex;
  align-items: center;
  gap: 9px;

  padding: 8px 12px;

  background: rgba(15, 23, 42, 0.83);
  border-radius: 999px;

  color: white;
  font-size: 13px;
  font-weight: 800;

  pointer-events: none;
}

.stage-strip span:last-child {
  color: #bfdbfe;
  font-weight: 600;
}

.target {
  position: absolute;

  display: none;

  padding: 0;

  border: 5px solid white;
  border-radius: 50%;

  color: white;
  font-size: 16px;
  font-weight: 900;

  box-shadow:
    0 8px 16px rgba(15, 23, 42, 0.3),
    inset 0 0 0 7px rgba(255, 255, 255, 0.18);

  cursor: pointer;

  transition:
    left 0.06s,
    top 0.06s,
    transform 0.08s;
}

.target:hover {
  transform: scale(1.08);
}

.target:active {
  transform: scale(0.82);
}

.target-normal {
  background: #e53935;
}

.target-gold {
  background: #f9a825;
  color: #4e342e;
}

.target-blue {
  background: #1e88e5;
}

.target-green {
  background: #16a34a;
}

.target-black {
  background: #111827;
}

.target-boss {
  background:
    radial-gradient(circle at 35% 30%, #fef3c7, #dc2626 40%, #7f1d1d);
  border-width: 7px;
  font-size: 24px;

  animation: boss-pulse 0.8s infinite alternate;
}

@keyframes boss-pulse {
  from {
    box-shadow:
      0 8px 18px rgba(127, 29, 29, 0.35),
      0 0 0 0 rgba(220, 38, 38, 0.35);
  }

  to {
    box-shadow:
      0 10px 25px rgba(127, 29, 29, 0.55),
      0 0 0 12px rgba(220, 38, 38, 0);
  }
}

.start-message,
.stage-message,
.countdown-display {
  position: absolute;
  z-index: 10;
  top: 50%;
  left: 50%;

  transform: translate(-50%, -50%);
}

.start-message {
  width: 90%;
  margin: 0;

  color: #166534;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.countdown-display {
  width: 175px;
  height: 175px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: rgba(37, 99, 235, 0.94);
  color: white;

  font-size: 80px;
  font-weight: 900;

  animation: pop 0.42s ease;
}

.countdown-display[hidden],
.stage-message[hidden],
.boss-hp-wrap[hidden],
.modal[hidden] {
  display: none;
}

.stage-message {
  min-width: 280px;
  padding: 22px 30px;

  background: rgba(15, 23, 42, 0.9);
  border-radius: 18px;

  color: white;
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 900;
  text-align: center;

  animation: pop 0.42s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.effect-message {
  position: absolute;
  z-index: 8;
  top: 58px;
  left: 50%;

  min-width: 180px;
  min-height: 32px;

  padding: 8px 14px;

  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;

  font-size: 18px;
  font-weight: 900;
  text-align: center;

  transform: translateX(-50%);
  pointer-events: none;
}

.boss-hp-wrap {
  position: absolute;
  z-index: 7;
  right: 14px;
  bottom: 14px;
  left: 14px;

  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;

  padding: 10px 13px;

  background: rgba(15, 23, 42, 0.88);
  border-radius: 12px;

  color: white;
  font-size: 13px;
  font-weight: 900;
}

.boss-hp-bar {
  height: 14px;
  overflow: hidden;

  background: #334155;
  border-radius: 999px;
}

.boss-hp-fill {
  width: 100%;
  height: 100%;

  background: linear-gradient(90deg, #facc15, #ef4444);
  border-radius: inherit;

  transition: width 0.12s;
}

.result {
  min-height: 29px;
  margin: 18px 0 0;

  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.target-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;

  margin-top: 21px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 9px;

  padding: 10px;

  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 11px;

  color: #475569;
  font-size: 13px;
}

.guide-circle {
  width: 34px;
  height: 34px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;

  border: 3px solid white;
  border-radius: 50%;

  color: white;
  font-size: 11px;
  font-weight: 900;

  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.25);
}

.guide-normal { background: #e53935; }
.guide-gold { background: #f9a825; color: #4e342e; }
.guide-blue { background: #1e88e5; }
.guide-green { background: #16a34a; }
.guide-black { background: #111827; }
.guide-boss { background: #991b1b; }

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;

  display: grid;
  place-items: center;

  padding: 20px;

  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(7px);
}

.modal-card {
  width: min(620px, 100%);
  max-height: 92vh;
  overflow-y: auto;

  padding: 30px;

  background: white;
  border-radius: 22px;

  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.28);

  text-align: center;
}

.modal-card h2 {
  margin: 0 0 15px;
  font-size: 30px;
}

.rank-badge {
  width: 112px;
  height: 112px;

  display: grid;
  place-items: center;

  margin: 0 auto 22px;

  border-radius: 50%;

  background: linear-gradient(145deg, #fbbf24, #ea580c);
  color: white;

  font-size: 58px;
  font-weight: 900;

  box-shadow: 0 12px 28px rgba(234, 88, 12, 0.28);
}

.rank-s {
  background: linear-gradient(145deg, #fde047, #f97316);
}

.rank-a {
  background: linear-gradient(145deg, #60a5fa, #2563eb);
}

.rank-b {
  background: linear-gradient(145deg, #4ade80, #16a34a);
}

.rank-c {
  background: linear-gradient(145deg, #cbd5e1, #64748b);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;

  margin: 0 0 18px;
}

.result-grid div {
  padding: 13px;

  background: #f8fafc;
  border-radius: 11px;
}

.result-grid dt {
  color: var(--muted);
  font-size: 13px;
}

.result-grid dd {
  margin: 5px 0 0;
  font-size: 22px;
  font-weight: 900;
}

.rank-message {
  margin: 0 0 22px;
  color: #475569;
  line-height: 1.7;
}

@media screen and (max-width: 760px) {
  .container {
    padding: 21px 14px;
  }

  .mobile-break {
    display: initial;
  }

  .game-header {
    flex-direction: column;
  }

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

  .difficulty-description {
    grid-column: 1 / -1;
  }

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

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

  .game-area {
    height: 430px;
  }
}

@media screen and (max-width: 520px) {
  body {
    padding: 8px;
  }

  .button-area,
  .modal-buttons {
    flex-direction: column;
  }

  .start-button,
  .reset-button {
    width: 100%;
    min-width: 0;
  }

  .target-guide,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .game-area {
    height: 390px;
  }

  .start-message {
    font-size: 18px;
  }

  .countdown-display {
    width: 140px;
    height: 140px;
    font-size: 64px;
  }
}
