/* ============================================
   NEON TETRIS - Styles
   ============================================ */
:root {
  --bg-deep: #050510;
  --neon-blue: #00d4ff;
  --neon-blue-g: rgba(0, 212, 255, 0.4);
  --neon-pink: #ff2d95;
  --neon-pink-g: rgba(255, 45, 149, 0.4);
  --neon-green: #39ff14;
  --neon-green-g: rgba(57, 255, 20, 0.4);
  --neon-yellow: #ffe156;
  --neon-orange: #ff8c00;
  --neon-red: #ff3344;
  --text-primary: #e4e4f0;
  --text-dim: #7777aa;
  --bg-glass: rgba(12, 12, 35, 0.8);
  --border-glow: rgba(0, 212, 255, 0.15);
  --font-display: 'Orbitron', monospace, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  max-width: 100%;
}

.game-header {
  text-align: center;
}

.game-logo {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px var(--neon-blue-g));
}

.subtitle {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Board Layout */
#main-board {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Side Panels */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 120px;
}

.panel-box {
  background: var(--bg-glass);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(0, 212, 255, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--neon-blue);
  text-shadow: 0 0 5px var(--neon-blue-g);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.preview-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(5, 5, 15, 0.6);
  border-radius: 6px;
  width: 100px;
  height: 100px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-slot canvas {
  display: block;
}

/* Help Box */
.controls-guide-box {
  flex-grow: 1;
}

.help-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: left;
}

.help-content p {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
  padding-bottom: 4px;
}

.help-content kbd {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--neon-blue);
  margin-left: 2px;
}

/* Stats Box */
.stats-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
}

#score-val {
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink-g);
}

#best-val {
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 225, 86, 0.25);
}

/* Main Canvas Frame */
#canvas-frame {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-glow);
  box-shadow: 0 0 25px rgba(0, 212, 255, 0.08), inset 0 0 30px rgba(0, 0, 0, 0.5);
  background: #04040c;
}

#game-canvas {
  display: block;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(3, 3, 10, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.tetris-icon {
  font-size: 2.8rem;
  animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.05); }
}

.overlay-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--neon-pink);
  text-shadow: 0 0 15px var(--neon-pink-g);
}

.neon-blue-text {
  color: var(--neon-blue);
  text-shadow: 0 0 15px var(--neon-blue-g);
}

.neon-red-text {
  color: var(--neon-red);
  text-shadow: 0 0 15px rgba(255, 50, 50, 0.5);
}

.gameover-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text-dim);
}

.stat-highlight {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue-g);
}

.arcade-btn {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s ease;
  box-shadow: 0 0 15px var(--neon-blue-g);
}

.arcade-btn:hover {
  transform: translateY(-1.5px) scale(1.03);
  box-shadow: 0 0 25px var(--neon-blue-g), 0 0 45px rgba(255, 45, 149, 0.15);
}

.arcade-btn:active {
  transform: scale(0.97);
}

/* Floating Back to Portal Button */
.back-home-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(10, 10, 26, 0.75);
  border: 1px solid var(--neon-blue);
  border-radius: 20px;
  color: var(--neon-blue);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.1em;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2), inset 0 0 4px rgba(0, 212, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.25s ease;
  cursor: pointer;
}

.back-home-btn:hover {
  background: var(--neon-blue);
  color: #050510;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.45);
  transform: translateY(-1.5px);
}

.back-home-btn:active {
  transform: translateY(0);
}

/* Mobile Controller styles (Hidden on Desktop) */
#mobile-controller {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin-top: 15px;
}

.ctrl-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.ctrl-btn {
  flex: 1;
  background: rgba(20, 20, 45, 0.7);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.ctrl-btn:active {
  background: var(--neon-blue);
  color: var(--bg-deep);
  border-color: var(--neon-blue);
  box-shadow: 0 0 15px var(--neon-blue-g);
  transform: scale(0.95);
}

.ctrl-arrow {
  font-size: 1.1rem;
  background: rgba(20, 20, 50, 0.85);
  border-color: rgba(255, 45, 149, 0.25);
  color: var(--neon-pink);
}

.ctrl-arrow:active {
  background: var(--neon-pink);
  color: var(--bg-deep);
  border-color: var(--neon-pink);
  box-shadow: 0 0 15px var(--neon-pink-g);
}

.ctrl-navigation .ctrl-btn {
  height: 50px;
}

/* Responsive Scaling */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
    overflow-y: auto;
    padding: 10px 4px 30px 4px;
  }

  #app {
    padding: 5px;
  }

  #game-wrapper {
    gap: 8px;
  }

  .game-logo {
    font-size: 1.6rem;
  }

  .subtitle {
    font-size: 0.6rem;
    letter-spacing: 0.25em;
  }

  #main-board {
    gap: 8px;
  }

  .side-panel {
    width: 68px;
    gap: 8px;
  }

  .panel-box {
    padding: 6px 4px;
    border-radius: 6px;
  }

  .panel-title {
    font-size: 0.55rem;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
  }

  .preview-slot {
    width: 60px;
    height: 60px;
  }

  .preview-slot canvas {
    transform: scale(0.65);
  }

  .controls-guide-box {
    display: none; /* Hide help keys on mobile */
  }

  .stats-box {
    gap: 6px;
  }

  .stat-item {
    gap: 0;
  }

  .stat-label {
    font-size: 0.45rem;
  }

  .stat-value {
    font-size: 0.85rem;
  }

  #canvas-frame {
    border-width: 1px;
  }

  /* Show mobile controls */
  #mobile-controller {
    display: flex;
  }

  .back-home-btn {
    top: 10px;
    left: 10px;
    padding: 6px 12px;
    font-size: 0.65rem;
  }
}

/* Portrait adjustments */
@media (max-height: 700px) and (max-width: 600px) {
  #mobile-controller {
    gap: 5px;
  }
  .ctrl-btn {
    height: 38px;
  }
  .ctrl-navigation .ctrl-btn {
    height: 42px;
  }
}
