  * { box-sizing: border-box; margin: 0; padding: 0; }
  .hidden { display: none !important; }

  @keyframes blinker { 50% { opacity: 0; } }
  @keyframes rainbowText {
    0%   { color:#ff0000; }
    16%  { color:#ff9900; }
    33%  { color:#ffff00; }
    50%  { color:#33ff00; }
    66%  { color:#00ccff; }
    83%  { color:#cc00ff; }
    100% { color:#ff0000; }
  }
  @keyframes constructionStripes {
    from { background-position: 0 0; }
    to   { background-position: 40px 0; }
  }

  html, body { height: 100%; }

  body {
    /* Classic tiled "starfield" wallpaper, straight out of a late-90s
       personal homepage. */
    background-color: #000033;
    background-image:
      radial-gradient(circle at 10% 20%, rgba(255,255,255,.9) 0 1px, transparent 1px),
      radial-gradient(circle at 80% 40%, rgba(255,255,255,.7) 0 1px, transparent 1px),
      radial-gradient(circle at 40% 70%, rgba(255,255,255,.8) 0 1px, transparent 1px),
      radial-gradient(circle at 60% 85%, rgba(255,255,255,.6) 0 1px, transparent 1px),
      radial-gradient(circle at 90% 90%, rgba(255,255,255,.9) 0 1px, transparent 1px),
      radial-gradient(circle at 25% 45%, rgba(255,255,255,.5) 0 1px, transparent 1px),
      linear-gradient(180deg, #1a0040 0%, #000033 60%, #000000 100%);
    background-size: 140px 140px, 160px 160px, 130px 130px, 170px 170px, 150px 150px, 120px 120px, cover;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    font-family: 'Comic Sans MS', 'Chicago', 'Trebuchet MS', cursive, sans-serif;
    gap: 14px;
    padding: 0 0 28px;
  }

  /* ── Top marquee banner (pure 90s homepage staple) ── */
  #marquee-banner {
    width: 100%;
    background: #000080;
    border-bottom: 3px double #ffff00;
    color: #ffff00;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 0.85rem;
    letter-spacing: 1px;
    padding: 5px 0;
  }

  #main-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
  }

  /* ── Site header: logo + title, right at the top of the page ── */
  #site-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: linear-gradient(180deg, #0000a8, #000050);
    border-bottom: 3px double #ffff00;
    padding: 10px 18px;
    width: 100%;
  }
  #site-logo {
    height: 48px;
    width: 48px;
    image-rendering: pixelated;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    background: #000000;
  }
  #site-logo-fallback {
    display: none;
    height: 48px;
    width: 48px;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: #000000;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
  }
  #site-title {
    color: #ffff00;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 1.5rem;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #ff0000, -1px -1px 0 #00ccff;
    animation: rainbowText 4s linear infinite;
  }

  /* ── Left panel ── */
  #left-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  .panel-title {
    color: #ffff00;
    background: #000080;
    font-size: 0.6rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 8px;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .divider {
    height: 3px;
    margin: 4px 0;
    border: none;
    background: repeating-linear-gradient(90deg,
      #ff0000 0 8px, #ff9900 8px 16px, #ffff00 16px 24px,
      #33cc33 24px 32px, #3366ff 32px 40px, #9933ff 40px 48px);
  }

  /* Windows-95-style raised "3D" panel, shared by every config box */
  #config-box, #color-box, #speed-box, #apple-box, #sound-box, #stats-box {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf;
    border-radius: 0;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
  }
  .config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.62rem;
    color: #000080;
    font-weight: bold;
  }
  .config-row input[type="number"] {
    width: 60px;
    background: #ffffff;
    border: 2px solid;
    border-color: #404040 #ffffff #ffffff #404040;
    border-radius: 0;
    color: #000000;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    padding: 4px 6px;
    text-align: center;
  }
  .config-row input[type="number"]:focus {
    outline: 1px dotted #000080;
    border-color: #404040 #ffffff #ffffff #404040;
  }
  .config-hint {
    font-size: 0.52rem;
    color: #000000;
    line-height: 1.4;
    font-family: 'Courier New', monospace;
  }

  /* ── Snake & background colors ── */
  .config-row input[type="color"] {
    width: 42px;
    height: 22px;
    background: none;
    border: 2px solid;
    border-color: #404040 #ffffff #ffffff #404040;
    border-radius: 0;
    padding: 0;
    cursor: pointer;
  }
  .config-row input[type="color"]:focus { outline: 1px dotted #000080; }
  .subtitle-mini {
    font-size: 0.52rem;
    color: #800080;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
  }

  /* ── Speed ── */
  .config-row input[type="range"] {
    flex: 1;
    accent-color: #ff00ff;
    cursor: pointer;
  }
  #speed-value {
    color: #000080;
    font-weight: bold;
    min-width: 26px;
    text-align: right;
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
  }

  /* ── Apple image (drag & drop) ── */
  #apple-drop-zone {
    border: 2px dashed #000080;
    background: #ffffff;
    padding: 14px 8px;
    text-align: center;
    font-size: 0.58rem;
    color: #000080;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
  }
  #apple-drop-zone:hover { border-color: #ff00ff; background: #fffbe0; }
  #apple-drop-zone.dragover { border-color: #ff0000; background: #ffe0e0; }
  #apple-preview {
    max-width: 100%;
    max-height: 48px;
    image-rendering: pixelated;
    display: none;
  }
  .reset-btn {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    border-radius: 0;
    color: #000000;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 0.6rem;
    padding: 6px 10px;
    cursor: pointer;
  }
  .reset-btn:hover { background: #dcdcdc; }
  .reset-btn:active {
    border-color: #404040 #ffffff #ffffff #404040;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,.4);
  }

  /* ── Sound section + gear icon ── */
  .gear-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #000080;
    transition: transform .3s;
    line-height: 1;
  }
  .gear-btn:hover { transform: rotate(45deg); }

  /* ── Stats ── */
  #stats-box {
    font-size: 0.62rem;
    color: #000080;
    font-family: 'Courier New', monospace;
    line-height: 2;
    font-weight: bold;
  }
  #stats-box span { color: #cc0000; }

  /* ── Center (game) ── */
  #center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
  }
  #score-display {
    background: #000080;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    padding: 4px 14px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 1.1rem;
    letter-spacing: 2px;
    animation: rainbowText 4s linear infinite;
  }

  /* Container put into fullscreen via the Fullscreen API: groups the
     game board AND the chart, so the chart stays visible (moved to the
     side) once in fullscreen. */
  #game-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  #game-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  /* Toolbar above the board: holds the "stop on complete" checkbox
     and the fullscreen button — kept INSIDE #game-stage (unlike the
     rest of the left panel) so they stay reachable while #game-stage
     is shown in fullscreen.
     `align-self: stretch` gives it the same width as the canvas (which
     itself sizes #game-col via the flex column above). */
  #game-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    align-self: stretch;
    gap: 10px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    padding: 6px 8px;
  }
  #game-toolbar-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }
  #btn-fullscreen { white-space: nowrap; }
  .toolbar-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.58rem;
    color: #000080;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  .toolbar-checkbox input[type="checkbox"] {
    accent-color: #ff00ff;
    width: 13px;
    height: 13px;
    cursor: pointer;
  }
  #btn-download-recording-game { white-space: nowrap; }

  canvas#gameCanvas { border: 8px solid #568A35; display: block; }
  #message {
    background: #000080;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    color: #ffff00;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 0.75rem;
    text-align: center;
    letter-spacing: 1px;
    line-height: 2.2;
    min-height: 40px;
    padding: 2px 10px;
    animation: blinker 1.1s step-start infinite;
  }

  /* ── Fullscreen mode: the board takes all the space, the chart
     moves to the side instead of being stacked below ── */
  #game-stage.fullscreen-mode {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    background: #000033;
    gap: 30px;
  }
  #game-stage.fullscreen-mode #chart-wrap {
    flex-shrink: 0;
  }

  /* ── Real-time chart: snake length ── */
  #chart-wrap {
    background: #707070;
    border: 2px solid;
    border-color: #ffffff #303030 #303030 #ffffff;
    box-shadow: inset -1px -1px 0 #404040, inset 1px 1px 0 #999999;
    padding: 16px 18px 12px;
  }
  #chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.55rem;
    color: #f0f0ff;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
    font-family: 'Courier New', monospace;
  }
  #chart-header span { color: #ffcc00; }
  #chart-canvas { display: block; }
  #chart-legend {
    display: flex;
    gap: 14px;
    font-size: 0.5rem;
    color: #e8e8e8;
    font-family: 'Courier New', monospace;
    margin-top: 4px;
  }
  .legend-dot {
    display: inline-block;
    width: 8px; height: 8px;
    margin-right: 4px;
    vertical-align: middle;
    border: 1px solid #000000;
  }
  /* Dedicated handle to drag the chart taller (see chart resize JS) */
  #chart-resize-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
    padding: 3px 0;
    background: #ffffff;
    border: 1px dashed #000080;
    color: #000080;
    font-size: 0.5rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: ns-resize;
    user-select: none;
    transition: background .2s, border-color .2s, color .2s;
  }
  #chart-resize-handle:hover,
  #chart-resize-handle.dragging {
    background: #fffbe0;
    border-color: #ff00ff;
    color: #cc00cc;
  }

  /* ── Sound settings modal ── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,50,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
  }
  .modal-overlay.hidden { display: none; }
  #sound-modal {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    padding: 18px 20px;
    width: 340px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  }
  .modal-title {
    color: #ffffff;
    background: #000080;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 0.75rem;
    letter-spacing: 1px;
    margin: -18px -20px 12px;
    padding: 8px 20px;
  }
  .sound-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px dashed #808080;
  }
  .sound-row:last-of-type { border-bottom: none; }
  .sound-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.62rem;
    color: #000080;
    font-weight: bold;
  }
  .sound-row-top label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }
  .sound-row-top input[type="checkbox"] {
    accent-color: #ff00ff;
    width: 13px; height: 13px;
    cursor: pointer;
  }
  .sound-row-actions {
    display: flex;
    gap: 6px;
  }
  .sound-row-actions .reset-btn {
    font-size: 0.52rem;
    padding: 4px 7px;
  }
  .sound-row-actions input[type="file"] { display: none; }
  #btn-close-sound-modal {
    margin-top: 14px;
    width: 100%;
  }
  #btn-mute-all-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.62rem;
    color: #000000;
    font-weight: bold;
    padding-bottom: 10px;
    margin-bottom: 6px;
    border-bottom: 2px solid #808080;
  }
  #btn-mute-all-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }
  #btn-mute-all-row input[type="checkbox"] {
    accent-color: #ff00ff;
    width: 14px; height: 14px;
    cursor: pointer;
  }

  /* ── Footer: under-construction banner ── */
  #retro-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
  }
  #construction-bar {
    width: min(560px, 90vw);
    height: 22px;
    background: repeating-linear-gradient(45deg, #ffff00 0 14px, #000000 14px 28px);
    background-size: 40px 40px;
    animation: constructionStripes 1.4s linear infinite;
    border: 2px solid #000000;
  }

  /* ── Right-side sidebar: "How to play" + "Privacy policy" icons ── */
  #side-icons {
    position: fixed;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 40;
  }
  .icon-btn {
    width: 42px;
    height: 42px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    color: #000080;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0,0,0,.5);
    text-decoration: none;
  }
  .icon-btn img {
    width: 26px;
    height: 26px;
    image-rendering: pixelated;
  }
  .icon-btn-fallback { display: none; align-items: center; justify-content: center; width: 100%; height: 100%; }
  .icon-btn:hover { background: #dcdcdc; }
  .icon-btn:active {
    border-color: #404040 #ffffff #ffffff #404040;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,.4);
  }
  @media (max-width: 680px) {
    #side-icons { right: 6px; gap: 8px; }
    .icon-btn { width: 36px; height: 36px; font-size: 0.95rem; }
  }

  /* ── "How to play" / "Privacy policy" modals ──
     Reuse .modal-overlay + .modal-title from the sound settings modal,
     just wider and with room to scroll long explanatory text. */
  #help-modal, #privacy-modal {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    padding: 18px 20px;
    width: 480px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  }
  .info-section {
    padding: 10px 0;
    border-bottom: 1px dashed #808080;
  }
  .info-section:last-of-type { border-bottom: none; }
  .info-section-title {
    color: #000080;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 0.7rem;
    letter-spacing: .5px;
    margin-bottom: 6px;
  }
  .info-section p {
    font-size: 0.62rem;
    color: #000000;
    line-height: 1.5;
    margin-bottom: 6px;
  }
  .info-section ul {
    margin: 0 0 6px 18px;
    font-size: 0.62rem;
    color: #000000;
    line-height: 1.5;
  }
  .info-section li { margin-bottom: 3px; }
  .info-section strong { color: #000080; }
  #btn-close-privacy-modal {
    margin-top: 14px;
    width: 100%;
  }

  /* ── Standalone "How to play" page ── */
  #help-page-panel {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    padding: 18px 20px;
    width: 560px;
    max-width: 92vw;
    margin: 16px auto;
    box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  }
  #help-page-panel .modal-title {
    margin: -18px -20px 12px;
  }
  #btn-back-to-game {
    display: block;
    margin-top: 14px;
    width: 100%;
    text-align: center;
    text-decoration: none;
  }
