html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-touch-callout: none;
}

/* ---------- Pixel-art thinking board (near head) ---------- */
#board {
  position: fixed;
  /* Placed over upper-right of the face area; JS can nudge via CSS vars if needed */
  top: 12%;
  left: 52%;
  max-width: min(58vw, 240px);
  z-index: 5;
  pointer-events: none;
  transform: translateX(-10%);
  opacity: 0;
  transition: opacity 0.45s ease;
}
#board.visible {
  opacity: 1;
}
#board[hidden] {
  display: none;
}

.board-inner {
  position: relative;
  background: rgba(8, 14, 12, 0.82);
  border: 2px solid rgba(160, 220, 170, 0.45);
  border-radius: 4px;
  padding: 10px 12px 11px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 0 12px rgba(100, 220, 140, 0.12),
    inset 0 0 0 1px rgba(180, 255, 190, 0.06);
  /* pixel corner accents */
  background-image:
    linear-gradient(rgba(140, 255, 160, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 255, 160, 0.05) 1px, transparent 1px);
  background-size: 6px 6px;
}

/* Thought-bubble tail pointing toward the head (bottom-left of board) */
.board-tail {
  position: absolute;
  left: 18px;
  bottom: -9px;
  width: 12px;
  height: 12px;
  background: rgba(8, 14, 12, 0.82);
  border-right: 2px solid rgba(160, 220, 170, 0.45);
  border-bottom: 2px solid rgba(160, 220, 170, 0.45);
  transform: rotate(45deg);
  box-shadow: 2px 2px 6px rgba(100, 220, 140, 0.08);
}

#message {
  margin: 0;
  text-align: center;
  font-family: "SF Mono", "Cascadia Code", "Consolas", "Courier New", monospace;
  font-size: clamp(12px, 3.4vw, 15px);
  line-height: 1.45;
  letter-spacing: 0.03em;
  color: #c8f0c8;
  text-shadow:
    0 0 5px rgba(140, 255, 160, 0.4),
    0 0 12px rgba(100, 220, 140, 0.14);
  white-space: pre-wrap;
  word-break: break-word;
  /* Native emoji rendering */
  font-variant-emoji: emoji;
}

#message.glitch {
  animation: textGlitch 0.28s steps(2, end) both;
  color: #e8ffe8;
}

@keyframes textGlitch {
  0%   { transform: translate(0, 0);     opacity: 1;    filter: none; }
  15%  { transform: translate(-2px, 1px); opacity: 0.8; filter: hue-rotate(50deg) saturate(1.5); }
  35%  { transform: translate(3px, -1px); opacity: 0.65; text-shadow: -2px 0 #f0a, 2px 0 #0ff; }
  55%  { transform: translate(-2px, 1px); opacity: 0.9;  filter: contrast(1.35); }
  75%  { transform: translate(2px, 0);    opacity: 0.75; text-shadow: 2px 0 #f0a, -2px 0 #0ff; }
  100% { transform: translate(0, 0);     opacity: 1;    filter: none;
         text-shadow: 0 0 5px rgba(140,255,160,0.4); }
}

/* Slightly lower board on very short screens so it stays near the head */
@media (max-height: 620px) {
  #board { top: 10%; max-width: min(62vw, 220px); }
}
@media (min-width: 480px) {
  #board { left: 54%; max-width: 260px; }
}

/* ---------- Controls ---------- */
#mute {
  position: fixed;
  left: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(160, 220, 170, 0.28);
  border-radius: 4px;
  color: #9ecf9e;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: border-color 0.2s, color 0.2s;
  /* pixel feel */
  image-rendering: pixelated;
}
#mute:hover, #mute:focus-visible {
  border-color: rgba(180, 255, 190, 0.55);
  color: #d0ffd0;
  outline: none;
}

#replay {
  position: fixed;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  padding: 14px;
  background: none;
  border: 0;
  color: #777;
  font: 13px system-ui, sans-serif;
  cursor: pointer;
  z-index: 6;
}
#replay:hover { color: #ddd; }
#replay:focus-visible { outline: 1px solid #aaa; }
#replay[hidden] { display: none; }
