*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #1c1c1c;
  overflow: hidden;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

#hud {
  position: absolute;
  top: 16px;
  left: 20px;
  pointer-events: none;
  color: #6d6d6d;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

#score {
  font-size: 22px;
  letter-spacing: 0.08em;
  font-weight: 400;
}

#best {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #5a5a5a;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 18, 18, 0.46);
}

.overlay[hidden],
.panel[hidden],
#hud[hidden] {
  display: none;
}

.panel {
  text-align: center;
  color: #ececec;
  padding: 28px 36px;
}

.panel h1 {
  margin: 0 0 16px;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #3fd4e8;
  text-shadow: 2px 2px 0 #1a1a1a;
}

.panel p {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.5;
  color: #d0d0d0;
}

.panel .controls {
  margin-bottom: 28px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #8d8d8d;
}

.panel .result {
  font-size: 18px;
}

.panel .muted {
  color: #9a9a9a;
  margin-bottom: 28px;
}

button {
  appearance: none;
  border: 3px solid #141414;
  background: #3fd4e8;
  color: #1a1a1a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 12px 28px;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: #2ee6c3;
  outline: none;
}

button:active {
  transform: translateY(1px);
}

.mode-box {
  display: table;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 22px;
  padding: 12px 16px 14px;
  border: 2px solid rgba(63, 212, 232, 0.45);
  background: rgba(18, 18, 18, 0.6);
}

.mode-label {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: #3fd4e8;
}

.mode-select {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.mode-select.compact {
  margin-bottom: 20px;
}

.mode-btn {
  background: rgba(18, 18, 18, 0.55);
  color: #d0d0d0;
  border: 2px solid #5a5a5a;
  font-size: 14px;
  letter-spacing: 0.14em;
  padding: 10px 18px;
  min-width: 150px;
}

.mode-select.compact .mode-btn {
  min-width: 0;
  font-size: 12px;
  padding: 7px 14px;
}

.mode-btn span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #b0b0b0;
}

.mode-btn:hover,
.mode-btn:focus-visible {
  background: rgba(63, 212, 232, 0.18);
  border-color: #3fd4e8;
}

.mode-btn.active,
.mode-btn.active:hover,
.mode-btn.active:focus-visible {
  background: #3fd4e8;
  border-color: #141414;
  color: #1a1a1a;
}

.mode-btn.active span {
  color: #1a3a40;
}

#hud-mode {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #5a5a5a;
}

#phase-warning {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -6px);
  pointer-events: none;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #ffffff;
  text-shadow: 2px 2px 0 #1a1a1a;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#phase-warning.show {
  opacity: 1;
  transform: translate(-50%, 0);
  animation: phase-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes phase-pulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.45;
  }
}
