/* static/style.css */

/* Core Color Tokens & Reset */
:root {
  --bg-dark: #0b0e14;
  --bg-panel: rgba(17, 22, 32, 0.8);
  --grid-line: #181e29;

  --neon-cyan: #00f0ff;
  --neon-cyan-glow: rgba(0, 240, 255, 0.4);
  --neon-pink: #ff007f;
  --neon-pink-glow: rgba(255, 0, 127, 0.4);
  --neon-purple: #9d00ff;
  --neon-red: #ff3232;
  --neon-gold: #ffb700;

  --font-cyber: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--bg-dark);
  color: #ffffff;
  font-family: var(--font-mono);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100vw;
}

/* App Main Grid Container */
#app-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 950px;
  height: 100dvh;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 15px calc(15px + env(safe-area-inset-bottom, 0px)) 15px;
}

/* Header & Title Glitch Effect */
.cyber-header {
  text-align: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.glitch-title {
  font-family: var(--font-cyber);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 10px var(--neon-cyan-glow);
  position: relative;
}

/* Game Playing Workspace */
.game-workspace {
  display: grid;
  grid-template-areas:
    "hold board next"
    "controls board stats";
  grid-template-columns: 180px 300px 180px;
  grid-template-rows: auto 1fr;
  gap: 20px;
  justify-content: center;
  align-items: start;
  flex-grow: 1;
  width: 100%;
}

.hold-box { grid-area: hold; }
.desktop-controls { grid-area: controls; }
.center-board { grid-area: board; }
.next-box { grid-area: next; }
.stats-box { grid-area: stats; }

.panel-box {
  background: var(--bg-panel);
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 15px var(--neon-cyan-glow);
  border-radius: 6px;
  padding: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
}

.panel-label {
  font-family: var(--font-cyber);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* Hold and Next Canvas Slots */
#hold-canvas, #next-canvas {
  background: rgba(8, 10, 15, 0.6);
  border-radius: 4px;
}

.panel-hotkey {
  font-size: 0.7rem;
  color: #566a7e;
  margin-top: 5px;
}

/* Desktop Controls display */
.desktop-controls ul {
  list-style: none;
  text-align: left;
  font-size: 0.8rem;
}

.desktop-controls li {
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.desktop-controls li span {
  color: var(--neon-pink);
}

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

.stat-entry {
  text-align: left;
  border-bottom: 1px solid rgba(0, 240, 255, 0.1);
  padding-bottom: 5px;
}

.stat-label {
  font-size: 0.75rem;
  color: #7d9cb3;
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-cyber);
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
}

/* Specific text color states */
.text-gold { color: var(--neon-gold); }
.text-cyan { color: var(--neon-cyan); }

/* Center Active Playfield Canvas */
.center-board {
  display: flex;
  justify-content: center;
  align-items: center;
}

.canvas-wrapper {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--neon-pink);
  box-shadow: 0 0 15px var(--neon-pink-glow);
}

#game-canvas {
  background: rgba(8, 10, 15, 0.95);
  display: block;
}

/* Screen overlays (Menus, Game over, Pauses) */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 15, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
  text-align: center;
  padding: 20px;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.neon-pink-text {
  font-family: var(--font-cyber);
  color: var(--neon-pink);
  text-shadow: 0 0 10px var(--neon-pink-glow);
  font-size: 1.5rem;
  letter-spacing: 1px;
}

.neon-red-text {
  font-family: var(--font-cyber);
  color: var(--neon-red);
  text-shadow: 0 0 10px rgba(255, 50, 50, 0.4);
  font-size: 1.5rem;
  letter-spacing: 1px;
}

.neon-cyan-text {
  font-family: var(--font-cyber);
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan-glow);
  font-size: 1.4rem;
  letter-spacing: 1px;
}

.blink-text {
  animation: flash 1s infinite;
  color: #fff;
  font-size: 0.9rem;
}

.pulse-text {
  animation: pulse 1.5s infinite alternate;
  color: #a0b6c7;
  font-size: 0.85rem;
}

/* Cyber Button Styling */
.cyber-btn {
  background: transparent;
  color: var(--neon-cyan);
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan-glow);
  font-family: var(--font-cyber);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.cyber-btn:hover, .cyber-btn:active {
  background: var(--neon-cyan);
  color: var(--bg-dark);
  box-shadow: 0 0 20px var(--neon-cyan);
}

.cyber-btn.danger-btn {
  color: var(--neon-red);
  border-color: var(--neon-red);
  box-shadow: 0 0 10px rgba(255, 50, 50, 0.3);
}

.cyber-btn.danger-btn:hover, .cyber-btn.danger-btn:active {
  background: var(--neon-red);
  color: #0b0e14;
  box-shadow: 0 0 20px rgba(255, 50, 50, 0.55);
}

.cyber-btn.ghost-btn {
  color: #a0b6c7;
  border-color: #607286;
  box-shadow: 0 0 10px rgba(96, 114, 134, 0.25);
}

.cyber-btn.ghost-btn:hover, .cyber-btn.ghost-btn:active {
  background: #607286;
  color: #0b0e14;
  box-shadow: 0 0 20px rgba(96, 114, 134, 0.45);
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 13, 0.82);
  z-index: 40;
  padding: 20px;
}

.confirm-dialog.active {
  display: flex;
}

.confirm-panel {
  width: min(420px, 100%);
  background: rgba(17, 22, 32, 0.98);
  border: 2px solid var(--neon-red);
  border-radius: 6px;
  box-shadow: 0 0 28px rgba(255, 50, 50, 0.25);
  padding: 22px 20px 18px;
  text-align: center;
}

.confirm-panel p {
  margin-top: 10px;
  color: #d3dce6;
  font-size: 0.95rem;
  line-height: 1.4;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

/* Virtual Touch Gamepad (Nintendo Design System) */
.gamepad-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
}

.nintendo-body {
  background: #2b2e32;
  border: 4px solid #1a1c1e;
  border-radius: 20px;
  box-shadow:
    0 10px 0 #121314,
    0 20px 20px rgba(0, 0, 0, 0.6),
    inset 0 2px 5px rgba(255, 255, 255, 0.1);
  width: 100%;
  max-width: 600px;
  padding: 20px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Glowing Neon Lines on Gamepad Body */
.nintendo-body::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 20px;
  right: 20px;
  height: 4px;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan), var(--neon-pink));
  opacity: 0.8;
  border-radius: 2px;
}

/* Nintendo D-Pad Cross */
.dpad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dpad-cross {
  width: 110px;
  height: 110px;
  position: relative;
}

.dpad-center {
  position: absolute;
  top: 36px;
  left: 36px;
  width: 38px;
  height: 38px;
  background: #111112;
  z-index: 2;
}

.dpad-button {
  position: absolute;
  background: #111112;
  border: 1px solid #000;
  color: #444;
  font-size: 0.75rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.dpad-button:active {
  background: #000000;
  color: var(--neon-cyan);
  text-shadow: 0 0 5px var(--neon-cyan);
  box-shadow: inset 0 2px 5px rgba(0, 240, 255, 0.3);
}

.dpad-up {
  top: 0;
  left: 36px;
  width: 38px;
  height: 38px;
  border-radius: 4px 4px 0 0;
}

.dpad-left {
  top: 36px;
  left: 0;
  width: 38px;
  height: 38px;
  border-radius: 4px 0 0 4px;
}

.dpad-right {
  top: 36px;
  right: 0;
  width: 38px;
  height: 38px;
  border-radius: 0 4px 4px 0;
}

.dpad-down {
  bottom: 0;
  left: 36px;
  width: 38px;
  height: 38px;
  border-radius: 0 0 4px 4px;
}

.dpad-label, .action-sub-label, .system-label {
  font-family: var(--font-cyber);
  font-size: 0.6rem;
  font-weight: 700;
  color: #727e8a;
  letter-spacing: 1px;
}

/* System Center Pills (Start/Select) */
.system-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.pills-container {
  display: flex;
  gap: 25px;
}

.pill-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.system-pill {
  width: 50px;
  height: 14px;
  background: #111112;
  border: 1px solid #000;
  border-radius: 7px;
  cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.05);
}

.system-pill:active {
  background: #000000;
  box-shadow: inset 0 2px 5px rgba(255, 0, 127, 0.3);
}

.brand-text {
  font-family: var(--font-cyber);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
  opacity: 0.3;
}

/* Action Buttons (A & B) */
.action-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.action-pair {
  display: flex;
  gap: 18px;
  background: #1a1c1e;
  border-radius: 35px;
  padding: 10px 15px;
  transform: rotate(-12deg); /* Classic retro tilted button slot! */
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.btn-cap-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.action-round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #111;
  color: #ffffff;
  font-family: var(--font-cyber);
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow:
    0 4px 0 #7b0000,
    inset 0 1px 3px rgba(255,255,255,0.2);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.action-b {
  background: #a30000; /* Retro dark red */
}

.action-a {
  background: #a30000;
}

.action-round:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #500000,
    0 0 10px rgba(255, 50, 50, 0.4);
}

.action-label {
  font-family: var(--font-cyber);
  font-size: 0.55rem;
  font-weight: 700;
  color: #727e8a;
}

/* Animations */
@keyframes flash {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

@keyframes pulse {
  0% { transform: scale(0.98); opacity: 0.7; }
  100% { transform: scale(1.02); opacity: 1; }
}

/* ======================================================= */
/* RESPONSIVE DESIGN - LAPTOP/DESKTOP STYLING              */
/* ======================================================= */
@media (min-width: 1025px) {
  /* Hide the touch gamepad on wide screens as keyboard is active */
  #nintendo-gamepad {
    display: none;
  }
}

/* ======================================================= */
/* RESPONSIVE DESIGN - TABLET/IPAD STYLING                 */
/* ======================================================= */
@media (max-width: 1024px) {
  #app-container {
    padding: 10px;
    height: 100dvh;
  }

  .game-workspace {
    grid-template-areas:
      "hold board next"
      "stats board stats";
    grid-template-columns: 140px 250px 140px;
    grid-template-rows: auto 1fr;
    gap: 15px;
    justify-content: center;
    align-items: start;
  }

  .desktop-controls {
    display: none !important;
  }

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

  .panel-box {
    padding: 10px;
  }

  /* Scales down canvas layout slightly if needed */
  #game-canvas {
    width: 250px;
    height: 500px;
  }
}

/* ======================================================= */
/* RESPONSIVE DESIGN - MOBILE DEVICE STYLING               */
/* ======================================================= */
@media (max-width: 600px) {
  #app-container {
    padding: env(safe-area-inset-top, 10px) 5px env(safe-area-inset-bottom, 5px) 5px;
    justify-content: flex-start;
    gap: 8px;
    height: 100dvh;
  }

  .glitch-title {
    font-size: 1.4rem;
    letter-spacing: 2px;
  }

  .cyber-header {
    margin-bottom: 5px;
  }

  .game-workspace {
    grid-template-areas:
      "hold next"
      "board board"
      "stats stats";
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 8px;
    width: 100%;
    align-items: center;
  }

  .desktop-controls {
    display: none !important;
  }

  .panel-box {
    padding: 8px 12px;
  }

  .hold-box, .next-box {
    max-height: 55px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }

  .hold-box canvas, .next-box canvas {
    width: 40px;
    height: 40px;
  }

  .hold-box .panel-label, .next-box .panel-label {
    margin-bottom: 0;
    font-size: 0.75rem;
  }

  .panel-hotkey {
    display: none;
  }

  /* Combine or compress stats for mobile */
  .stats-box {
    grid-area: stats;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 8px;
    gap: 5px;
  }

  .stat-entry {
    border-bottom: none;
    padding-bottom: 0;
    text-align: center;
    flex: 1;
  }

  .stat-label {
    font-size: 0.6rem;
    margin-bottom: 0;
    color: #7d9cb3;
  }

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

  /* Play Board scales down gracefully on phone screens */
  #game-canvas {
    width: 200px;
    height: 400px;
  }

  .nintendo-body {
    padding: 12px;
    border-radius: 12px;
  }

  .dpad-cross {
    width: 85px;
    height: 85px;
  }

  .dpad-center {
    top: 28px;
    left: 28px;
    width: 29px;
    height: 29px;
  }

  .dpad-up { top: 0; left: 28px; width: 29px; height: 29px; }
  .dpad-left { top: 28px; left: 0; width: 29px; height: 29px; }
  .dpad-right { top: 28px; right: 0; width: 29px; height: 29px; }
  .dpad-down { bottom: 0; left: 28px; width: 29px; height: 29px; }

  .action-pair {
    gap: 10px;
    padding: 6px 12px;
  }

  .action-round {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    box-shadow: 0 2px 0 #7b0000;
  }

  .system-pill {
    width: 40px;
    height: 12px;
  }
}
