:root {
  --bg: #071018;
  --ink: #e8f4ff;
  --muted: #8aa3b8;
  --accent: #3de0c5;
  --accent-2: #ff7a45;
  --panel: rgba(8, 18, 28, 0.88);
  --line: rgba(61, 224, 197, 0.35);
  --font-display: "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "Segoe UI", "Helvetica Neue", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 30% 10%, rgba(61, 224, 197, 0.12), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(255, 122, 69, 0.1), transparent 40%),
    var(--bg);
}

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

#hud {
  position: absolute;
  top: max(12px, var(--safe-top));
  left: max(12px, var(--safe-left));
  right: max(12px, var(--safe-right));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}

.hud-score,
.hud-best {
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.hud-best {
  text-align: right;
}

.label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

#score,
#best {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(24px, calc(var(--safe-top) + 16px))
    max(24px, calc(var(--safe-right) + 16px))
    max(24px, calc(var(--safe-bottom) + 16px))
    max(24px, calc(var(--safe-left) + 16px));
  z-index: 3;
  background: rgba(4, 10, 16, 0.45);
}

.panel {
  width: min(360px, 100%);
  padding: 28px 24px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(12, 28, 40, 0.96), rgba(6, 14, 22, 0.94));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  animation: rise 420ms ease both;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, #e8f4ff 20%, var(--accent) 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
}

.sub {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  margin-bottom: 18px;
}

.meta,
.scoreline,
.hint {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.scoreline {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  min-width: 160px;
  min-height: 48px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #041018;
  background: linear-gradient(120deg, var(--accent), #7ef0d8);
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid #e8f4ff;
  outline-offset: 3px;
}

.hint {
  margin-top: 16px;
  margin-bottom: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.loader {
  width: 42px;
  height: 42px;
  margin: 8px auto 0;
  border-radius: 50%;
  border: 3px solid rgba(232, 244, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-height: 420px) {
  .panel {
    padding: 18px 16px;
  }

  .brand {
    font-size: 24px;
    margin-bottom: 6px;
  }

  .sub {
    font-size: 13px;
    margin-bottom: 10px;
  }
}
