:root {
    color-scheme: dark;
    --night-high: #151c36;
    --night-low: #04060b;
  }

  html,
  body {
    height: 100%;
    margin: 0;
    font-family: 'Yu Gothic', 'Hiragino Sans', 'Meiryo', 'Microsoft YaHei', sans-serif;
  }

  body {
    background: radial-gradient(120% 90% at 50% 38%, var(--night-high), var(--night-low));
    overflow: hidden;
  }

  #scene {
    cursor: crosshair;
    display: block;
    height: 100%;
    opacity: 0;
    outline: none;
    touch-action: none;
    transition: opacity 1.8s ease;
    width: 100%;
  }

  #scene.is-ready { opacity: 1; }
  #scene:active { cursor: crosshair; }
  body.is-locked #scene { cursor: none; }

  #crosshair {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
    pointer-events: none;
    z-index: 5;
  }

  #hint,
  #prompt {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    padding: 9px 16px;
    border-radius: 10px;
    background: rgba(8, 14, 26, 0.62);
    border: 1px solid rgba(140, 180, 240, 0.22);
    color: #cfe0ff;
    font-size: 13px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    pointer-events: none;
    z-index: 6;
    transition: opacity .35s ease;
  }
  #hint { bottom: 26px; }
  #prompt { bottom: 66px; color: #e8f2ff; }
  #hint.hidden, #prompt.hidden { opacity: 0; }
  #hint b { color: #8fd3ff; font-weight: 600; }

  #fps {
    position: fixed;
    right: 14px;
    top: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(8, 14, 26, 0.55);
    border: 1px solid rgba(140, 180, 240, 0.18);
    color: #a9e6a0;
    font: 600 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
    letter-spacing: 0.04em;
    pointer-events: none;
    z-index: 6;
  }


  /* talking to the cat: the live view is blurred behind the box */
  #talk {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 9, 18, 0.34);
    -webkit-backdrop-filter: blur(13px) saturate(0.85);
    backdrop-filter: blur(13px) saturate(0.85);
  }
  #talk.active { display: flex; }

  #talk-panel {
    width: min(560px, 84vw);
    padding: 22px 24px 18px;
    border-radius: 16px;
    background: rgba(10, 16, 28, 0.74);
    border: 1px solid rgba(140, 180, 240, 0.26);
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.6);
    color: #dbe7ff;
  }


  #talk-row {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  #talk-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(140, 180, 240, 0.3);
    background: rgba(4, 8, 16, 0.78);
    color: #eaf2ff;
    font: inherit;
    font-size: 15px;
    outline: none;
  }
  #talk-input:focus { border-color: rgba(150, 205, 255, 0.7); }

  #talk-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  #talk-name {
    font-size: 15px;
    letter-spacing: 0.08em;
    color: #cfe0ff;
  }

  #talk-close {
    position: relative;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(140, 180, 240, 0.28);
    background: rgba(6, 12, 22, 0.6);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
  }
  #talk-close::before,
  #talk-close::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 13px;
    height: 1.6px;
    background: #cfe0ff;
    border-radius: 2px;
  }
  #talk-close::before { transform: translate(-50%, -50%) rotate(45deg); }
  #talk-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
  #talk-close:hover {
    background: rgba(34, 56, 90, 0.85);
    border-color: rgba(150, 205, 255, 0.6);
  }

  #talk-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
    max-height: 44vh;
    overflow-y: auto;
    padding: 2px 2px 6px;
  }

  .msg { display: flex; }
  .msg.cat { justify-content: flex-start; }
  .msg.me { justify-content: flex-end; }

  .msg .bubble {
    max-width: 76%;
    padding: 9px 13px;
    border-radius: 13px;
    font-size: 16px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
  }
  .msg.cat .bubble {
    background: rgba(58, 78, 116, 0.62);
    color: #eaf2ff;
    border-top-left-radius: 5px;
  }
  .msg.me .bubble {
    background: rgba(52, 124, 96, 0.55);
    color: #eafff5;
    border-top-right-radius: 5px;
  }

  #talk-send {
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid rgba(140, 180, 240, 0.3);
    background: rgba(40, 70, 110, 0.7);
    color: #eaf2ff;
    font: inherit;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
  }
  #talk-send:hover { background: rgba(55, 95, 145, 0.8); }



/* ---------- pre-flight quality screen ---------- */
#start {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 38%, #151c36, #04060b);
  transition: opacity .4s ease;
}
#start.hidden { opacity: 0; pointer-events: none; }

#start-panel {
  width: min(620px, 88vw);
  padding: 30px 32px 26px;
  border-radius: 18px;
  background: rgba(10, 16, 28, 0.72);
  border: 1px solid rgba(140, 180, 240, 0.26);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  color: #dbe7ff;
}

#start-title {
  font-size: 26px;
  letter-spacing: 0.14em;
  color: #eaf2ff;
}

#start-sub {
  margin: 8px 0 22px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: #8fa8cc;
}

#start-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.lvl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  border-radius: 12px;
  border: 1px solid rgba(140, 180, 240, 0.22);
  background: rgba(6, 12, 22, 0.6);
  color: #cfe0ff;
  cursor: pointer;
  font: inherit;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.lvl b { font-size: 20px; letter-spacing: 0.1em; color: #eaf2ff; }
.lvl span { font-size: 12px; line-height: 1.6; color: #93a9c8; }
.lvl:hover { background: rgba(24, 40, 66, 0.75); }
.lvl.on {
  border-color: rgba(150, 205, 255, 0.85);
  background: rgba(34, 62, 104, 0.85);
  transform: translateY(-2px);
}
.lvl.on span { color: #cfe0ff; }

#start-gpu-line {
  margin: 18px 0 4px;
  font-size: 11.5px;
  color: #7d93b3;
  word-break: break-all;
}
#start-gpu { color: #a9c4e6; }

#start-go {
  margin-top: 16px;
  padding: 12px 42px;
  border-radius: 12px;
  border: 1px solid rgba(150, 205, 255, 0.5);
  background: rgba(40, 78, 122, 0.85);
  color: #eaf2ff;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.2em;
  cursor: pointer;
}
#start-go:hover { background: rgba(56, 104, 156, 0.9); }
