/* Cream speech bubbles and ink-blue outlines from the supplied Brent artwork. */
:root {
  --brent-blue: #245f89;
  --brent-ink: #173c58;
  --brent-cream: #fff6d9;
  --brent-round: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", Arial, sans-serif;
}

.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Both controls are in their own row, outside the canvas. */
#shell .touch {
  gap: 32px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.stick-control, .work-control { display: grid; justify-items: center; gap: 10px; }
.control-hint { color: #cfddcf; font: 700 .875rem/1.2 var(--brent-round); }
#thumbstick {
  position: relative;
  width: 136px;
  height: 136px;
  border: 3px solid #5f94ac;
  border-radius: 50%;
  background: radial-gradient(circle, #213c4b 0 43%, #10222e 44% 100%);
  box-shadow: inset 0 3px 16px #0008, 0 5px 0 #081521, 0 12px 24px #0004;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#thumbstick, #thumbstick * { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.stick-ring { position: absolute; inset: 13px; border: 1px dashed #7193a160; border-radius: 50%; pointer-events: none; }
.thumbstick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 62px; height: 62px;
  border: 4px solid var(--brent-blue);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 28%, #fffbed, #eddcae);
  box-shadow: 0 5px 0 #163d55, 0 9px 16px #0006, inset 0 0 0 2px #fff8;
  pointer-events: none;
  transition: transform .14s ease-out;
}
#thumbstick.is-active { cursor: grabbing; border-color: #efd878; }
#thumbstick.is-active .thumbstick-knob { transition: none; }
#thumbstick[aria-disabled="true"] { opacity: .5; }
#shell .touch .act {
  width: 96px; height: 96px;
  border: 4px solid var(--brent-blue);
  border-radius: 50%;
  background: var(--brent-cream);
  color: var(--brent-blue) !important;
  box-shadow: 0 5px 0 #102e43, 0 12px 24px #0005, inset 0 0 0 3px #fff7;
  font: 900 1.05rem/1 var(--brent-round) !important;
  text-transform: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#shell .touch .act:is(:active,.is-held) { transform: translateY(3px); box-shadow: 0 2px 0 #102e43; background: #f4d77f; }
#shell .touch .act:focus-visible { outline: 3px solid #f4d77f; outline-offset: 5px; }

#taskModal {
  padding: 24px 16px;
  background: rgba(5, 18, 30, .7);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  font-family: var(--brent-round);
}
#taskModal .terminal {
  width: min(580px, 100%);
  max-height: calc(100svh - 48px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: clamp(22px, 5vw, 34px);
  border: 5px solid var(--brent-blue);
  border-radius: 40px 40px 40px 14px;
  background: var(--brent-cream);
  color: var(--brent-ink);
  box-shadow: 0 8px 0 #122f46, 0 28px 65px #0007, inset 0 0 0 2px #fff9;
}
#taskModal .terminal h2 {
  margin: 0;
  color: var(--brent-blue);
  font: 900 clamp(1.5rem, 5.5vw, 2.1rem)/1.12 var(--brent-round);
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
#taskModal .modal-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--brent-ink);
  font: 500 1.0625rem/1.6 var(--brent-round);
  scrollbar-width: thin;
  scrollbar-color: #7ea1b2 transparent;
}
#taskModal .workbar {
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  overflow: hidden;
  border: 2px solid var(--brent-blue);
  border-radius: 99px;
  background: #dfddc7;
}
#taskModal .workbar span { border-radius: inherit; background: var(--brent-blue); }
#taskModal .choices { flex: 0 0 auto; gap: 12px; }
#taskModal .choices button,
#overlay.report-overlay .start {
  min-height: 54px;
  padding: 13px 18px;
  border: 3px solid var(--brent-blue);
  border-radius: 25px;
  background: var(--brent-blue);
  color: #fff9e6;
  font: 900 1rem/1.25 var(--brent-round);
  letter-spacing: 0;
  box-shadow: 0 4px 0 var(--brent-ink);
  cursor: pointer;
}
#taskModal .choices button + button { background: #fff9e7; color: var(--brent-blue); }
#taskModal .choices button:disabled { opacity: .52; cursor: wait; box-shadow: none; }
#taskModal .choices button:not(:disabled):active,
#overlay.report-overlay .start:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brent-ink); }
#taskModal .choices button:focus-visible,
#overlay.report-overlay .start:focus-visible { outline: 3px solid #d99c24; outline-offset: 4px; }

/* A conversation, with each voice in its own speech bubble. */
#taskModal.chat-modal .terminal {
  width: min(640px, 100%);
  height: min(760px, calc(100svh - 48px));
  gap: 0;
  padding: 22px 20px 24px;
  border-color: #3c7fa5;
  border-radius: 38px;
  background: #12324b;
  box-shadow: 0 8px 0 #081e30, 0 28px 70px #0009, inset 0 0 0 2px #6395ac66;
}
#taskModal.chat-modal .terminal h2 { color: var(--brent-cream); padding: 0 8px 18px; }
#taskModal.chat-modal .modal-body { flex: 1; margin: 0 -4px; padding: 6px 8px 18px; }
#taskModal .chat-conversation { display: flex; flex-direction: column; gap: 22px; }
#taskModal .chat-bubble {
  position: relative;
  isolation: isolate;
  width: fit-content;
  max-width: 90%;
  padding: 14px 18px;
  border: 3px solid #3a789d;
  border-radius: 26px;
  background: var(--brent-cream);
  color: var(--brent-ink);
  box-shadow: 0 4px 0 #091f32;
}
#taskModal .chat-bubble::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  bottom: -10px; left: 22px;
  transform: skewY(-25deg);
  border-left: 3px solid #3a789d;
  border-bottom: 3px solid #3a789d;
  border-radius: 0 0 0 4px;
  background: var(--brent-cream);
}
#taskModal .chat-bubble.brent { align-self: flex-end; background: #d5eafa; }
#taskModal .chat-bubble.brent::after { left: auto; right: 22px; transform: scaleX(-1) skewY(-25deg); background: #d5eafa; }
#taskModal .chat-bubble span { display: block; margin-bottom: 6px; font: 900 .875rem/1.2 var(--brent-round); color: var(--brent-blue); }
#taskModal .chat-bubble p { margin: 0; font: 500 1rem/1.5 var(--brent-round); color: var(--brent-ink); }
#taskModal .chat-bubble.system-note { align-self: center; max-width: 100%; padding: 8px 12px; border: 0; background: transparent; box-shadow: none; text-align: center; }
#taskModal .chat-bubble.system-note::after { content: none; }
#taskModal .chat-bubble.system-note span { color: #f4d589; }
#taskModal .chat-bubble.system-note p { font-size: .875rem; color: #d1e3ee; }
#taskModal.chat-modal .choices { grid-template-columns: 1fr; padding-top: 18px; border-top: 1px solid #89afc14d; }
#taskModal.chat-modal .choices button { background: var(--brent-cream); color: var(--brent-blue); box-shadow: 0 4px 0 #061e30; }
#taskModal.chat-modal .workbar { display: none !important; }

/* The starting artwork still fills the screen; its copy now uses the same palette. */
.intro-copy {
  border: 4px solid #2c6a91;
  border-radius: 36px 36px 14px 36px;
  background: rgba(255, 246, 217, .94);
  box-shadow: 0 7px 0 #14364e, 0 20px 60px #0007;
}
.intro-copy p { font-family: var(--brent-round); color: var(--brent-ink); }
.intro-copy .small { color: #405e6d; }
.intro-copy .start { border: 3px solid #174465; border-radius: 24px; background: var(--brent-blue); color: var(--brent-cream); font-family: var(--brent-round); letter-spacing: 0; }
#overlay.report-overlay {
  padding: 24px 16px;
  background: rgba(5,18,30,.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#overlay.report-overlay .intro {
  width: min(560px, 100%);
  height: auto;
  max-height: calc(100svh - 48px);
  overflow: auto;
  padding: 28px;
  border: 5px solid var(--brent-blue);
  border-radius: 40px 40px 16px 40px;
  background: var(--brent-cream);
  box-shadow: 0 8px 0 #122f46, 0 28px 65px #0007;
  color: var(--brent-ink);
  font-family: var(--brent-round);
}
#overlay.report-overlay .intro h1 { color: var(--brent-blue); font: 900 clamp(1.75rem,7vw,2.8rem)/1.1 var(--brent-round); letter-spacing: -.035em; }
#overlay.report-overlay .intro h1 span { color: var(--brent-blue); }
#overlay.report-overlay .intro p { color: var(--brent-ink); font-size: 1rem; }
#overlay.report-overlay .intro .small { font-size: .875rem; color: #536775; }
#overlay.report-overlay .seal { border-color: var(--brent-blue); color: var(--brent-blue); }
#overlay.report-overlay .end-art { max-height: 170px; border: 0; border-radius: 22px; }
#overlay.report-overlay .end-copy { padding: 22px 0 0; }

@media (max-width: 850px), (pointer: coarse) {
  #shell.chat-entity-mode {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) clamp(96px, 14svh, 120px);
    gap: 12px;
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }
  #shell.chat-entity-mode header { position: static; margin: 0; grid-column: 1; }
  #shell.chat-entity-mode #gameWrap {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 4px;
    min-height: 0;
  }
  #shell .game-stage { overflow: hidden; }
  #shell #gameWrap canvas { width: auto; height: auto; max-width: 100%; max-height: 100%; flex: 0 1 auto; object-fit: contain; }
  #shell.chat-entity-mode aside { position: static; width: auto; height: 100%; min-height: 0; }
  #shell.chat-entity-mode .tasks { padding: 10px 13px; height: 100%; overflow: auto; }
  #shell.chat-entity-mode .tasks ul { font-size: .875rem; grid-template-columns: 1fr 1fr; gap: 5px 12px; }
  #shell.chat-entity-mode .tasks h2 { font-size: .875rem; }
  #shell.chat-entity-mode .touch { display: flex; position: relative; inset: auto; min-height: 166px; padding: 0 18px 6px; }
  #shell.chat-entity-mode #prompt { bottom: 10px; width: max-content; max-width: calc(100% - 20px); padding: 8px 12px; font-size: .875rem; }
}
@media (max-width: 460px) {
  #taskModal .terminal { padding: 24px 20px; border-radius: 32px 32px 32px 12px; gap: 18px; }
  #taskModal .choices { grid-template-columns: 1fr; }
  #taskModal.chat-modal .terminal { padding: 20px 12px; border-radius: 32px; gap: 0; }
  #taskModal .chat-bubble { max-width: 94%; padding: 12px 14px; }
}
@media (max-height: 670px) {
  #thumbstick { width: 112px; height: 112px; }
  .thumbstick-knob { width: 54px; height: 54px; }
  #shell.chat-entity-mode .touch { min-height: 140px; }
}
@media (max-width: 360px) {
  #shell.chat-entity-mode .touch { padding-inline: 8px; }
  #thumbstick { width: 120px; height: 120px; }
  .thumbstick-knob { width: 54px; height: 54px; }
  #shell .touch .act { width: 88px; height: 88px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 4/3) {
  #shell.chat-entity-mode { grid-template-columns: minmax(0,1fr) 210px; grid-template-rows: auto minmax(0,1fr); }
  #shell.chat-entity-mode header { grid-column: 1/-1; }
  #shell.chat-entity-mode aside { grid-column: 2; grid-row: 2; }
  #shell.chat-entity-mode .tasks ul { grid-template-columns: 1fr; }
  #shell.chat-entity-mode .touch { min-height: 104px; }
  #thumbstick { width: 88px; height: 88px; }
  .thumbstick-knob { width: 42px; height: 42px; }
  #shell .touch .act { width: 70px; height: 70px; }
  .control-hint { display: none; }
  #taskModal .terminal { gap: 12px; padding: 18px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .thumbstick-knob { transition: none; }
}
