/*  z-index on canvas is irelevant and the layering goes off the parent modals 
These can be referenced by ID or class */

/* SCANLINE LAYER */
#scanline-simulation-modal {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
}
/* GRILLE SCREEN LAYER */
#grille-screen-modal {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: transparent;
}
/* SYSTEM SCREEN LAYER */
#system-screen-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: transparent;
  z-index: 6;                           /* Layer  5  */
}
/* OPTIONS BAR LAYER */
.optionsBar {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background-color: black;
  color: white;
  z-index: 99;                          /* Layer  99  */
}
/* the actual OPTIONS modal window layer to change properties of grille, intensity etc. */
.scanlinesModal {
  display: none;
  position: fixed;
   z-index: 98;                         /* Layer  98   */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  background-color: #000;
  color: #fff;
  border-radius: 10px;
  border: 2px solid #ccc;
  padding: 20px;
  box-sizing: border-box;
}
/* BLACK UNDERLAY, UTMOST REAR, no canvas, just black backdrop modal */
.blackScreenModal {
  display: none;
  position: fixed;
  z-index: 0; /* random negative utmost rear z index */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: show;
  background-color: black;
}


/* all other styling, z index stuff put on top for layering */
.scanlineSimulationModal {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: show;
  background-color: transparent;
}

#scanline-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background-color: transparent;
}

.grilleScreenModal {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: show;
  background-color: transparent;
}

#grille-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.screenModal {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  background-color: rgba(0, 0, 0, 0.8);
}

#screen-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  filter: blur(0px);
}

.screenModal:hover .optionsBar {
  display: block;
}

.optionsBar li:hover {
  background-color: black;
  color: yellow;
  cursor: pointer;
}

.optionsBar ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.optionsBar li {
  float: left;
  padding: 10px;
}

.scanlinesModal label,
.scanlinesModal input[type=radio] {
  color: #fff;
}

.scanlinesModal input[type=range] {
  width: 100%;
  margin: 10px 0;
}

.scanlinesModal button {
  display: block;
  margin: 20px auto 0;
}

/* Tile view Modal */
.TileViewModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: auto;
}

.tileView-modal-box {
  background-color: #1a1a1a;         /* Deep CRT-style black */
  border: 2px solid #00ffcc;         /* Aqua green glow border */
  box-shadow: 0 0 12px #00ffcc88;    /* Soft glow effect */
  border-radius: 12px;
  padding: 16px;
  width: 640px;
  max-height: 480px;
  overflow: auto;
  font-family: 'Courier New', monospace;
  color: #00ffcc;
  
  margin: auto;
  top: 50%;

  text-align: center;
}

/* Modal box centered and properly sized */
.modal-box {
  background: #1e1e1e;
  color: white;
  width: 650px;
  max-width: 95vw;
  margin: 80px auto;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 0 20px #000;
}

/* Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.close-button {
  font-size: 24px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

/* Body */
.modal-body {
  margin-top: 20px;
}

.canvas-wrapper {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

/* Each canvas section */
.canvas-container {
  text-align: center;
  width: 256px;
}

.canvas-container h3 {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: normal;
}

canvas {
  display: block;
  width: 256px;
  height: 256px;
  background: #000;
  border: 2px solid #444;
  image-rendering: pixelated;
}


/* Palette modal overlay */
#palette-modal { 
  position: fixed; 
  inset: 0; 
  z-index: 9999; 
  font-family: inherit;
}

#palette-modal .palette-modal-backdrop {
  position: absolute; 
  inset: 0; 
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px); /* subtle background blur */
}

#palette-modal .palette-modal-box {
  position: absolute; 
  left: 50%; 
  top: 50%; 
  transform: translate(-50%, -50%);
  background: #111; 
  color: #eee; 
  border: 1px solid #444; 
  border-radius: 8px;
  width: 380px; 
  max-width: calc(100% - 24px); 
  max-height: 90vh; /* prevents overflowing the screen */
  box-shadow: 0 12px 28px rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
}

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

#palette-modal .palette-close {
  background: transparent; 
  border: none; 
  color: #aaa; 
  font-size: 22px; 
  cursor: pointer;
  transition: color 0.2s ease;
}
#palette-modal .palette-close:hover {
  color: #fff;
}

#palette-modal .palette-modal-body {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  overflow-y: auto;
}

#palette-modal .pal-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 14px;
  background: #1a1a1a;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  user-select: none;
}

#palette-modal .pal-opt:hover {
  background: #262626;
  transform: translateY(-1px);
}

#palette-modal .pal-opt input {
  accent-color: #4da3ff; 
}

#palette-modal .palette-modal-footer {
  display: flex; 
  gap: 8px; 
  justify-content: flex-end;
  padding: 10px 12px; 
  border-top: 1px solid #333;
}

#palette-modal .palette-modal-footer button {
  background: #222; 
  color: #eee; 
  border: 1px solid #555; 
  padding: 6px 12px; 
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
#palette-modal .palette-modal-footer button:hover { 
  background: #2e2e2e; 
  border-color: #888; 
}
