:root {
  --nut-w: 66px;
  --nut-h: 30px;
  --rod-w: 18px;
  --bolt-w: 90px;
  --base-h: 14px;
  --bolt-h: calc(var(--base-h) + 5 * var(--nut-h) + 58px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 20%, #3a4454, #1d232e 70%);
  color: #e8ecf2;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.top-banner {
  background: #fff7bf;
  padding: 10px 20px;
  text-align: center;
}

.top-banner a {
  color: #1f2a3a;
  font-weight: 700;
  text-decoration: none;
}

.top-banner a:hover,
.top-banner a:focus-visible {
  text-decoration: underline;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
}

h1 { font-size: 1.4rem; letter-spacing: 1px; }

#level-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffd166;
}

.controls { margin-left: auto; display: flex; gap: 8px; }

button {
  background: #313c4d;
  color: #e8ecf2;
  border: 1px solid #4a586e;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { background: #3d4a5f; }
button:active { transform: translateY(1px); }

#board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 18px 10px;
  padding: 30px 12px 60px;
  max-width: 900px;
  margin: 0 auto;
}

/* ---------- bolt ---------- */

.bolt {
  position: relative;
  width: var(--bolt-w);
  height: var(--bolt-h);
  cursor: pointer;
}

.bolt .rod {
  position: absolute;
  left: calc(50% - var(--rod-w) / 2);
  bottom: var(--base-h);
  width: var(--rod-w);
  height: calc(var(--bolt-h) - var(--base-h) - 16px);
  background:
    repeating-linear-gradient(
      -60deg,
      #9aa5b1 0 3px,
      #6b7684 3px 7px
    );
  border-radius: 4px 4px 2px 2px;
  box-shadow: inset -4px 0 6px rgba(0,0,0,.35), inset 4px 0 6px rgba(255,255,255,.15);
}

.bolt .tip {
  position: absolute;
  left: calc(50% - var(--rod-w) / 2 - 4px);
  top: 6px;
  width: calc(var(--rod-w) + 8px);
  height: 12px;
  background: linear-gradient(#c3ccd6, #7d8794);
  border-radius: 5px;
  box-shadow: 0 2px 3px rgba(0,0,0,.4);
}

.bolt .base {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: var(--base-h);
  background: linear-gradient(#55617a, #333c4e);
  border-radius: 6px;
  box-shadow: 0 3px 6px rgba(0,0,0,.5);
}

.bolt.complete .rod,
.bolt.complete .tip { filter: brightness(1.15); }

.bolt.complete::after {
  content: "\2713";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  color: #7bd88f;
  font-size: 1.2rem;
  font-weight: bold;
}

/* ---------- nuts ---------- */

.nut {
  position: absolute;
  left: calc(50% - var(--nut-w) / 2);
  width: var(--nut-w);
  height: var(--nut-h);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background:
    linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,0) 45%,
                    rgba(0,0,0,.25) 90%),
    var(--c);
  transition: transform 0.18s ease;
  pointer-events: none;
}

.nut::after {
  content: "";
  position: absolute;
  left: calc(50% - var(--rod-w) / 2 - 2px);
  top: calc(50% - 4px);
  width: calc(var(--rod-w) + 4px);
  height: 8px;
  background: rgba(0,0,0,.28);
  border-radius: 4px;
}

.nut.lifted { transform: translateY(-48px); }

@keyframes drop {
  from { transform: translateY(-56px); }
  to   { transform: translateY(0); }
}
.nut.drop { animation: drop 0.2s ease-in; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.bolt.shake { animation: shake 0.18s ease 2; }

/* ---------- overlay ---------- */

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
#overlay.hidden { display: none; }

.panel {
  background: #2a3342;
  border: 1px solid #4a586e;
  border-radius: 14px;
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.panel h2 { font-size: 1.7rem; margin-bottom: 10px; color: #ffd166; }
.panel p { margin-bottom: 22px; color: #b8c2d0; }
.panel button {
  background: #ffd166;
  color: #22282f;
  font-weight: 700;
  border: none;
  padding: 12px 28px;
  font-size: 1.05rem;
}
.panel button:hover { background: #ffdc85; }