:root {
  --stone: #1b2329;
  --stone-light: #3b4a54;
  --moss: #2f6b3e;
  --toxic: #a6ff3f;
  --blood: #e5235a;
  --bone: #f7e6b0;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(51, 104, 133, .35), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(12, 56, 25, .35), transparent 60%),
    #05090d;
  color: #d9e6e1;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 50% 50%, transparent 45%, rgba(0,0,0,.65) 100%);
  mix-blend-mode: overlay;
  opacity: .8;
}

#shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.5vh, 18px);
  padding: clamp(8px, 2vh, 24px);
}

#screen-wrap {
  position: relative;
  width: min(96vw, calc((100vh - 110px) * 4 / 3), 1180px);
  aspect-ratio: 4 / 3;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: #061018;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: none;
}

#loading {
  position: absolute;
  inset: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background:
    radial-gradient(circle at 50% 40%, rgba(28, 82, 62, .5), transparent 55%),
    #050b0d;
  z-index: 5;
  transition: opacity .45s ease, visibility .45s ease;
}
#loading.hidden { opacity: 0; visibility: hidden; }

.loading-title {
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(22px, 4vw, 54px);
  letter-spacing: .06em;
  color: var(--toxic);
  -webkit-text-stroke: 2px #12310d;
  text-shadow: 0 4px 0 #e5235a, 0 8px 24px rgba(0,0,0,.9);
  transform: rotate(-2deg);
}

.loading-bar {
  width: min(60%, 420px);
  height: 10px;
  border: 1px solid #395244;
  border-radius: 8px;
  background: #07110b;
  overflow: hidden;
}
.loading-bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #2e6a38, #a6ff3f, #2e6a38);
  animation: load 1.15s ease-in-out infinite alternate;
}
@keyframes load { from { transform: translateX(-30%); } to { transform: translateX(190%); } }

.loading-sub {
  color: #8ea89a;
  font-size: clamp(11px, 1.2vw, 14px);
  letter-spacing: .08em;
  text-transform: uppercase;
}

#foot {
  width: min(96vw, 1180px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #70857c;
  font-size: clamp(10px, 1.05vw, 13px);
  letter-spacing: .03em;
  text-transform: uppercase;
  user-select: none;
}
#foot b { color: #b8d0bd; font-weight: 600; }
.keys { text-align: right; }

#score-entry {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 7, 9, .72);
  backdrop-filter: blur(2px);
}
#score-entry.hidden { display: none; }

.score-card {
  width: min(78%, 430px);
  padding: clamp(16px, 3vw, 30px);
  text-align: center;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(80, 128, 75, .22), transparent 55%),
    linear-gradient(160deg, #26302f, #0e1516 45%, #090d0f);
  border: 1px solid rgba(154, 177, 164, .55);
  box-shadow:
    0 0 0 3px rgba(0,0,0,.55),
    0 0 0 4px rgba(154, 177, 164, .25),
    0 22px 50px rgba(0,0,0,.8);
}
.score-kicker {
  color: #8fa89a;
  font-size: clamp(9px, 1.2vw, 11px);
  letter-spacing: .18em;
}
.score-card h2 {
  margin: 5px 0 4px;
  color: var(--toxic);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(22px, 3.4vw, 36px);
  letter-spacing: .03em;
  line-height: 1;
  -webkit-text-stroke: 1px #17340f;
  text-shadow: 0 3px 0 var(--blood), 0 8px 18px rgba(0,0,0,.7);
}
.score-card p {
  margin: 0 0 14px;
  color: #a9c0b2;
  font-size: clamp(11px, 1.3vw, 13px);
}
.score-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 12px;
  max-width: 250px;
  padding: 7px 12px;
  border: 1px solid #354a42;
  border-radius: 7px;
  background: rgba(0,0,0,.32);
  color: #8fa89a;
  font-size: clamp(10px, 1.2vw, 12px);
  letter-spacing: .1em;
}
.score-line b {
  color: var(--bone);
  font-size: clamp(16px, 2.2vw, 22px);
  letter-spacing: .04em;
}
#score-name {
  width: min(250px, 90%);
  padding: 9px 12px;
  border: 1px solid #4d6b5a;
  border-radius: 7px;
  background: #07100c;
  color: #f0ffe8;
  font: inherit;
  font-size: clamp(15px, 2vw, 19px);
  font-weight: 700;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}
#score-name:focus {
  border-color: var(--toxic);
  box-shadow: 0 0 0 3px rgba(166, 255, 63, .14);
}
.score-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}
.score-actions button {
  padding: 9px 16px;
  border: 1px solid #6f9b78;
  border-radius: 7px;
  background: linear-gradient(#3c6e47, #1e4128);
  color: #eaffdf;
  font: inherit;
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
}
.score-actions button:hover { filter: brightness(1.12); }
.score-actions button.ghost {
  background: transparent;
  border-color: #3a4b44;
  color: #8fa89a;
}
kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 5px;
  border: 1px solid #3a4b44;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #0e1518;
  color: #a9c0b2;
  font: inherit;
  font-size: .92em;
  text-align: center;
}

@media (max-width: 700px) {
  #foot .keys,
  #foot > span:first-child { display: none; }
  #foot { justify-content: center; }
}
