/* style.css: everything around the game (the game itself is drawn by draw.js) */

:root {
  --ink: #2b1d3a;        /* the dark "ink" color used for every outline */
  --paper: #fffdf6;
  --pink: #ff5a8f;
  --yellow: #ffe14d;
}

body {
  margin: 0;
  overflow: hidden;          /* no scroll bars */
  background: #000;
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;   /* no long-press menu on phones */
  touch-action: none;            /* no pinch zoom or scrolling while playing */
  overscroll-behavior: none;
}

/* Elements with the "hidden" attribute are always hidden */
[hidden] { display: none !important; }

/* Instructions: show the keyboard ones or the touch ones, depending on the device */
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-only { display: revert; }
  .key-only { display: none; }
}

/* The canvas fills the whole window */
canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;                /* the part a phone's address bar doesn't cover */
}

/* ===== Score (comic lettering with an ink outline) ===== */
.hud {
  position: fixed;
  top: 14px;
  left: 18px;
  font-family: "Bangers", Impact, sans-serif;
  letter-spacing: 2px;
  pointer-events: none;
}
#height {
  font-size: 3rem;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
}
#best {
  font-size: 1.4rem;
  color: var(--yellow);
  -webkit-text-stroke: 1px var(--ink);
  text-shadow: 2px 2px 0 var(--ink);
}

/* In the horror zone (800 m+) the score turns red. JavaScript adds the "horror" class. */
body.horror #height {
  color: #ff2a3a;
  text-shadow: 3px 3px 0 var(--ink), 0 0 18px rgba(255, 0, 0, .8);
}

/* ===== The message box, styled like a manga panel ===== */
.overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-1.5deg);
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  touch-action: pan-y;           /* a long leaderboard can still scroll on a phone */
  box-sizing: border-box;
  padding: 26px 28px;
  text-align: center;
  background-color: var(--paper);
  /* Tiny dots = "screentone", the dot shading used in manga */
  background-image: radial-gradient(rgba(43, 29, 58, .12) 1.2px, transparent 1.7px);
  background-size: 9px 9px;
  border: 4px solid var(--ink);
  border-radius: 6px;
  box-shadow: 8px 8px 0 var(--ink);
}
.overlay.hidden { display: none; }

.overlay h1 {
  margin: 0 0 6px;
  font-family: "Bangers", Impact, sans-serif;
  font-weight: normal;
  font-size: 3.6rem;
  letter-spacing: 3px;
  color: var(--pink);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
}
.overlay h2 {
  margin: 18px 0 8px;
  font-family: "Bangers", Impact, sans-serif;
  font-weight: normal;
  font-size: 1.8rem;
  letter-spacing: 2px;
}
.overlay p { line-height: 1.5; margin: 8px 0; }

kbd {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: inherit;
  font-weight: 800;
}

/* Gently pulse the "Press Space" line */
.start { font-weight: 800; margin-top: 16px !important; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  50% { opacity: .35; }
}
.warning { font-size: .8rem; opacity: .7; margin-top: 12px !important; }

.practice-note { font-size: .85rem; font-weight: 800; color: #b0003a; }

/* ===== Secret menu (dark and spooky instead of manga paper) ===== */
.overlay.secret {
  z-index: 20;                       /* on top of the start / game over box */
  color: #ffd9dd;
  background-color: #12000a;
  /* thin horizontal lines, like an old TV screen */
  background-image: repeating-linear-gradient(rgba(255, 0, 40, .08) 0 2px, transparent 2px 4px);
  background-size: auto;
  border-color: #ff1f3d;
  box-shadow: 8px 8px 0 #ff1f3d, 0 0 40px rgba(255, 0, 40, .5);
  transform: translate(-50%, -50%) rotate(1deg);
}
.overlay.secret h1 {
  font-family: "Nosifer", Impact, sans-serif;
  font-size: 2.2rem;
  letter-spacing: 1px;
  color: #ff1f3d;
  -webkit-text-stroke: 0;
  text-shadow: 3px 3px 0 #000, 0 0 16px rgba(255, 0, 40, .8);
}
.scene-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.scene-list button {
  width: 100%;
  padding: 12px;
  font-family: "Nosifer", Impact, sans-serif;
  font-size: 1.3rem;
  letter-spacing: 1px;
  color: #fff;
  background: #3a0010;
  border: 3px solid #ff1f3d;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.scene-list button:hover { background: #ff1f3d; transform: scale(1.03); }
.scene-list kbd { font-family: "Nunito", sans-serif; font-size: 1rem; vertical-align: middle; color: var(--ink); }
.secret-note { font-size: .85rem; opacity: .7; }
.close-secret {
  margin-top: 6px;
  padding: 6px 14px;
  font: inherit;
  font-weight: 800;
  color: #ffd9dd;
  background: transparent;
  border: 2px solid rgba(255, 217, 221, .5);
  border-radius: 6px;
  cursor: pointer;
}

/* ===== Name entry ===== */
.name-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 4px;
  padding: 12px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 8px;
  font-weight: 800;
}
.name-row { display: flex; gap: 8px; }
.name-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  border: 3px solid var(--ink);
  border-radius: 6px;
  outline: none;
}
.name-form button {
  padding: 8px 16px;
  font: inherit;
  background: var(--pink);
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.name-form button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.name-form small { font-weight: 600; opacity: .7; }

/* ===== Leaderboard list ===== */
.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  text-align: left;
}
.leaderboard li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  padding: 5px 12px;
  font-weight: 600;
}
.leaderboard li:nth-child(even) { background: #f4eefc; }
.leaderboard li + li { border-top: 1px dashed rgba(43, 29, 58, .25); }
.leaderboard .rank { font-weight: 800; }
.leaderboard .score { font-weight: 800; }
.leaderboard li:nth-child(1) .rank { color: #e0a800; }
.leaderboard li.empty { display: block; text-align: center; opacity: .6; }

/* The score you just saved flashes */
.leaderboard li.mine {
  background: var(--yellow);
  animation: flash .6s ease-in-out 4;
}
@keyframes flash {
  50% { background: #fff; }
}
