:root {
  --space-900: #040913;
  --space-700: #0d1b2d;
  --space-500: #163153;
  --accent-1: #8de0ff;
  --accent-2: #ffd479;
  --danger: #ff7373;
  --ok: #82f2bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #e9f5ff;
  background:
    radial-gradient(80rem 30rem at 10% -10%, #1d3f67 0%, transparent 50%),
    radial-gradient(90rem 30rem at 100% 0%, #0d2a4a 0%, transparent 40%),
    linear-gradient(130deg, var(--space-900), #02070e);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.shell {
  width: min(100%, 1040px);
  display: grid;
  gap: 0.75rem;
  position: relative;
}

.panel {
  border: 1px solid #245488;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(10, 22, 36, 0.88), rgba(8, 16, 28, 0.9));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.uplink {
  padding: 0.9rem 1rem 1rem;
  display: grid;
  gap: 0.8rem;
}

.uplink h2,
.uplink h3 {
  margin: 0;
  color: #b9eaff;
}

.uplink p {
  margin: 0.3rem 0 0;
  color: #b4d3eb;
}

#scoreForm {
  display: grid;
  grid-template-columns: auto minmax(120px, 220px) auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

#scoreForm label {
  margin: 0;
  font-size: 0.85rem;
}

#scoreForm input {
  width: 100%;
  border: 1px solid #2f6ea3;
  border-radius: 7px;
  padding: 0.5rem 0.6rem;
  background: #0b1f34;
  color: #ecf7ff;
}

#scoreForm button {
  border: 1px solid #3c82ba;
  background: linear-gradient(180deg, #2f78b4, #1f5e91);
  color: #eef9ff;
  border-radius: 7px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

#scoreForm button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#scoreStatus {
  color: #afd3ef;
}

#leaderboard {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.2rem;
  color: #d8eeff;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  color: var(--accent-1);
}

.top p {
  margin: 0.25rem 0 0;
  color: #acc9df;
}

.stats {
  display: flex;
  gap: 0.9rem;
}

.stats div {
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: rgba(24, 59, 95, 0.65);
  border: 1px solid #2c679f;
  min-width: 88px;
  text-align: center;
}

.stats span {
  display: block;
  font-size: 0.72rem;
  color: #a8d7ff;
}

.stats strong {
  font-size: 1.15rem;
  color: white;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  min-height: 260px;
  touch-action: none;
}

.bottom {
  padding: 0.8rem 1rem 1rem;
}

.meters {
  display: grid;
  gap: 0.45rem;
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: #c9e8ff;
}

progress {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: #08213b;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--ok), #d6ff9f);
}

progress[value="0"]::-webkit-progress-value {
  background: var(--danger);
}

kbd {
  background: #173f69;
  border: 1px solid #3576af;
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
}

.touch-controls {
  display: none;
  padding: 0.8rem 1rem 1rem;
  grid-template-columns: 1fr auto;
  gap: 0.9rem;
  align-items: center;
}

.stick-wrap p {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: #aacde8;
}

.touch-pad {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid #2f6ea2;
  background: radial-gradient(circle at 30% 25%, #21496f, #0d2137);
  position: relative;
  touch-action: none;
}

.touch-knob {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(180deg, #90dcff, #4184b8);
  border: 2px solid #caedff;
  position: absolute;
  left: 39px;
  top: 39px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.action-wrap {
  display: grid;
  gap: 0.6rem;
}

.touch-btn {
  min-width: 116px;
  border-radius: 999px;
  border: 1px solid #3e82ba;
  background: linear-gradient(180deg, #2f78b4, #1f5e91);
  color: #f2f9ff;
  font-weight: 700;
  padding: 0.7rem 0.95rem;
  touch-action: manipulation;
}

.touch-btn.alt {
  border-color: #b4863e;
  background: linear-gradient(180deg, #b6852f, #865d1f);
}

.touch-btn:active,
.touch-btn.is-active {
  transform: scale(0.97);
  filter: brightness(1.1);
}

@media (max-width: 760px) {
  .top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }
  #scoreForm {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .touch-controls {
    display: grid;
  }
}
