:root {
  --bg-1: #070b1b;
  --bg-2: #0f1732;
  --accent: #4cc9f0;
  --accent-2: #f72585;
  --text: #f8f9ff;
  --panel: rgba(12, 16, 36, 0.84);
  --panel-border: rgba(130, 156, 255, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at 20% 20%, #1a2249 0, var(--bg-1) 50%, #03050e 100%);
}

#gameCanvas {
  display: block;
  margin: 0 auto;
  background: linear-gradient(to bottom, var(--bg-1), var(--bg-2));
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.6);
}

.overlay-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 500px);
  padding: 28px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 25px 40px rgba(0, 0, 0, 0.45);
  z-index: 10;
  text-align: center;
  backdrop-filter: blur(10px);
}

.overlay-card h1 {
  margin-top: 0;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
}

#startButton,
#difficultySelect {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

#startButton {
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(135deg, #2f76ff, #7747ff);
  font-weight: 600;
}

#startButton:hover {
  filter: brightness(1.12);
}

.hint {
  margin-top: 16px;
  font-size: 13px;
  color: #b6c0ff;
}

.hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  z-index: 8;
}

.hud-left,
.hud-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  background: rgba(7, 10, 24, 0.72);
  border: 1px solid rgba(119, 161, 255, 0.45);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.hidden {
  display: none;
}

.score-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 210px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  z-index: 9;
  backdrop-filter: blur(8px);
}

.score-panel h2 {
  margin: 2px 0 10px;
  font-size: 18px;
  text-align: center;
}

#scoreTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#scoreTable th,
#scoreTable td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  padding: 6px;
}

#scoreTable th {
  color: #a4dcff;
  font-weight: 600;
}

.skill-tree-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 92vw);
  max-height: 85vh;
  overflow: auto;
  background: radial-gradient(circle at top, rgba(52, 34, 16, 0.8), rgba(12, 16, 36, 0.95));
  border: 1px solid rgba(150, 95, 53, 0.65);
  border-radius: 20px;
  padding: 20px;
  z-index: 9;
  backdrop-filter: blur(9px);
  box-shadow: 0 30px 40px rgba(0, 0, 0, 0.5);
}

.skill-tree-panel h2 {
  margin: 2px 0 4px;
  font-size: 18px;
}

.skill-subtitle {
  margin: 0 0 12px;
  font-size: 13px;
  color: #e7d9c6;
}

.skill-tree-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, auto);
  gap: 20px;
  position: relative;
  padding: 24px 10px 10px;
}

.skill-tree-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 48%, rgba(123, 79, 44, 0.9) 50%, transparent 52%) center 8% / 42px 88% no-repeat,
    linear-gradient(145deg, transparent 50%, rgba(123, 79, 44, 0.75) 51%, transparent 53%) 35% 26% / 170px 54px no-repeat,
    linear-gradient(35deg, transparent 50%, rgba(123, 79, 44, 0.75) 51%, transparent 53%) 58% 26% / 170px 54px no-repeat,
    linear-gradient(145deg, transparent 50%, rgba(123, 79, 44, 0.75) 51%, transparent 53%) 21% 49% / 180px 54px no-repeat,
    linear-gradient(35deg, transparent 50%, rgba(123, 79, 44, 0.75) 51%, transparent 53%) 68% 49% / 180px 54px no-repeat,
    radial-gradient(circle at center, rgba(68, 124, 62, 0.2) 0%, transparent 72%);
}

.skill-node-wrapper {
  display: flex;
  justify-content: center;
}

.skill-node {
  text-align: center;
  border: 1px solid rgba(151, 232, 138, 0.5);
  background: linear-gradient(180deg, rgba(34, 60, 26, 0.9), rgba(23, 39, 19, 0.9));
  color: var(--text);
  border-radius: 50%;
  width: 118px;
  min-height: 118px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.28), 0 0 16px rgba(106, 219, 100, 0.18);
}

.skill-node:hover:not(:disabled) {
  border-color: #b5ff76;
  transform: translateY(-2px) scale(1.03);
}

.skill-node:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.skill-node.unlocked {
  border-color: #ffe066;
  background: linear-gradient(180deg, rgba(87, 108, 23, 0.92), rgba(63, 82, 17, 0.9));
  box-shadow: 0 0 18px rgba(255, 224, 102, 0.35);
}

.skill-node-title {
  font-weight: 700;
  font-size: 12px;
}

.skill-node-desc {
  font-size: 10px;
  color: #def5cf;
}

.skill-node-cost {
  font-size: 10px;
  color: #f9e7ab;
}

.secondary-button {
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.settings-panel {
  width: min(92vw, 520px);
  z-index: 11;
  text-align: left;
}

.settings-subtitle {
  margin: 0 0 14px;
  color: #c6d0ff;
  font-size: 14px;
}

.keybind-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.keybind-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
}

.keybind-action {
  font-weight: 600;
}

.keybind-button,
#closeSettingsButton {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
