html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d12;
  color: #e8e6e1;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.roster {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* One card per robot: portrait with the key number, name underneath. The selected robot's card is
   large and lit, the others small and dimmed. */
.robot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.robot.active {
  opacity: 1;
}

.robot .portrait {
  position: relative;
  width: 44px;
  height: 44px;
  border: 2px solid #3a404c;
  border-radius: 8px;
  overflow: hidden;
  /* the portraits are cut out; a dark backdrop lit faintly in the robot's colour sits behind them */
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--robot-color) 35%, #1b2029), #0d1016 75%);
  transition: width 0.2s ease-out, height 0.2s ease-out, border-color 0.2s, box-shadow 0.2s;
}

.robot.active .portrait {
  width: 72px;
  height: 72px;
  border-width: 3px;
  border-color: var(--robot-color);
  box-shadow: 0 0 10px var(--robot-color);
}

.robot .portrait img {
  width: 100%;
  height: 100%;
  display: block;
}

.robot .key {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 14px;
  padding: 0 4px;
  border-bottom-right-radius: 6px;
  background: var(--robot-color);
  color: #15171c;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.robot.active .key {
  font-size: 14px;
  min-width: 20px;
}

.robot .name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 3px #000;
}

.robot.active .name {
  font-size: 13px;
  color: var(--robot-color);
}

.robot.annoyed .portrait {
  border-color: #ffb347;
}

.robot.furious .portrait {
  border-color: #ff5a4f;
  animation: mood-shake 0.3s linear infinite;
}

@keyframes mood-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(11, 13, 18, 0.72);
  font-size: 13px;
  color: #b8bcc6;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  padding: 0 5px;
  margin: 0 1px;
  border: 1px solid #4a5060;
  border-radius: 3px;
  font: 12px ui-monospace, monospace;
  color: #e8e6e1;
}

.clock {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  background: rgba(11, 13, 18, 0.72);
  text-align: center;
}

.clock-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a8f99;
}

.clock-value {
  font: 700 28px ui-monospace, monospace;
  color: #ff8a1f;
}

.clock.warning .clock-value {
  color: #ff4d3d;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% { opacity: 0.45; }
}

.objectives {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: 340px;
  margin: 0;
  padding: 10px 12px 10px 30px;
  background: rgba(11, 13, 18, 0.72);
  font-size: 13px;
  line-height: 1.45;
  color: #d6d8de;
}

.objectives li + li {
  margin-top: 4px;
}

.objectives b {
  color: var(--robot-color);
}

.objectives li.done {
  color: #6b7080;
  text-decoration: line-through;
}

.objectives li.done b {
  color: inherit;
}

.prompt {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: rgba(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 0.5);
  font-size: 15px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}

.prompt.visible {
  opacity: 1;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 7, 10, 0.72);
}

.screen.visible {
  display: flex;
}

.screen .panel {
  max-width: 560px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;   /* the HUD ignores the mouse, but the panel has to scroll */
  box-sizing: border-box;
  margin: 16px;
  padding: 28px 32px;
  background: #11141b;
  border-top: 3px solid #ff8a1f;
  line-height: 1.5;
}

.screen h1 {
  margin: 0 0 14px;
  font-size: 34px;
  color: #ff8a1f;
}

.screen h1 span {
  display: block;
  font-size: 18px;
  font-weight: 500;
  color: #e8e6e1;
}

.carousel {
  position: relative;
  margin: 18px 0 8px;
  padding: 0 28px;
}

.carousel .slide {
  display: none;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
  min-height: 206px;      /* slides of different length must not make the panel jump */
  box-sizing: border-box;
  margin: 0;
  padding: 12px;
  border-left: 3px solid var(--robot-color);
  background: rgba(255, 255, 255, 0.03);
}

.carousel .slide.active {
  display: grid;
  animation: slide-in 0.35s ease-out;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

.carousel img {
  width: 150px;
  height: 180px;
  object-fit: contain;
  background: #eceae6;
  border-radius: 4px;
}

.carousel h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--robot-color);
}

.carousel h2 .key {
  font-size: 14px;
  color: #7f8796;
}

.carousel figcaption p {
  margin: 0 0 8px;
  font-size: 14px;
}

.carousel .facts {
  color: #b8bcc6;
  font-size: 13px;
}

.carousel .idol {
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #d8d6d0;
}

.carousel .nav {
  position: absolute;
  top: calc(50% - 20px);
  width: 24px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: #b8bcc6;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.carousel .nav:hover {
  color: #ff8a1f;
}

.carousel .prev {
  left: 0;
}

.carousel .next {
  right: 0;
}

.carousel .dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.carousel .dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #3a404c;
  cursor: pointer;
}

.carousel .dot.active {
  background: #ff8a1f;
}

@media (max-width: 520px) {
  .carousel .slide {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.screen .keys {
  color: #b8bcc6;
  font-size: 14px;
}

.screen .credit {
  margin-top: 14px;
  font-size: 11px;
  color: #7f8796;
}

.screen .credit a {
  color: inherit;
}

.screen .start {
  margin-bottom: 0;
  font-weight: 600;
  animation: blink 1.6s steps(2) infinite;
}

@media (max-width: 720px) {
  .objectives, .controls { display: none; }
}

.log {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 460px;
  padding: 6px 10px 8px;
  background: rgba(6, 8, 11, 0.82);
  border-left: 3px solid #5ac8ff;
  font: 11.5px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: #7f8796;
}

.log-title {
  color: #5ac8ff;
  margin-bottom: 2px;
}

.log-lines div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-lines span {
  color: #555c68;
}

.log-lines .lore {
  color: #e0b25a;
}

.screen .easter-egg {
  color: #e0b25a;
  font-size: 14px;
}

.log-lines .glitch {
  color: #ff6b5b;
}

.log-lines .fixed {
  color: #3ddc84;
}

.log-lines .info {
  color: #c5cad3;
}

.objectives li.optional {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #2a2f3a;
}

.screen .verdict {
  padding: 8px 12px;
  background: rgba(90, 200, 255, 0.08);
  border-left: 3px solid #5ac8ff;
}

@media (max-width: 1100px) {
  .log { width: 340px; }
  .controls { left: auto; right: 16px; transform: none; }
}

.screen .record {
  color: #ff8a1f;
  font-weight: 600;
}


/* Touch controls (src/touch.js). Hidden until the device turns out to have a touch screen; then the
   keyboard hints give way to a stick on the left half and buttons on the right. */
.touch-only,
.touch-layer {
  display: none;
}

body.touch .touch-only {
  display: inline;
}

body.touch p.touch-only {
  display: block;
}

body.touch .key-only,
body.touch .controls {
  display: none;
}

body.touch .touch-layer {
  display: block;
}

#hud:has(.screen.visible) .touch-layer {
  display: none;
}

body.touch,
body.touch #game {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.touch .roster .robot {
  pointer-events: auto;
}

/* Pinned to the bottom of the scrolling panel, so the way into the game is always in sight. */
body.touch .screen .start {
  position: sticky;
  bottom: -28px;          /* the panel's bottom padding */
  margin: 16px -32px -28px;
  padding: 14px 22px;
  text-align: center;
  background: #ff8a1f;
  color: #11141b;
  cursor: pointer;
  animation: none;
}

body.touch .prompt {
  bottom: 24px;
  max-width: 50vw;
  white-space: normal;
  text-align: center;
}

.stick-zone {
  position: absolute;
  top: 130px;
  bottom: 0;
  left: 0;
  width: 50%;
  pointer-events: auto;
  touch-action: none;
}

.stick-base {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border: 2px solid rgba(232, 230, 225, 0.35);
  border-radius: 50%;
  background: rgba(11, 13, 18, 0.35);
  opacity: 0;
  transition: opacity 0.1s;
}

.stick-base.visible {
  opacity: 1;
}

.stick-knob {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 138, 31, 0.75);
}

.touch-buttons {
  position: absolute;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.touch-buttons button {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(232, 230, 225, 0.3);
  border-radius: 50%;
  background: rgba(11, 13, 18, 0.72);
  color: #e8e6e1;
  font-size: 22px;
  touch-action: manipulation;
}

.touch-buttons button:active {
  background: rgba(255, 138, 31, 0.4);
}

.touch-buttons .act {
  width: 84px;
  height: 84px;
  border: 2px solid #ff8a1f;
  font-size: 30px;
  font-weight: 700;
  color: #ff8a1f;
}
