:root {
  --ink: #22313a;
  --muted: #63727c;
  --paper: #fffaf4;
  --panel: #ffffff;
  --line: #eadfd4;
  --red: #df3d2e;
  --red-dark: #9d241d;
  --teal: #157a76;
  --mint: #dff5ee;
  --gold: #f4b84a;
  --blue: #355c7d;
  --shadow: 0 16px 40px rgba(46, 31, 24, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(223, 61, 46, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(21, 122, 118, 0.12), transparent 38%),
    var(--paper);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 24px;
}

.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(300px, 1.05fr);
  align-items: center;
  gap: 34px;
}

.login-art {
  min-height: 460px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(223, 61, 46, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(160deg, #ffe3d6, #f8f7e8 45%, #dff5ee);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.octopus-portrait,
.coach-image {
  position: relative;
  display: grid;
  place-items: center;
}

.octopus-portrait img {
  width: min(78vw, 380px);
  height: auto;
  filter: drop-shadow(0 18px 20px rgba(122, 39, 28, 0.18));
}

.red-hat {
  position: absolute;
  top: 5%;
  left: 44%;
  width: 26%;
  height: 14%;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #ff5246, var(--red-dark));
  transform: rotate(9deg);
  box-shadow: inset 0 -8px 0 rgba(81, 17, 14, 0.18), 0 8px 0 rgba(34, 49, 58, 0.08);
}

.red-hat::before {
  content: "";
  position: absolute;
  left: -9%;
  right: -12%;
  bottom: -20%;
  height: 34%;
  border-radius: 999px;
  background: #6e1916;
}

.red-hat::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -17%;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff5d6;
  border: 3px solid #c6342a;
}

.login-panel {
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  color: var(--red-dark);
  font-size: 2.35rem;
  line-height: 1.08;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.35rem;
  line-height: 1.18;
}

.login-panel p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.passcode-form {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.passcode-form label {
  font-size: 0.92rem;
  font-weight: 800;
}

.passcode-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.passcode-row input {
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

.passcode-row input:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(21, 122, 118, 0.16);
}

.passcode-row button,
.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
}

.passcode-row button,
.primary-button {
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow: 0 12px 24px rgba(157, 36, 29, 0.22);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
}

.form-message,
.mission-message {
  min-height: 1.45rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.form-message[data-tone="error"],
.mission-message[data-tone="error"] {
  color: #b92e26;
}

.form-message[data-tone="success"],
.mission-message[data-tone="success"] {
  color: var(--teal);
}

.mission-view {
  display: grid;
  gap: 18px;
}

.mission-view[hidden],
.login-view[hidden] {
  display: none;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.75rem;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--red-dark);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 1.25rem;
}

.coach-band {
  padding: 0;
}

.coach-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 190px;
  border: 1px solid rgba(223, 61, 46, 0.2);
  border-radius: var(--radius);
  background: linear-gradient(110deg, #fff 0%, #fff1e9 45%, #e8f8f1 100%);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.coach-image {
  height: 190px;
  background: rgba(223, 61, 46, 0.08);
}

.coach-image img {
  width: 165px;
  height: 165px;
  object-fit: contain;
}

.coach-image .red-hat {
  top: 13px;
  left: 81px;
  width: 52px;
  height: 29px;
}

.coach-copy {
  padding: 22px 24px 22px 0;
}

.coach-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.mission-panel,
.utility-strip,
.cadet-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.mission-panel {
  padding: 24px;
}

.mission-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.mission-status span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--mint);
  font-size: 0.86rem;
  font-weight: 800;
}

.mission-panel h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
  color: var(--red-dark);
}

.mission-panel p {
  color: var(--muted);
  line-height: 1.62;
}

.mission-detail {
  margin-bottom: 18px;
}

.mission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(21, 122, 118, 0.22);
  color: var(--teal);
  background: #fff;
  text-decoration: none;
}

.utility-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.utility-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.cadet-section {
  padding: 22px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading p {
  max-width: 380px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: right;
}

.cadet-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.cadet-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
}

.cadet-card.is-me {
  border-color: rgba(223, 61, 46, 0.48);
  box-shadow: inset 0 0 0 2px rgba(223, 61, 46, 0.08);
}

.cadet-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cadet-name {
  min-width: 0;
  margin: 0;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-pill {
  flex: 0 0 auto;
  min-width: 52px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
}

.avatar-stage {
  height: 190px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #eef9f2, #fff5e9);
  overflow: hidden;
}

.avatar {
  --strength: 0.45;
  --skin: #f4b38d;
  --shirt: #5aaec2;
  --shorts: #355c7d;
  --scale-x: calc(0.78 + var(--strength) * 0.34);
  --arm-width: calc(10px + var(--strength) * 19px);
  --leg-width: calc(12px + var(--strength) * 14px);
  position: relative;
  width: 112px;
  height: 164px;
  transform: scaleX(var(--scale-x));
  transition: transform 0.25s ease;
}

.avatar .head {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 52px;
  height: 58px;
  border-radius: 45% 45% 48% 48%;
  background: var(--skin);
  transform: translateX(-50%);
  border: 2px solid rgba(62, 38, 32, 0.16);
  z-index: 3;
}

.avatar .head::before,
.avatar .head::after {
  content: "";
  position: absolute;
  top: 27px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2c2430;
}

.avatar .head::before {
  left: 15px;
}

.avatar .head::after {
  right: 15px;
}

.avatar .hair {
  position: absolute;
  top: -4px;
  left: 6px;
  right: 6px;
  height: 18px;
  border-radius: 20px 20px 8px 8px;
  background: #3b2b22;
  z-index: 4;
}

.avatar.female .hair {
  top: -6px;
  left: -1px;
  right: -1px;
  height: 32px;
  border-radius: 26px 26px 12px 12px;
}

.avatar .mouth {
  position: absolute;
  left: 50%;
  bottom: 13px;
  width: 16px;
  height: 7px;
  border-bottom: 3px solid #9e453c;
  border-radius: 50%;
  transform: translateX(-50%);
}

.avatar .body {
  position: absolute;
  top: 61px;
  left: 50%;
  width: calc(44px + var(--strength) * 34px);
  height: 58px;
  border-radius: 18px 18px 10px 10px;
  background: var(--shirt);
  transform: translateX(-50%);
  z-index: 2;
}

.avatar .body::before,
.avatar .body::after {
  content: "";
  position: absolute;
  top: 11px;
  width: calc(8px + var(--strength) * 19px);
  height: calc(16px + var(--strength) * 20px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.avatar .body::before {
  left: 4px;
}

.avatar .body::after {
  right: 4px;
}

.avatar .arm {
  position: absolute;
  top: 67px;
  width: var(--arm-width);
  height: calc(54px + var(--strength) * 18px);
  border-radius: 999px;
  background: var(--skin);
  z-index: 1;
}

.avatar .arm.left {
  left: calc(23px - var(--strength) * 16px);
  transform: rotate(calc(-14deg - var(--strength) * 18deg));
}

.avatar .arm.right {
  right: calc(23px - var(--strength) * 16px);
  transform: rotate(calc(14deg + var(--strength) * 18deg));
}

.avatar .shorts {
  position: absolute;
  top: 112px;
  left: 50%;
  width: calc(46px + var(--strength) * 24px);
  height: 24px;
  border-radius: 6px 6px 12px 12px;
  background: var(--shorts);
  transform: translateX(-50%);
  z-index: 3;
}

.avatar .leg {
  position: absolute;
  top: 128px;
  width: var(--leg-width);
  height: calc(32px + var(--strength) * 14px);
  border-radius: 999px;
  background: var(--skin);
}

.avatar .leg.left {
  left: 42px;
}

.avatar .leg.right {
  right: 42px;
}

.avatar .shoe {
  position: absolute;
  bottom: 0;
  width: calc(18px + var(--strength) * 12px);
  height: 10px;
  border-radius: 999px;
  background: #2d3340;
}

.avatar .shoe.left {
  left: 32px;
}

.avatar .shoe.right {
  right: 32px;
}

.avatar.level-1 {
  --strength: 0;
  --skin: #f1ecd8;
  --shirt: #c9d0d2;
  --shorts: #8f9a9f;
  transform: scaleX(0.62) rotate(-3deg);
}

.avatar.level-1 .head {
  border-radius: 50%;
  background: #f7f2df;
}

.avatar.level-1 .head::before,
.avatar.level-1 .head::after {
  width: 9px;
  height: 11px;
  background: #252525;
}

.avatar.level-1 .body {
  width: 32px;
  background:
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(36, 36, 36, 0.22) 6px 8px),
    #f1ecd8;
}

.avatar.level-1 .hair,
.avatar.level-1 .mouth {
  display: none;
}

.avatar.level-2 { --strength: 0.08; --shirt: #a8c9d6; }
.avatar.level-3 { --strength: 0.18; --shirt: #8fc1d1; }
.avatar.level-4 { --strength: 0.31; --shirt: #6fb8c9; }
.avatar.level-5 { --strength: 0.44; --shirt: #5aaec2; }
.avatar.level-6 { --strength: 0.56; --shirt: #39a995; }
.avatar.level-7 { --strength: 0.68; --shirt: #29a17a; }
.avatar.level-8 { --strength: 0.8; --shirt: #f0a43b; }
.avatar.level-9 { --strength: 0.92; --shirt: #ef723f; }
.avatar.level-10 { --strength: 1; --shirt: #df3d2e; --shorts: #1d2730; }

.avatar.level-10 .head::before {
  left: 12px;
  width: 28px;
  height: 8px;
  border-radius: 2px;
  background: #111;
  box-shadow: 17px 0 0 #111;
}

.avatar.level-10 .head::after {
  display: none;
}

.avatar.level-10 .body {
  height: 66px;
  border-radius: 26px 26px 12px 12px;
}

.avatar.level-10 .body::before,
.avatar.level-10 .body::after {
  top: 15px;
  background: rgba(255, 222, 188, 0.34);
}

.cadet-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.complete-mark {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #704d13;
  background: #fff2c9;
}

.complete-mark.is-done {
  color: #0b655e;
  background: #dff5ee;
}

@media (max-width: 980px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 320px;
  }

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

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .login-view {
    min-height: calc(100vh - 28px);
    gap: 14px;
  }

  .login-panel {
    padding: 22px;
  }

  h1 {
    font-size: 1.9rem;
  }

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

  .coach-card {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 14px;
    min-height: 138px;
  }

  .coach-image {
    height: 138px;
  }

  .coach-image img {
    width: 122px;
    height: 122px;
  }

  .coach-image .red-hat {
    top: 10px;
    left: 52px;
    width: 42px;
    height: 24px;
  }

  .coach-copy {
    padding: 16px 14px 16px 0;
  }

  .mission-panel,
  .cadet-section {
    padding: 16px;
  }

  .utility-strip {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .section-heading p {
    text-align: left;
  }

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

  .avatar-stage {
    height: 176px;
  }
}
