* {
  box-sizing: border-box;
}

:root {
  --ink: #27345a;
  --blue: #4f9cff;
  --yellow: #ffd84d;
  --pink: #ff7fb5;
  --green: #60d394;
  --purple: #8e7dff;
  --orange: #ff9d42;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Comic Sans MS", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.9) 0 2px, transparent 3px),
    radial-gradient(circle at 75% 10%, rgba(255,255,255,.8) 0 2px, transparent 3px),
    linear-gradient(#93d9ff, #dff6ff 52%, #fff8cf);
  background-size: 60px 60px, 90px 90px, auto;
}

button, input, select {
  font: inherit;
}

.app {
  width: min(1250px, calc(100% - 18px));
  margin: 10px auto 28px;
}

.hero {
  background: #fff6b8;
  border: 5px solid white;
  outline: 4px solid #ffc857;
  border-radius: 28px;
  padding: 12px 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 0 rgba(39,52,90,.16);
}

.title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.hero h1 {
  margin: 0;
  font-size: clamp(25px, 4vw, 44px);
  color: #ff6b6b;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 #ffd1d1;
}

.hero p {
  margin: 2px 0 0;
  font-weight: 700;
  color: #50618c;
}

.star {
  font-size: 36px;
  color: #ffcb3d;
  filter: drop-shadow(2px 2px 0 white);
}

.hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.hud-card {
  min-width: 0;
  padding: 10px 12px;
  background: white;
  border-radius: 18px;
  border: 4px solid #dcecff;
  box-shadow: 0 5px 0 rgba(39,52,90,.12);
  text-align: center;
}

.hud-card:nth-child(2) { border-color: #ffd9e9; }
.hud-card:nth-child(3) { border-color: #ffe1b7; }
.hud-card:nth-child(4) { border-color: #ddf6bd; }
.hud-card:nth-child(5) { border-color: #dcd6ff; }

.hud-card span {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #7180a7;
}

.hud-card strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.game-shell {
  overflow: hidden;
  border: 7px solid white;
  outline: 4px solid #75bfff;
  border-radius: 28px;
  box-shadow: 0 9px 0 rgba(39,52,90,.15);
  background: #8bd4ff;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  margin-top: 16px;
  align-items: stretch;
}

.control-card,
.button-card,
.message {
  background: white;
  border-radius: 22px;
  border: 4px solid #dbeaff;
  box-shadow: 0 6px 0 rgba(39,52,90,.12);
  padding: 14px;
}

.control-title {
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.value-bubble {
  width: 82px;
  margin: 6px auto 8px;
  border-radius: 30px;
  padding: 7px 10px;
  background: #fff2a8;
  border: 3px solid #ffd449;
  text-align: center;
  font-size: 25px;
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  accent-color: #ff6b6b;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #7f8bad;
}

.button-card {
  display: flex;
  min-width: 210px;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  border-color: #ffe2bf;
}

.big-btn,
.fire-btn {
  min-height: 48px;
  border: 0;
  border-radius: 18px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 900;
  color: white;
  box-shadow: 0 5px 0 rgba(39,52,90,.2);
  transition: transform .08s ease;
}

.big-btn:active,
.fire-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(39,52,90,.2);
}

.blue { background: #4f9cff; }
.green { background: #5ccf82; }

.fire-btn {
  background: linear-gradient(#ff9e43, #ff624d);
  min-height: 64px;
  font-size: 24px;
  border: 4px solid #fff3ce;
}

.fire-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.message {
  margin-top: 14px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  border-color: #eadfff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(35,50,84,.55);
  padding: 18px;
}

.hidden { display: none; }

.modal-card {
  width: min(460px, 100%);
  background: #fffdf0;
  border: 6px solid white;
  outline: 4px solid #8e7dff;
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 10px 0 rgba(39,52,90,.18);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  color: #6d5de7;
}

.close-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #ff7d7d;
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.modal-card label {
  display: block;
  margin-top: 15px;
  margin-bottom: 6px;
  font-weight: 900;
}

.modal-card select,
.modal-card input[type="number"] {
  width: 100%;
  min-height: 46px;
  border: 3px solid #cfe3ff;
  border-radius: 15px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
  font-size: 16px;
}

.check-line {
  display: flex !important;
  align-items: center;
  gap: 9px;
}

.small-fire {
  width: 100%;
  margin-top: 18px;
  font-size: 20px;
}

@media (max-width: 860px) {
  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .button-card {
    min-width: 0;
    flex-direction: row;
  }

  .button-card button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .app {
    width: calc(100% - 8px);
    margin-top: 4px;
  }

  .hero {
    border-radius: 18px;
    padding: 10px;
  }

  .star {
    display: none;
  }

  .hero p {
    font-size: 12px;
  }

  .hud {
    gap: 6px;
  }

  .hud-card {
    padding: 8px;
    border-width: 3px;
  }

  .hud-card strong {
    font-size: 15px;
  }

  .game-shell {
    border-radius: 18px;
    border-width: 4px;
  }

  .button-card {
    flex-direction: column;
  }
}
