/* Memory Lights 6 - the look of the page.
   Sizes use vmin (1% of the smaller side of the window), so everything
   grows and shrinks with the window, like the C# version. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: white;
  font-family: "Segoe UI", Arial, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* The background color comes from --bg, set by the color buttons (game.js).
   It fades from a little lighter at the top to much darker at the bottom. */
body {
  --bg: #121834;
  background: linear-gradient(color-mix(in srgb, var(--bg) 92%, white),
                              color-mix(in srgb, var(--bg) 35%, black));
  display: flex;
  transition: background 0.4s;
}

#game {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2vmin;
}

/* ---------------- Version 4: the panel on the left ---------------- */
#sidePanel {
  width: 69vmin;          /* version 5: wider, to fit the Instructions button beside the colors */
  flex-shrink: 0;
  padding: 3vmin 2.5vmin;
  display: flex;
  flex-direction: column;
  gap: 1.6vmin;
}

/* Version 5: the color panel with the Instructions button to its right */
#colorRow {
  display: flex;
  gap: 1.6vmin;
  align-items: flex-start;
}
#colorRow #colorPanel { width: 35vmin; flex-shrink: 0; }
#instructionsButton {
  --face: #2860b8;
  width: 28vmin;          /* twice as wide, so the word fits */
  height: 12vmin;
  font-size: 2.6vmin;
}
#instructionsButton.open { --face: #6a3fb0; }

/* Version 6: the Instructions and Musical version buttons, one under the other */
#rightButtons { display: flex; flex-direction: column; gap: 1.6vmin; }
#musicalButton {
  --face: #b0602a;
  width: 28vmin;
  height: 12vmin;
  font-size: 2.6vmin;
}
#musicalButton.on { --face: #c9a227; color: #1a1300; text-shadow: none; }

/* The comments and close buttons line up under the color panel */
#commentsButton, #closeButton { width: 35vmin; }

/* A panel with a dark see-through backing and a border, used around the
   color buttons and around the game squares. */
.framePanel {
  background: rgba(0, 0, 0, 0.38);
  border: 0.5vmin solid rgba(255, 220, 120, 0.55);
  border-radius: 2vmin;
  box-shadow: 0 0 2vmin rgba(0, 0, 0, 0.5), inset 0 0 1.5vmin rgba(0, 0, 0, 0.4);
}

#colorPanel {
  padding: 1.6vmin;
  display: flex;
  flex-direction: column;
  gap: 1.6vmin;
}

#gridPanel {
  padding: 4.5vmin;   /* version 5: a wider margin around the squares (was 3vmin) */
}

/* ---------------- Version 5: the scrolling instructions ---------------- */
#instructionsPanel {
  position: fixed;
  top: 9vh;
  left: calc(69vmin + (100vw - 69vmin) / 2);   /* centered over the game, right of the side panel */
  transform: translateX(-50%);
  width: min(78vmin, calc(100vw - 74vmin));
  height: 82vh;
  display: flex;
  flex-direction: column;
  background: rgba(8, 14, 35, 0.97);
  border-color: rgba(120, 190, 255, 0.85);
  z-index: 10;
}
#instructionsPanel[hidden] { display: none; }

#instructionsTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.6vmin 2vmin;
  border-bottom: 2px solid rgba(120, 190, 255, 0.4);
  color: #ffdc78;
  font-size: 2.8vmin;
  font-weight: bold;
}
#instructionsClose { --face: #b03030; width: 14vmin; height: 6vmin; font-size: 2.3vmin; }

#instructionsText {
  flex: 1;
  overflow-y: auto;            /* the text scrolls */
  padding: 1vmin 3vmin 3vmin;
  font-size: 2.3vmin;
  line-height: 1.5;
  color: #e6ecff;
  user-select: text;
}
#instructionsText h2 { color: #78beff; font-size: 2.8vmin; margin: 2.4vmin 0 0.6vmin; }
#instructionsText b { color: #ffe9a8; }
#instructionsText .endNote { color: #a0aac8; font-style: italic; margin-top: 3vmin; }
#instructionsText::-webkit-scrollbar { width: 1.6vmin; }
#instructionsText::-webkit-scrollbar-thumb { background: #4a78c0; border-radius: 1vmin; }

#messageBar {
  padding: 1.4vmin 1.2vmin;
  border-radius: 1.2vmin;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 220, 120, 0.7);
  color: #ffdc78;
  font-size: 2.8vmin;
  font-weight: bold;
  text-align: center;
}

#colorButtons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));   /* three equal columns that never spill out */
  gap: 1.6vmin;
}

/* A raised 3D button: light edges on top and left, dark on bottom and right,
   a shadow underneath; it sinks in while pressed. --face is its color. */
.button3d {
  --face: #8a8f9c;
  position: relative;
  border: 0.55vmin solid;
  border-color: color-mix(in srgb, var(--face) 45%, white)
                color-mix(in srgb, var(--face) 45%, black)
                color-mix(in srgb, var(--face) 35%, black)
                color-mix(in srgb, var(--face) 55%, white);
  border-radius: 1vmin;
  background: linear-gradient(color-mix(in srgb, var(--face) 80%, white), var(--face) 55%,
                              color-mix(in srgb, var(--face) 80%, black));
  box-shadow: 0.4vmin 0.6vmin 0.8vmin rgba(0, 0, 0, 0.6);
  color: white;
  text-shadow: 0 0.2vmin 0.3vmin rgba(0, 0, 0, 0.8);
  font: bold 1.9vmin "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}
.button3d:active {
  transform: translate(0.3vmin, 0.4vmin);
  box-shadow: 0.1vmin 0.1vmin 0.3vmin rgba(0, 0, 0, 0.6);
  border-color: color-mix(in srgb, var(--face) 45%, black)
                color-mix(in srgb, var(--face) 45%, white)
                color-mix(in srgb, var(--face) 55%, white)
                color-mix(in srgb, var(--face) 35%, black);
}

.colorButton {
  width: 100%;
  min-width: 0;
  height: 10.5vmin;
  line-height: 1.15;
  padding: 0 0.4vmin;
  font-size: 2.1vmin;
}
/* The color now in use gets a yellow ring and a check mark */
.colorButton.chosen {
  outline: 0.6vmin solid #ffe128;
  outline-offset: 0.35vmin;
}
.colorButton.chosen::after {
  content: "\2713";
  position: absolute;
  right: 0.5vmin;
  top: 0.1vmin;
  font-size: 2.2vmin;
  color: #ffe128;
}

#commentsButton { --face: #2e7d4f; height: 8.5vmin; margin-top: 1.6vmin; font-size: 2.8vmin; }
#commentsButton.off { --face: #8a5a2a; }
#closeButton { --face: #b03030; height: 8.5vmin; font-size: 2.8vmin; }

#closeNote {
  font-size: 1.8vmin;
  color: #ffdc78;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 5.6vmin;
  color: #ffdc78;
  letter-spacing: 0.08em;
}

#info {
  margin-top: 1.2vmin;
  font-size: 3vmin;
  font-weight: bold;
  color: #b4c8ff;
  display: flex;
  gap: 5vmin;
}

#status {
  margin: 2.2vmin 0 2.4vmin;
  font-size: 3.6vmin;
  font-weight: bold;
  min-height: 5vmin;
  text-align: center;
}
#status.good { color: #78e68c; }
#status.bad  { color: #ff786e; }

/* --- The 3 x 3 grid --- */
#grid {
  --size: min(calc((100vw - 69vmin) * 0.92 - 10vmin), calc(100vh - 57vmin));   /* 69vmin = the side panel; 10vmin = the grid's own panel */
  width: var(--size);
  height: var(--size);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(var(--size) * 0.04);
}

.square {
  --color: white;
  position: relative;
  border-radius: 12%;
  border: max(2px, 0.4vmin) solid color-mix(in srgb, var(--color) 70%, black);
  /* Unlit: a dark version of the square's color */
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--color) 32%, #141828),
              color-mix(in srgb, var(--color) 20%, #0a0c14));
  transition: background 0.12s, box-shadow 0.12s;
  cursor: pointer;
}

.square .number {
  position: absolute;
  left: 8%;
  top: 4%;
  font-size: 3vmin;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.5);
}

/* Lit: bright face and a soft colored halo */
.square.lit {
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--color) 80%, white),
              var(--color));
  box-shadow: 0 0 2vmin 1vmin color-mix(in srgb, var(--color) 60%, transparent),
              0 0 6vmin 2vmin color-mix(in srgb, var(--color) 35%, transparent);
}
.square.lit .number { color: rgba(0, 0, 0, 0.7); }

/* The yellow frame, gently pulsing */
.square.framed {
  outline: max(4px, 1vmin) solid #ffe128;
  outline-offset: max(3px, 0.8vmin);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  50% { outline-color: rgba(255, 225, 40, 0.55); }
}

/* GAME OVER: a red X on the wrong square */
.square.wrong::after {
  content: "\2715";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14vmin;
  color: rgba(255, 60, 60, 0.9);
}

/* --- START / PLAY AGAIN --- */
#startButton {
  margin-top: 2.5vmin;
  width: 26vmin;
  height: 8vmin;
  border-radius: 2.4vmin;
  border: 2px solid #c8ffc8;
  background: linear-gradient(#50d264, #1e8c3c);
  color: white;
  font: bold 3vmin "Segoe UI", Arial, sans-serif;
  box-shadow: 0.4vmin 0.5vmin 0 rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
#startButton.hidden { visibility: hidden; }

#help {
  margin-top: 2.6vmin;
  font-size: 1.9vmin;
  color: #a0aac8;
  text-align: center;
  line-height: 1.55;
}
