@font-face {
  font-family: 'Nosifer';
  src: url('fonts/Nosifer-Regular.ttf') format('truetype');
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #020308;
  overflow: hidden;
}

body {
  background:
    radial-gradient(90% 62% at 78% 4%, rgba(120, 110, 190, 0.16), transparent 62%),
    radial-gradient(120% 100% at 50% 50%, #080b16 0%, #04050b 55%, #020308 100%);
  color: #dfffd0;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
}

body::before {
  content: '';
  position: fixed;
  top: -10vmin;
  right: -6vmin;
  width: 54vmin;
  height: 54vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(210, 220, 255, 0.11), rgba(160, 170, 230, 0.045) 42%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#cabinet {
  --bandH: 56px;
  --tableW: 390px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  filter: drop-shadow(0 16px 38px rgba(0, 0, 0, 0.85));
}

#backglass {
  position: relative;
  width: 100%;
  height: var(--bandH);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2%;
  padding: 0 2.4%;
  background:
    linear-gradient(180deg, rgba(4, 7, 12, 0.62), rgba(3, 5, 9, 0.88)),
    url('assets/stone.jpg') center / cover;
  border: 1px solid #04060a;
  border-bottom: 2px solid #7CFF2A;
  box-shadow:
    0 0 20px rgba(124, 255, 42, 0.32),
    inset 0 -9px 20px rgba(124, 255, 42, 0.10),
    inset 0 8px 18px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

#backglass::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26%;
  background: linear-gradient(180deg, transparent, rgba(124, 255, 42, 0.10));
  pointer-events: none;
}

.bgskull {
  flex: 0 0 auto;
  height: 78%;
  width: auto;
  opacity: 0.92;
  filter: drop-shadow(0 0 6px rgba(124, 255, 42, 0.45)) brightness(0.86) contrast(1.05);
}

#scoreBlock {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.label {
  font-size: max(7px, calc(var(--bandH) * 0.145));
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #7CFF2A;
  opacity: 0.72;
  text-shadow: 0 0 6px rgba(124, 255, 42, 0.65);
  line-height: 1;
  margin-bottom: 1px;
}

#score {
  font-family: 'Nosifer', 'Trebuchet MS', sans-serif;
  font-size: min(calc(var(--bandH) * 0.5), calc(var(--tableW) * 0.075));
  line-height: 1;
  color: #c9ff8f;
  white-space: nowrap;
  letter-spacing: 0.01em;
  text-shadow:
    0 0 3px #ffffff,
    0 0 9px #7CFF2A,
    0 0 22px rgba(124, 255, 42, 0.8);
}

#ballBlock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}

#balls {
  display: flex;
  align-items: center;
  gap: 2px;
  height: calc(var(--bandH) * 0.34);
}

.ballIcon {
  height: 100%;
  width: auto;
  filter: drop-shadow(0 0 5px rgba(124, 255, 42, 0.9)) brightness(1.15);
  transition: opacity 0.25s, filter 0.25s;
}

.ballIcon.lost {
  opacity: 0.16;
  filter: grayscale(1) brightness(0.55);
}

#tableWrap {
  position: relative;
  width: 100%;
  background: #04060a;
  border-left: 1px solid #04060a;
  border-right: 1px solid #04060a;
  overflow: hidden;
  box-shadow:
    0 0 34px rgba(0, 0, 0, 0.9),
    0 0 70px rgba(124, 255, 42, 0.06);
}

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

#hint {
  align-self: center;
  margin-top: 2px;
  height: 26px;
  max-width: 100%;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(2, 6, 4, 0.9);
  border: 1px solid rgba(124, 255, 42, 0.55);
  color: #eaffd8;
  font-size: clamp(8px, 1.35vh, 12px);
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-shadow: 0 0 6px rgba(124, 255, 42, 0.65);
  box-shadow: 0 0 12px rgba(124, 255, 42, 0.15);
}

#hint.show { opacity: 1; }
#hint .coarse { display: none; }

@media (pointer: coarse) {
  #hint .fine { display: none; }
  #hint .coarse { display: inline; }
}

#cornerBtns {
  position: absolute;
  left: 2.2%;
  bottom: 1.4%;
  display: flex;
  gap: 5px;
  z-index: 6;
}

#cornerBtns button {
  width: clamp(20px, calc(var(--tableW) * 0.072), 30px);
  height: clamp(20px, calc(var(--tableW) * 0.072), 30px);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(124, 255, 42, 0.45);
  background: rgba(2, 6, 4, 0.78);
  color: #9dff5e;
  font-family: 'Trebuchet MS', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(124, 255, 42, 0.22);
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
}

#cornerBtns button:active { transform: scale(0.94); }

#soundBtn svg {
  width: 62%;
  height: 62%;
  display: block;
}

#soundBtn .slash { display: none; }
#soundBtn.off .wave { display: none; }
#soundBtn.off .slash { display: block; }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 8, 0.74);
  backdrop-filter: blur(3px);
  z-index: 10;
}

#overlay.hidden { display: none; }

#overPanel {
  position: relative;
  width: min(80%, 330px);
  padding: 30px 18px 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(4, 8, 10, 0.84), rgba(3, 6, 8, 0.92)),
    url('assets/stone.jpg') center / cover;
  border: 1px solid rgba(124, 255, 42, 0.5);
  border-radius: 4px;
  box-shadow:
    0 0 32px rgba(124, 255, 42, 0.25),
    0 0 70px rgba(0, 0, 0, 0.8),
    inset 0 0 34px rgba(0, 0, 0, 0.9);
}

.overSkull {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: auto;
  filter: drop-shadow(0 0 9px rgba(124, 255, 42, 0.7)) brightness(0.95);
}

.overTitle {
  font-family: 'Nosifer', 'Trebuchet MS', sans-serif;
  font-size: clamp(18px, 4.4vh, 32px);
  line-height: 1.1;
  color: #b6ff6a;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 4px #ffffff,
    0 0 16px #7CFF2A,
    0 0 34px rgba(124, 255, 42, 0.7);
  margin-bottom: 10px;
}

.overRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(124, 255, 42, 0.15);
  font-size: clamp(9px, 1.4vh, 12px);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #7CFF2A;
  opacity: 0.9;
}

.overRow b {
  font-family: 'Nosifer', 'Trebuchet MS', sans-serif;
  font-size: clamp(17px, 3.5vh, 29px);
  letter-spacing: 0;
  color: #c9ff8f;
  text-shadow: 0 0 10px #7CFF2A;
}

.overRow.small b {
  font-size: clamp(13px, 2.3vh, 19px);
  color: #b98cff;
  text-shadow: 0 0 10px #B23CFF;
}

#againBtn {
  margin-top: 15px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid #7CFF2A;
  background: rgba(124, 255, 42, 0.12);
  color: #d8ffb0;
  font-family: 'Trebuchet MS', sans-serif;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: clamp(10px, 1.6vh, 13px);
  cursor: pointer;
  box-shadow:
    0 0 16px rgba(124, 255, 42, 0.35),
    inset 0 0 12px rgba(124, 255, 42, 0.15);
  text-shadow: 0 0 8px #7CFF2A;
  -webkit-tap-highlight-color: transparent;
}

#againBtn:active { transform: scale(0.97); }
