:root {
  --bg-color: #0a0a0a;
  --panel-bg: #16161a;
  --accent-cyan: #00eaff;
  --accent-pink: #ff0055;
  --text-color: #e0e0e0;
  --gap: 4px;
  --board-max-width: 450px;
}

body {
  background-color: var(--bg-color);
  background-image: linear-gradient(
      rgba(18, 18, 18, 0.9),
      rgba(18, 18, 18, 0.9)
    ),
    linear-gradient(90deg, rgba(255, 0, 85, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(0, 234, 255, 0.05) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  color: var(--text-color);
  font-family: "Courier New", Courier, monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  user-select: none;
  overflow-x: hidden;
  padding-bottom: 40px; 
}

/* --- Retro Scanline Effect --- */
.scanline {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.1)
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 999;
  opacity: 0.3;
}

/* --- Typography --- */
header {
  text-align: center;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 10px;
}

.glitch-title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 2px 2px 0px var(--accent-pink);
  margin: 0;
  text-align: center;
  line-height: 1.1;
}

.subtitle {
  color: var(--accent-cyan);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-top: 5px;
  opacity: 0.8;
  text-align: center;
}

.logo-img {
  width: 70px; /* Adjust size as needed */
  height: auto;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 5px var(--accent-pink)); /* Adds a nice glow */
}

/* --- Layout --- */
.arcade-cabinet {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px; /* Limit overall width */
}

/* --- NEW TOP BAR STATS --- */
.top-bar {
  width: 100%;
  display: flex;
  justify-content: flex-end; /* Push to the right */
  margin-bottom: 10px;
  padding-right: 10px;
}

.stats-panel {
  display: flex;
  align-items: center;
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid var(--accent-cyan);
  border-radius: 20px; /* Pill shape */
  padding: 8px 20px;
  box-shadow: 0 0 15px rgba(0, 234, 255, 0.2);
  backdrop-filter: blur(5px);
}

.stat-item {
  font-size: 1rem;
  font-weight: bold;
  display: flex;
  gap: 8px;
}

.stat-separator {
  color: #555;
  margin: 0 15px;
  font-weight: normal;
}

.highlight {
  color: var(--accent-cyan);
  text-shadow: 0 0 5px rgba(0, 234, 255, 0.4);
}

/* --- Game Interface --- */
.game-interface {
  display: flex;
  gap: 25px;
  padding: 25px;
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid var(--accent-cyan);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 234, 255, 0.1), inset 0 0 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);

  justify-content: center;
  align-items: flex-start; /* Align top */
  width: 100%;
  box-sizing: border-box;
}

/* --- The Board --- */
.board-container {
  padding: 12px;
  background: #000;
  border: 2px solid #333;
  border-radius: 4px;
  box-shadow: inset 0 0 20px #000;
  flex: 0 0 auto; /* Prevent resizing */
}

.grid-4x4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);
  width: var(--board-max-width);
  height: var(--board-max-width);
}

/* --- Tiles --- */
.tile {
  width: 100%;
  height: 100%;
  background-color: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0;
  transition: transform 0.1s ease-out, background-position 0.2s ease-out;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

.tile:hover {
  filter: brightness(1.2);
  border-color: rgba(255, 255, 255, 0.5);
  z-index: 10;
}

.tile:active {
  transform: scale(0.98);
}

.empty-tile {
  background: transparent !important;
  border: 2px solid #ffffff;
  box-shadow: inset 0 0 20px #000;
  cursor: default;
}

/* --- Sidebar --- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 280px; /* Fixed width for side-by-side layout */
  flex-shrink: 0;
}

.panel-box {
  background: var(--panel-bg);
  padding: 15px;
  border-radius: 6px;
  border-left: 3px solid var(--accent-pink);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.panel-box h3 {
  margin: 0 0 12px 0;
  font-size: 0.85rem;
  color: #888;
  letter-spacing: 1px;
}

.reference-wrapper {
  margin-bottom: 15px;
}

.label-text {
  font-size: 0.7rem;
  color: #666;
  margin-bottom: 5px;
}

.image-cropper {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid #444;
}

.reference-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
  display: block;
}

.disclaimer-text {
  font-size: 0.75rem;
  color: var(--accent-pink);
  margin-top: 10px;
  opacity: 1;
  text-shadow: 0 0 2px rgba(255, 0, 85, 0.4);
  letter-spacing: 0.5px;
  font-weight: bold;
}

/* --- Buttons --- */
.arcade-btn {
  background: var(--accent-pink);
  color: white;
  border: none;
  padding: 15px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
  margin-top: auto;
  border-radius: 4px;
  box-shadow: 0 4px 0px #b3003b;
  width: 100%;
}

.arcade-btn:hover {
  background: #ff1a66;
  transform: translateY(-2px);
  box-shadow: 0 6px 0px #b3003b;
}

.arcade-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0px #b3003b;
}

.action-row {
  display: flex;
  gap: 10px;
}

.icon-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 10px;
  cursor: pointer;
  text-align: center;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: bold;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.icon-btn:hover {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 0 10px rgba(0, 234, 255, 0.4);
}

/* --- Modals --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.hidden {
  display: none !important;
}

.modal-content {
  background: var(--panel-bg);
  padding: 30px;
  border: 2px solid var(--accent-cyan);
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 0 50px rgba(0, 234, 255, 0.15);
  max-width: 90%;
}

/* Gallery Specifics */
.gallery-container {
  width: 90%;
  max-width: 650px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  border-color: var(--accent-pink);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  color: var(--accent-pink);
  font-size: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 10px;
}

.gallery-item {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  transition: transform 0.2s;
}

.gallery-item:hover {
  border-color: var(--accent-cyan);
  transform: scale(1.05);
}

.win-stats {
  margin: 20px 0;
  font-size: 1.5rem;
}

.win-content {
  max-width: 450px;
}

.main-win-btn {
  margin-bottom: 20px;
  width: 100%;
  font-size: 1.2rem;
}

.next-steps {
  margin-top: 15px;
  border-top: 1px solid #333;
  padding-top: 15px;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  margin-bottom: 15px;
  opacity: 0.8;
  letter-spacing: 2px;
}

.secondary-actions {
  display: flex;
  gap: 15px;
}

.neon-hover {
  padding: 12px;
  font-size: 0.9rem;
  background: rgba(0, 234, 255, 0.1); /* Slight background tint */
  transition: all 0.3s ease;
}

.neon-hover:hover {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 0 20px rgba(0, 234, 255, 0.6);
  transform: translateY(-3px);
}

/* --- IN style.css --- */

/* FOOTER STYLES */
.arcade-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 10px 0;
  background: rgba(10, 10, 10, 0.8); /* Semi-transparent black */
  border-top: 1px solid #333;
  font-size: 0.8rem;
  color: #888;
  z-index: 10; /* Ensure it sits above the scanlines */
  backdrop-filter: blur(5px);
}

.arcade-footer p {
  margin: 0;
}

.portfolio-link {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: bold;
  transition: all 0.2s ease;
  text-shadow: 0 0 2px rgba(0, 234, 255, 0.3);
}

.portfolio-link:hover {
  color: var(--accent-pink);
  text-shadow: 0 0 5px rgba(255, 0, 85, 0.6);
  letter-spacing: 1px; /* Cool little expansion effect on hover */
}

/* --- MEDIA QUERIES --- */

/* Tablets and below */
@media (max-width: 850px) {
  .top-bar {
    justify-content: center; /* Center stats on smaller screens */
    padding-right: 0;
  }

  .game-interface {
    flex-direction: column; /* Stack board and sidebar */
    align-items: center;
    padding: 15px;
    gap: 20px;
  }

  .board-container {
    /* Allow board to shrink on tablet */
    width: min(var(--board-max-width), 90vw);
    height: auto;
  }

  .grid-4x4 {
    width: 100%;
    aspect-ratio: 1/1;
    height: auto;
  }

  .sidebar {
    width: 100%; /* Full width sidebar when stacked */
    max-width: var(--board-max-width);
  }

  .action-row {
    flex-wrap: wrap;
  }
}

/* Small Phones */
@media (max-width: 480px) {
  .glitch-title {
    font-size: 2rem;
  }

  .stats-panel {
    padding: 6px 15px;
    font-size: 0.9rem;
  }

  .game-interface {
    padding: 10px;
    width: 100%;
    border-left: none;
    border-right: none;
    border-radius: 0;
    background: transparent; /* Cleaner look on very small screens */
    box-shadow: none;
  }

  .board-container {
    padding: 6px;
  }
}
/* @media (max-width: 400px) {
    .secondary-actions {
        flex-direction: column;
    }
} */


/* demo overlay styles -> new one for reference*/
.demo-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 10, 10, 0.9); /* Darker background for better contrast */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.demo-overlay.hidden {
    opacity: 0;
    visibility: hidden; /* Ensure it doesn't block clicks after hiding */
}

.demo-content {
    text-align: center;
    color: var(--text-color);
    background: rgba(22, 22, 26, 0.8);
    padding: 30px;
    border: 2px solid var(--accent-cyan);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 234, 255, 0.2);
}

.demo-content h2 {
    font-family: var(--font-heading);
    color: var(--accent-pink);
    margin-bottom: 25px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--accent-pink);
}

/* --- The Diagram Structure --- */
.instruction-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

/* Common box styles */
.diagram-box {
    width: 80px;
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 8px;
    position: relative;
}

/* 1. The Movable Tile Box */
.movable-piece {
    background: var(--panel-bg);
    border: 2px solid var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.4);
}

.hand-icon {
    font-size: 2rem;
    margin-bottom: 5px;
    color: var(--accent-pink);
    /* Subtle nudge animation */
    animation: nudgeRight 1.5s ease-in-out infinite;
}

/* 2. The Arrow */
.arrow-connector {
    font-size: 2.5rem;
    color: var(--text-color);
}

.bounce-arrow {
    /* Strong pointing animation */
    animation: strongBounceRight 1.5s ease-in-out infinite;
    color: var(--accent-pink);
}

/* 3. The Empty Target Box */
.empty-target {
    background: transparent;
    /* Dashed border makes it look like a "slot" */
    border: 3px dashed var(--accent-pink);
    color: var(--accent-pink);
    /* Glowing pulse to indicate it's the goal */
    animation: glowPulse 1.5s ease-in-out infinite alternate;
}

/* --- Text Styles --- */
.demo-text {
    font-size: 1.1rem;
    margin-bottom: 15px;
    max-width: 300px;
    line-height: 1.4;
}

.pulse-text {
    font-size: 0.9rem;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    font-weight: bold;
    animation: textPulse 1.5s ease-in-out infinite;
}

/* --- Keyframe Animations --- */

@keyframes nudgeRight {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}

@keyframes strongBounceRight {
    0%, 20%, 50%, 80%, 100% { transform: translateX(0); }
    40% { transform: translateX(-10px); }
    60% { transform: translateX(-5px); }
}

@keyframes glowPulse {
    from { box-shadow: inset 0 0 5px var(--accent-pink); }
    to { box-shadow: inset 0 0 20px var(--accent-pink); }
}

@keyframes textPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Ensure board container is relative for absolute overlay */
.board-container {
    position: relative;
}