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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  font-family: 'Segoe UI', Arial, sans-serif;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  color: #fff;
}

/* === HUD === */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  background: rgba(10,10,15,0.9);
  border-bottom: 1px solid #1a3355;
  z-index: 20;
}

#hud-atp {
  font-size: 18px;
  font-weight: bold;
  color: #ffdd00;
}

#hud-wave {
  font-size: 16px;
  color: #fff;
  font-weight: bold;
}

#hud-lives {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
}

.hud-heart { color: #ff3333; }

#hud-timer {
  font-size: 16px;
  font-weight: bold;
  color: #aabbcc;
}
.hud-icon { margin-right: 2px; }

/* === GAME CANVAS === */
#gameCanvas {
  position: fixed;
  top: 50px;
  left: 0;
  width: 100%;
  touch-action: none;
  z-index: 1;
}

/* === N-BACK AREA === */
#nback-area {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 240px;
  background: #12121f;
  border-top: 2px solid #1a3355;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 10px 10px;
  z-index: 20;
}

#nback-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  margin-bottom: 6px;
}

#nback-level {
  font-size: 14px;
  color: #00ccff;
  font-weight: bold;
}

#nback-streak {
  font-size: 14px;
  color: #00ff88;
  font-weight: bold;
}

/* N-Back Grid */
#nback-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  width: 130px;
  height: 130px;
  margin-bottom: 8px;
}

.nback-cell {
  background: rgba(25,35,60,0.8);
  border-radius: 50%;
  border: 2px solid #1a3355;
  transition: background 0.12s, border-color 0.12s;
}

.nback-cell.lit {
  background: #00ccff;
  border-color: #44ddff;
}

/* N-Back Buttons */
#nback-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 6px;
}

.nback-btn {
  flex: 1;
  height: 60px;
  font-size: 17px;
  font-weight: bold;
  border-radius: 12px;
  border: 2px solid;
  cursor: pointer;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, background 0.15s;
  background: rgba(20,30,50,0.9);
}

.nback-btn:active {
  transform: scale(0.95);
}

.btn-pos {
  border-color: #00cc66;
}

.btn-both {
  border-color: #ffaa00;
}

.btn-snd {
  border-color: #4488ff;
}

.nback-btn.btn-glow, .build-btn.btn-glow {
  animation: btnGlow 0.8s ease-in-out infinite;
}

@keyframes btnGlow {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(255,220,0,0.4); }
  50% { box-shadow: 0 0 18px 6px rgba(255,220,0,0.8); }
}

.nback-btn.flash-correct {
  background: #00aa44 !important;
  border-color: #00ff88 !important;
}

.nback-btn.flash-wrong {
  background: #aa0022 !important;
  border-color: #ff3333 !important;
}

#nback-hint {
  font-size: 11px;
  color: #667;
  text-align: center;
}

#match-hint {
  font-size: 16px;
  font-weight: bold;
  color: #ffdd00;
  text-align: center;
  padding: 6px;
  animation: pulse 0.6s ease-in-out infinite;
  margin-top: 4px;
}

/* === BUILD BAR === */
#build-bar {
  position: fixed;
  bottom: 240px;
  left: 0; right: 0;
  height: 50px;
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  background: rgba(10,10,20,0.95);
  border-top: 1px solid #1a3355;
  z-index: 20;
  padding: 0 10px;
}

.build-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 8px;
  border-radius: 10px;
  border: 2px solid #334;
  background: rgba(20,25,40,0.9);
  color: #aab;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
}

.build-btn:active { transform: scale(0.96); }

.build-btn.build-selected {
  border-color: #00ccff;
  background: rgba(0,80,130,0.4);
  color: #fff;
}

.build-btn.build-locked {
  opacity: 0.35;
  pointer-events: none;
}

.build-icon { font-size: 20px; }
.build-label { text-align: left; line-height: 1.2; }
.build-label small { color: #ffdd00; font-size: 10px; }

/* === FLOATING TEXT === */
#float-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

.float-text {
  position: absolute;
  font-weight: bold;
  font-size: 18px;
  pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
  text-align: center;
  white-space: nowrap;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-50px); }
}

/* Not enough ATP */
#no-atp-msg {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(120,20,20,0.9);
  color: #ff6644;
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 15px;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

#no-atp-msg.show {
  opacity: 1;
}

/* === OVERLAYS === */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5,5,10,0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay-content {
  background: rgba(12,16,30,0.97);
  border: 2px solid #1a3355;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 380px;
  width: 90%;
}

.overlay-content h1 {
  font-size: 32px;
  color: #00ccff;
  letter-spacing: 3px;
  margin-bottom: 6px;
}

.overlay-content h2 {
  font-size: 22px;
  color: #00ccff;
  margin-bottom: 10px;
}

.overlay-content p {
  color: #bbb;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.overlay-content .subtitle {
  color: #ff44ff;
  font-size: 16px;
  margin-bottom: 16px;
}

.overlay-content .tagline {
  margin-bottom: 24px;
}

.go-title {
  color: #ff3333 !important;
}

.victory-title {
  color: #00ff88 !important;
  letter-spacing: 2px;
}

#start-logo {
  width: 100px;
  height: 100px;
  margin-bottom: 12px;
}

.pulse-title {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* Buttons */
.big-btn {
  display: inline-block;
  min-width: 200px;
  min-height: 56px;
  font-size: 20px;
  font-weight: bold;
  border-radius: 14px;
  border: 2px solid #00ff88;
  background: linear-gradient(135deg, #00aa66, #006644);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s;
  padding: 10px 24px;
  margin-top: 6px;
}

.big-btn:active {
  transform: scale(0.95);
}

.btn-red {
  border-color: #ff3333;
  background: linear-gradient(135deg, #aa2200, #661100);
}

.tut-btn {
  display: inline-block;
  min-width: 180px;
  min-height: 50px;
  font-size: 17px;
  font-weight: bold;
  border-radius: 12px;
  border: 2px solid #00ccff;
  background: linear-gradient(135deg, #0066aa, #004488);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s;
  padding: 8px 20px;
  margin-top: 10px;
}

/* Tutorial hint (dezent) */
#tutorial-hint {
  position: fixed;
  top: 55px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 360px;
  width: 90%;
  background: rgba(10,15,30,0.88);
  border: 1px solid #1a3366;
  border-radius: 12px;
  padding: 12px 16px;
  z-index: 50;
  text-align: center;
  animation: tutFadeIn 0.3s ease-out;
}

@keyframes tutFadeIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#tutorial-text {
  color: #ccd;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 8px;
  text-align: left;
}

#tutorial-text b { color: #fff; }

.tut-btn-inline {
  display: inline-block;
  padding: 6px 20px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 8px;
  border: 1px solid #00ccff;
  background: rgba(0,60,100,0.5);
  color: #00ccff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tut-btn-inline:active { transform: scale(0.96); }

.tut-skip-inline {
  font-size: 11px;
  color: #445;
  cursor: pointer;
  margin-left: 12px;
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
}

.tut-text {
  text-align: left;
  color: #ccc;
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
}

/* Stars canvas */
#stars-canvas {
  display: block;
  margin: 8px auto;
}

#wc-tap {
  font-size: 13px;
  color: #667;
  transition: opacity 0.5s;
}

/* === RESPONSIVE === */
@media (max-width: 380px) {
  #hud { height: 44px; padding: 0 8px; }
  #hud-atp { font-size: 15px; }
  #hud-wave { font-size: 14px; }
  #nback-area { height: 220px; padding: 6px 8px 8px; }
  #nback-grid { width: 110px; height: 110px; }
  .nback-btn { height: 52px; font-size: 15px; }
  .overlay-content { padding: 20px 16px; }
}

@media (min-width: 700px) {
  #nback-area { max-width: 500px; left: 50%; transform: translateX(-50%); border-radius: 12px 12px 0 0; }
}
