:root {
  --bg-panel: rgba(12, 18, 29, 0.75);
  --border-panel: rgba(100, 185, 255, 0.45);
  --text-main: #e8f4ff;
  --text-subtle: #b6d4f0;
  --accent: #50d6b4;
  --danger: #ff7272;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-main);
  font-family: "Rajdhani", sans-serif;
  background: radial-gradient(circle at 20% 10%, #2a3f56 0%, #111a26 45%, #070d15 100%);
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

#startupPanel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  z-index: 5;
  animation: panel-enter 420ms ease;
}

#startupPanel h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: 1px;
}

#startupPanel p {
  margin: 0 0 14px;
  color: var(--text-subtle);
}

.form-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 15px;
  color: var(--text-subtle);
}

.form-row input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(125, 182, 226, 0.55);
  background: rgba(8, 15, 22, 0.75);
  color: var(--text-main);
  padding: 10px 12px;
  font: inherit;
}

button,
a {
  border: 1px solid rgba(121, 234, 214, 0.65);
  background: linear-gradient(120deg, rgba(56, 188, 157, 0.26), rgba(88, 209, 245, 0.25));
  color: #e8fbff;
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  font: 600 16px/1 "Rajdhani", sans-serif;
  cursor: pointer;
}

button:hover,
a:hover {
  border-color: rgba(158, 255, 235, 0.8);
}

#startupPanel small {
  margin-top: 10px;
  display: block;
  color: var(--text-subtle);
  font-family: "Space Mono", monospace;
  font-size: 11px;
}

#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  padding: 12px;
  z-index: 4;
  min-width: 320px;
  animation: panel-enter 300ms ease;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px 12px;
  font-size: 17px;
}

.hud-grid span {
  color: var(--accent);
  font-family: "Space Mono", monospace;
}

.hud-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

#modeHint {
  position: fixed;
  bottom: 14px;
  left: 14px;
  padding: 10px 12px;
  z-index: 4;
}

#modeHint p {
  margin: 0;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  color: var(--text-subtle);
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font: 700 24px/1 "Space Mono", monospace;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.45);
  color: #ffffff;
  z-index: 4;
  pointer-events: none;
}

#hotbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
}

#hotbarSlots {
  display: flex;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(124, 169, 219, 0.55);
  border-radius: 14px;
  background: rgba(8, 14, 21, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
}

.hotbar-slot {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  border: 1px solid rgba(127, 162, 201, 0.45);
  background: rgba(20, 30, 43, 0.8);
  position: relative;
  overflow: hidden;
}

.hotbar-slot.selected {
  border-color: rgba(112, 255, 208, 0.95);
  box-shadow: 0 0 0 2px rgba(74, 220, 178, 0.35) inset;
}

.hotbar-slot-swatch {
  position: absolute;
  width: 26px;
  height: 26px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.hotbar-slot-key {
  position: absolute;
  top: 3px;
  left: 5px;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  color: rgba(222, 238, 255, 0.72);
}

.hotbar-slot-count {
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  color: rgba(222, 255, 236, 0.92);
}

.hotbar-slot-name {
  position: absolute;
  left: 5px;
  bottom: 4px;
  right: 5px;
  font-family: "Space Mono", monospace;
  font-size: 10px;
  color: rgba(186, 215, 243, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(119, 230, 172, 0.7);
  background: rgba(7, 24, 15, 0.85);
  color: #d6fbe7;
  z-index: 7;
  font-size: 15px;
}

#toast.error {
  border-color: rgba(255, 109, 109, 0.9);
  background: rgba(38, 8, 8, 0.88);
  color: #ffe8e8;
}

.hidden {
  display: none !important;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 740px) {
  #hud {
    min-width: 0;
    width: calc(100vw - 28px);
  }

  .hud-grid {
    grid-template-columns: 1fr;
  }

  .hud-actions {
    flex-wrap: wrap;
  }

  .hotbar-slot {
    width: 44px;
    height: 44px;
  }

  .hotbar-slot-swatch {
    width: 20px;
    height: 20px;
  }

  .hotbar-slot-name {
    display: none;
  }
}
