:root {
  --bg-a: #061428;
  --bg-b: #0d3050;
  --bg-c: #1a4a67;
  --ink: #e8f5ff;
  --muted: #a9c4dd;
  --accent: #77ffd7;
  --accent-2: #9fd5ff;
  --danger: #ff9f9f;
  --warn: #ffd28a;
  --panel: rgba(8, 24, 42, 0.82);
  --panel-border: rgba(132, 198, 242, 0.23);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  background: radial-gradient(980px 620px at 8% 0%, rgba(39, 141, 208, 0.26), transparent 60%),
    radial-gradient(860px 520px at 92% 4%, rgba(95, 220, 190, 0.2), transparent 62%),
    linear-gradient(160deg, var(--bg-a) 12%, var(--bg-b) 58%, var(--bg-c) 100%);
}

.shell {
  width: min(1320px, 95vw);
  margin: 0 auto;
  padding: 1rem 0 1.9rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.84fr);
  gap: 1rem;
  align-items: center;
  padding: 1.05rem;
  border-radius: 22px;
  border: 1px solid rgba(141, 215, 255, 0.24);
  background: linear-gradient(132deg, rgba(5, 20, 36, 0.86), rgba(18, 56, 86, 0.56));
  box-shadow: 0 24px 40px rgba(3, 11, 20, 0.36);
  animation: riseIn 360ms ease-out both;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(97deg, rgba(4, 15, 28, 0.08), rgba(4, 15, 28, 0.26) 58%, rgba(4, 15, 28, 0.34));
  pointer-events: none;
}

.hero::before {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  right: -120px;
  top: -200px;
  background: radial-gradient(circle, rgba(119, 255, 215, 0.2), rgba(119, 255, 215, 0));
  pointer-events: none;
  filter: blur(2px);
}

.hero-copy,
.hero-art {
  position: relative;
  z-index: 1;
}

.hero-copy {
  display: grid;
  gap: 0.15rem;
  align-content: center;
}

.eyebrow {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.95;
}

h1 {
  margin: 0.12rem 0 0;
  font-family: "Sora", "Space Grotesk", sans-serif;
  font-size: clamp(2.2rem, 4.8vw, 3.65rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.52rem 0 0;
  color: #d1e9fb;
  line-height: 1.47;
  max-width: 62ch;
  text-shadow: 0 1px 0 rgba(2, 10, 18, 0.3);
}

.hero-meta {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.54rem;
  border-radius: 999px;
  border: 1px solid rgba(145, 216, 252, 0.3);
  background: rgba(12, 35, 57, 0.56);
  color: #c9e6fb;
  font-size: 0.73rem;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.link-line {
  margin: 0.74rem 0 0;
}

.link-line a {
  color: #c7e7ff;
  text-decoration: none;
  border-bottom: 1px dashed rgba(146, 218, 255, 0.4);
}

.hero-art {
  margin: 0;
  width: min(100%, 460px);
  justify-self: end;
  padding: 0.48rem;
  border-radius: 20px;
  border: 1px solid rgba(141, 215, 255, 0.28);
  background: linear-gradient(138deg, rgba(12, 39, 63, 0.85), rgba(14, 53, 78, 0.75));
  box-shadow: inset 0 1px 0 rgba(186, 234, 255, 0.11), 0 18px 34px rgba(2, 10, 18, 0.34);
}

.hero-art img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 620;
  object-fit: cover;
  animation: heroFloat 7.4s ease-in-out infinite;
  border-radius: 14px;
  border: 1px solid rgba(140, 211, 250, 0.28);
  background: linear-gradient(140deg, rgba(14, 48, 74, 0.72), rgba(9, 32, 52, 0.8));
}

.layout {
  margin-top: 0.95rem;
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.92fr);
  gap: 0.9rem;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  animation: riseIn 420ms ease-out both;
}

.layout .panel:nth-child(2) {
  animation-delay: 90ms;
}

.monitor-panel {
  padding: 0.82rem;
  display: grid;
  gap: 0.7rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.52rem;
}

.hud-item {
  border: 1px solid rgba(150, 211, 247, 0.2);
  border-radius: 14px;
  padding: 0.48rem 0.58rem;
  background: rgba(11, 36, 60, 0.6);
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.hud-item.pulse {
  transform: translateY(-1px) scale(1.015);
  border-color: rgba(130, 241, 214, 0.6);
  background: rgba(16, 48, 75, 0.9);
}

.hud-item .label {
  display: block;
  color: #aac8e4;
  font-size: 0.74rem;
}

.hud-item strong {
  font-size: 1.24rem;
  line-height: 1.2;
}

.hud-item.timer strong {
  color: #ffe0a8;
}

.hud-item.timer.is-low {
  border-color: rgba(255, 174, 138, 0.7);
  background: rgba(74, 31, 17, 0.45);
}

.sepsis-board {
  border-radius: 18px;
  border: 1px solid rgba(140, 208, 249, 0.22);
  background: linear-gradient(160deg, rgba(8, 29, 47, 0.84), rgba(12, 42, 66, 0.8));
  padding: 0.68rem;
}

.sepsis-head {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

#caseTag,
#scenarioText {
  margin: 0;
}

#caseTag {
  color: #9bf7d7;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

#scenarioText {
  color: #cce6fa;
  line-height: 1.43;
  min-height: 2.75em;
}

.sepsis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.sepsis-cell {
  border: 1px solid rgba(153, 213, 245, 0.24);
  border-radius: 12px;
  background: rgba(10, 34, 54, 0.72);
  padding: 0.48rem 0.52rem;
  min-height: 76px;
  display: grid;
  gap: 0.18rem;
  align-content: center;
  transition: border-color 180ms ease, transform 180ms ease, background-color 180ms ease;
}

.sepsis-cell.value-flash {
  border-color: rgba(126, 241, 214, 0.64);
  background: rgba(18, 55, 84, 0.9);
  transform: translateY(-1px);
}

.sepsis-cell span {
  color: #a6c8e2;
  font-size: 0.74rem;
  line-height: 1.2;
}

.sepsis-cell strong {
  font-family: "Sora", "Space Grotesk", sans-serif;
  font-size: clamp(1rem, 2vw, 1.28rem);
  letter-spacing: 0.02em;
}

.status-line {
  border: 1px solid rgba(151, 211, 245, 0.2);
  border-radius: 13px;
  background: rgba(12, 37, 60, 0.65);
  padding: 0.5rem 0.62rem;
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.9rem;
}

.status-line p {
  margin: 0;
  overflow-wrap: anywhere;
}

#streakText {
  color: #b7ffd7;
  font-weight: 700;
}

.control-panel {
  padding: 0.82rem;
  display: grid;
  gap: 0.7rem;
}

.block {
  border: 1px solid rgba(143, 206, 244, 0.2);
  border-radius: 14px;
  padding: 0.65rem;
  background: rgba(10, 33, 53, 0.66);
}

.block h2 {
  margin: 0;
  font-family: "Sora", "Space Grotesk", sans-serif;
  font-size: 1.06rem;
}

label {
  display: grid;
  gap: 0.34rem;
  font-size: 0.86rem;
  margin-top: 0.55rem;
  color: #c9e4fb;
}

input,
select {
  border-radius: 11px;
  border: 1px solid rgba(155, 214, 245, 0.3);
  background: rgba(5, 18, 32, 0.72);
  color: #eef8ff;
  font: inherit;
  padding: 0.58rem 0.66rem;
}

input::placeholder {
  color: #7ea6c7;
}

.row {
  margin-top: 0.58rem;
  display: flex;
  gap: 0.48rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid rgba(156, 218, 250, 0.3);
  border-radius: 11px;
  color: #e7f7ff;
  font: inherit;
  font-weight: 700;
  padding: 0.56rem 0.8rem;
  background: rgba(16, 49, 77, 0.8);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(118deg, #6cf1cf, #a3ffd9);
  color: #072034;
  border-color: rgba(141, 255, 224, 0.72);
}

.btn-ghost {
  background: rgba(11, 39, 63, 0.65);
}

.btn-mini {
  padding: 0.35rem 0.55rem;
  font-size: 0.79rem;
}

#questionText {
  margin: 0.55rem 0 0;
  color: #c9e5fb;
  line-height: 1.43;
}

.options {
  margin-top: 0.58rem;
  display: grid;
  gap: 0.45rem;
}

.option-btn {
  width: 100%;
  text-align: left;
  border-radius: 11px;
  border: 1px solid rgba(150, 211, 244, 0.28);
  background: rgba(10, 36, 58, 0.75);
  color: #e8f3ff;
  font: inherit;
  padding: 0.56rem 0.62rem;
  min-height: 46px;
  line-height: 1.35;
  white-space: normal;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease, background-color 120ms ease;
}

.option-btn.option-enter {
  animation: optionRise 280ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.option-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(123, 241, 216, 0.55);
}

.option-btn.correct {
  border-color: rgba(124, 244, 217, 0.78);
  background: linear-gradient(118deg, rgba(42, 138, 114, 0.4), rgba(18, 69, 57, 0.42));
}

.option-btn.wrong {
  border-color: rgba(255, 152, 152, 0.76);
  background: linear-gradient(118deg, rgba(123, 34, 34, 0.36), rgba(67, 15, 15, 0.42));
}

.explanation {
  margin: 0.52rem 0 0;
  color: #9dc5e6;
  font-size: 0.81rem;
  line-height: 1.42;
  min-height: 44px;
}

.leaderboard-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

#leaderboardInfo {
  margin: 0.48rem 0 0;
  color: #afd3ef;
  font-size: 0.82rem;
}

.leaderboard-list {
  margin: 0.48rem 0 0;
  padding: 0 0 0 1.05rem;
  max-height: 240px;
  overflow: auto;
  display: grid;
  gap: 0.42rem;
}

.leaderboard-list li {
  border: 1px solid rgba(153, 212, 245, 0.2);
  border-radius: 10px;
  background: rgba(12, 37, 61, 0.65);
  padding: 0.46rem 0.52rem;
  list-style-position: inside;
}

.entry-main {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.88rem;
}

.entry-sub {
  margin-top: 0.16rem;
  font-size: 0.75rem;
  color: #9ebfdd;
}

.powered-by {
  margin-top: 0.92rem;
  text-align: center;
}

.powered-by a {
  color: #99cce6;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
}


.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 11, 19, 0.78);
  display: grid;
  place-items: center;
  padding: 0.9rem;
  z-index: 30;
}

.result-modal.hidden {
  display: none;
}

.result-card {
  width: min(560px, 94vw);
  border-radius: 16px;
  border: 1px solid rgba(150, 214, 246, 0.28);
  background: linear-gradient(170deg, rgba(5, 18, 32, 0.96), rgba(15, 47, 74, 0.93));
  padding: 0.82rem;
}

.result-card h2 {
  margin: 0;
  font-family: "Sora", "Space Grotesk", sans-serif;
}

#resultSummary {
  margin: 0.45rem 0 0;
  color: #bad5ee;
}

.result-grid {
  margin-top: 0.62rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.result-grid div {
  border: 1px solid rgba(153, 214, 245, 0.24);
  border-radius: 12px;
  background: rgba(12, 37, 60, 0.68);
  padding: 0.5rem;
  display: grid;
  gap: 0.22rem;
}

.result-grid span {
  color: #a9c9e4;
  font-size: 0.78rem;
}

.result-grid strong {
  font-size: 1.17rem;
}

.save-row {
  margin-top: 0.62rem;
}

.save-row label {
  margin: 0;
  color: #d0e9fd;
}

.save-input-row {
  margin-top: 0.38rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.44rem;
}

#saveInfo {
  margin: 0.42rem 0 0;
  color: #a2c7e7;
  font-size: 0.8rem;
}

.result-actions {
  margin-top: 0.62rem;
  display: flex;
  gap: 0.48rem;
  flex-wrap: wrap;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes optionRise {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes heroFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes heroTextIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes orbDrift {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-18px, 12px, 0);
  }
}

@media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
  .hero::before {
    animation: orbDrift 12.4s ease-in-out infinite;
  }

  .hero-copy .eyebrow,
  .hero-copy h1,
  .hero-copy .subtitle,
  .hero-copy .hero-meta,
  .hero-copy .link-line {
    opacity: 0;
    animation: heroTextIn 520ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }

  .hero-copy h1 {
    animation-delay: 60ms;
  }

  .hero-copy .subtitle {
    animation-delay: 120ms;
  }

  .hero-copy .hero-meta {
    animation-delay: 170ms;
  }

  .hero-copy .link-line {
    animation-delay: 220ms;
  }

  .panel {
    transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
  }

  .panel:hover {
    transform: translateY(-2px);
    border-color: rgba(155, 229, 255, 0.4);
    box-shadow: 0 18px 34px rgba(2, 10, 18, 0.28);
  }
}

@media (max-width: 1120px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 0.86rem;
  }

  .hero-art {
    justify-self: center;
    width: min(100%, 500px);
  }

  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .sepsis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(96vw, 96vw);
  }

  .hero {
    padding: 0.78rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .hero-pill {
    font-size: 0.7rem;
  }

  .monitor-panel,
  .control-panel {
    padding: 0.68rem;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-line {
    flex-direction: column;
    align-items: flex-start;
  }

  .save-input-row {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .hero-art {
    display: none;
  }
}

@media (max-width: 900px) {
  html,
  body {
    scroll-padding-top: calc(8.6rem + env(safe-area-inset-top));
  }

  body.running-sepsis .layout {
    gap: 0.66rem;
  }

  body.running-sepsis .monitor-panel {
    position: sticky;
    top: calc(0.52rem + env(safe-area-inset-top));
    z-index: 16;
    border-color: rgba(141, 221, 255, 0.42);
    box-shadow: 0 16px 32px rgba(4, 14, 24, 0.45);
    background: rgba(8, 24, 42, 0.95);
  }

  body.running-sepsis .hud {
    gap: 0.36rem;
  }

  body.running-sepsis .hud-item {
    padding: 0.36rem 0.42rem;
  }

  body.running-sepsis .hud-item .label {
    font-size: 0.65rem;
  }

  body.running-sepsis .hud-item strong {
    font-size: 1rem;
  }

  body.running-sepsis .status-line {
    display: none;
  }

  body.running-sepsis .sepsis-board {
    padding: 0.54rem;
  }

  body.running-sepsis #scenarioText {
    min-height: 0;
    font-size: 0.8rem;
    line-height: 1.32;
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    overflow: visible;
    white-space: normal;
  }

  body.running-sepsis .sepsis-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.32rem;
  }

  body.running-sepsis .sepsis-grid .sepsis-cell {
    display: none;
  }

  body.running-sepsis .sepsis-grid .sepsis-cell:nth-child(1),
  body.running-sepsis .sepsis-grid .sepsis-cell:nth-child(2),
  body.running-sepsis .sepsis-grid .sepsis-cell:nth-child(4),
  body.running-sepsis .sepsis-grid .sepsis-cell:nth-child(7) {
    display: grid;
  }

  body.running-sepsis .sepsis-cell {
    min-height: 56px;
    padding: 0.3rem 0.34rem;
  }

  body.running-sepsis .sepsis-cell span {
    font-size: 0.58rem;
    letter-spacing: 0.01em;
  }

  body.running-sepsis .sepsis-cell strong {
    font-size: 0.82rem;
  }

  body.running-sepsis #questionBlock {
    display: block;
  }

  .leaderboard-list {
    max-height: 180px;
  }
}

@media (max-width: 620px) {
  .hero {
    gap: 0.52rem;
    border-radius: 18px;
  }

  .hero-art {
    display: none;
  }

  h1 {
    font-size: clamp(1.72rem, 9vw, 2.22rem);
  }

  .subtitle {
    font-size: 0.87rem;
    line-height: 1.42;
  }

  .hero-meta {
    margin-top: 0.5rem;
    gap: 0.32rem;
  }

  .hero-pill {
    padding: 0.22rem 0.46rem;
    font-size: 0.66rem;
  }

  .sepsis-grid {
    grid-template-columns: 1fr;
  }

  .sepsis-cell {
    min-height: 64px;
  }

  .option-btn {
    font-size: 0.92rem;
    padding: 0.6rem 0.62rem;
  }

  .explanation {
    min-height: 58px;
    font-size: 0.8rem;
  }

  body.running-sepsis .sepsis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.34rem;
  }

  body.running-sepsis .sepsis-cell {
    min-height: 54px;
  }

  body.running-sepsis .sepsis-cell span {
    font-size: 0.6rem;
  }

  body.running-sepsis .sepsis-cell strong {
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
