* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #07090e;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f8fafc;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* 3D Splash Screen */
#splash-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: radial-gradient(circle at 50% 35%, #1a1025 0%, #05070b 100%);
}

#splash-screen.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
}

#three-container {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.splash-ui {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  pointer-events: none;
}

.splash-header {
  text-align: center;
  margin-top: 2px;
  text-shadow: 0 4px 14px rgba(0,0,0,0.95);
}

.badge {
  display: inline-block;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fca5a5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.splash-title {
  font-size: clamp(26px, 6.5vw, 40px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(to bottom, #fffbeb, #f59e0b, #b45309);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.9));
}

.character-labels {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 2px 4px #000;
}

.char-tag {
  background: rgba(9, 13, 22, 0.85);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 4px 8px;
  border-radius: 6px;
}

.splash-card {
  pointer-events: auto;
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}

.story-text {
  font-size: 13px;
  line-height: 1.45;
  color: #e2e8f0;
  margin-bottom: 10px;
}

.story-text strong {
  color: #fbbf24;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(23, 31, 48, 0.8);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}

.ctrl-item span {
  color: #38bdf8;
  font-weight: 700;
}

.start-btn {
  width: 100%;
  padding: 13px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 50%, #1d4ed8 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.8px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(220, 38, 38, 0.45);
  touch-action: manipulation;
}

/* Top HUD */
.top-hud {
  height: 46px;
  min-height: 46px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  z-index: 10;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.hud-pill {
  background: #1e293b;
  padding: 4px 7px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.hud-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.mini-btn {
  background: #334155;
  color: #f8fafc;
  border: none;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.mini-btn:active {
  background: #475569;
}

/* Viewport */
#viewport {
  flex: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #0f172a;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* Controls Deck */
.touch-deck {
  height: 108px;
  min-height: 108px;
  background: #0b1120;
  border-top: 2px solid #1e293b;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 8px 14px;
  z-index: 20;
  touch-action: none;
}

.touch-deck.all-right {
  justify-content: flex-end;
  gap: 14px;
}

.touch-deck.all-left {
  justify-content: flex-start;
  gap: 14px;
}

.deck-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ctrl-btn {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: #1e293b;
  border: 2px solid #475569;
  color: #f8fafc;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 #050811;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Prevent child text from intercepting touch target */
.ctrl-btn * {
  pointer-events: none;
}

.ctrl-btn small {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  margin-top: 2px;
}

.ctrl-btn.attack {
  background: #7f1d1d;
  border-color: #ef4444;
}

.ctrl-btn.jump {
  background: #0369a1;
  border-color: #38bdf8;
}

.ctrl-btn.active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #050811;
  filter: brightness(1.35);
}
