:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #607086;
  --line: #d7dee8;
  --paper: #ffffff;
  --field: #ecfccb;
  --track: #fef3c7;
  --accent: #047857;
  --accent-2: #2563eb;
  --danger: #dc2626;
  --panel: rgba(255, 255, 255, 0.86);
  --shadow: 0 22px 55px rgba(24, 35, 58, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  align-items: flex-start;
  background:
    linear-gradient(120deg, rgba(4, 120, 87, 0.10), transparent 34%),
    linear-gradient(240deg, rgba(37, 99, 235, 0.10), transparent 36%),
    linear-gradient(180deg, #eef6f8 0%, #f7fafc 46%, #e9eef5 100%);
  color: var(--ink);
  display: flex;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

.game-shell {
  max-width: 1120px;
  width: min(100%, 1120px);
}

.topbar {
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(24, 35, 58, 0.10);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 {
  color: #101827;
  font-size: clamp(28px, 3.6vw, 46px);
  letter-spacing: 0;
  line-height: 0.98;
  margin: 0;
  max-width: 760px;
}

.mission-goal {
  color: #42526a;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  margin: 10px 0 0;
  max-width: 620px;
}

.stats {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 430px;
}

.stats span,
.key {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.88));
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  box-shadow:
    0 10px 24px rgba(24, 35, 58, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  gap: 8px;
  padding: 9px 13px;
}

.stats strong {
  color: var(--ink);
  font-family: "Segoe UI Mono", "Cascadia Mono", "Courier New", monospace;
  font-size: 16px;
}

#level {
  min-width: 82px;
  text-align: left;
}

.stage-wrap {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid rgba(100, 116, 139, 0.28);
  border-radius: 8px;
  box-shadow:
    0 28px 80px rgba(24, 35, 58, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  overflow: hidden;
  position: relative;
}

canvas {
  display: block;
  height: auto;
  width: 100%;
}

.overlay {
  align-items: center;
  background: rgba(248, 250, 252, 0.80);
  backdrop-filter: blur(4px);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
  position: absolute;
  text-align: center;
}

.overlay.is-hidden {
  display: none;
}

.stage-actions {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}

.game-action {
  background: linear-gradient(135deg, #172033, #2563eb);
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  box-shadow:
    0 14px 30px rgba(37, 99, 235, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  color: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 15px;
  min-width: 96px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.game-action:hover {
  box-shadow:
    0 18px 36px rgba(37, 99, 235, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.30);
  transform: translateY(-1px);
}

.game-action[aria-pressed="true"],
.game-action-danger {
  background: linear-gradient(135deg, #991b1b, #ef4444);
  border-color: rgba(254, 202, 202, 0.75);
  color: #fff;
}

.game-action-danger:hover {
  box-shadow:
    0 18px 36px rgba(239, 68, 68, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.30);
}

.career-toast {
  --toast-accent: #047857;
  --toast-accent-2: #22c55e;
  --toast-bg: linear-gradient(135deg, rgba(236, 253, 245, 0.98), rgba(255, 255, 255, 0.94) 48%, rgba(209, 250, 229, 0.92));
  --toast-border: rgba(16, 185, 129, 0.52);
  --toast-shadow: rgba(6, 95, 70, 0.24);
  backdrop-filter: blur(14px);
  background: var(--toast-bg);
  border: 1px solid var(--toast-border);
  border-radius: 8px;
  box-shadow:
    0 22px 52px var(--toast-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  max-width: min(360px, calc(100% - 24px));
  opacity: 0;
  overflow: hidden;
  padding: 12px 14px 11px 20px;
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 12px;
  transform: translate(12px, -8px) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
  width: 360px;
  z-index: 3;
}

.career-toast::before {
  background: linear-gradient(180deg, var(--toast-accent), var(--toast-accent-2));
  bottom: 0;
  content: "";
  left: 0;
  position: absolute;
  top: 0;
  width: 6px;
}

.career-toast::after {
  background: radial-gradient(circle, var(--toast-accent-2), transparent 68%);
  border-radius: 999px;
  content: "";
  height: 112px;
  opacity: 0.18;
  position: absolute;
  right: -34px;
  top: -42px;
  width: 112px;
}

.career-toast > * {
  position: relative;
  z-index: 1;
}

.career-toast.is-visible {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.career-toast span {
  color: var(--toast-accent);
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.career-toast strong {
  color: var(--ink);
  display: block;
  font-size: clamp(15px, 1.8vw, 18px);
  line-height: 1.12;
}

.career-toast-mention {
  background:
    linear-gradient(135deg, var(--toast-accent), var(--toast-accent-2));
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  box-shadow:
    0 10px 22px var(--toast-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 8px;
  max-width: 100%;
  overflow: hidden;
  padding: 6px 10px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.career-toast p {
  color: #64748b;
  font-size: 12px;
  line-height: 1.3;
  margin: 8px 0 6px;
}

.career-toast em {
  color: #475569;
  display: block;
  font-size: 10px;
  font-style: normal;
  text-transform: uppercase;
}

.overlay p {
  color: #172033;
  font-family: "Segoe UI Mono", "Cascadia Mono", "Courier New", monospace;
  font-size: clamp(28px, 5vw, 50px);
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 12px;
  text-transform: uppercase;
}

.overlay span {
  color: #475569;
  display: block;
  font-size: clamp(14px, 2vw, 18px);
  line-height: 1.45;
  max-width: 620px;
}

.hud {
  align-items: center;
  backdrop-filter: blur(14px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(248, 250, 252, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  box-shadow:
    0 16px 36px rgba(24, 35, 58, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.80);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 14px;
  padding: 12px;
}

.tip {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.key {
  color: var(--ink);
  font-weight: 800;
  min-width: 42px;
  justify-content: center;
}

.roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.medals {
  align-items: center;
  display: flex;
  gap: 8px;
}

.medal {
  align-items: center;
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 rgba(15, 23, 42, 0.08);
  color: #64748b;
  display: inline-flex;
  font-family: "Courier New", monospace;
  font-size: 14px;
  font-weight: 700;
  height: 36px;
  justify-content: center;
  position: relative;
  width: 36px;
}

.medal::before {
  background: #94a3b8;
  border-radius: 0 0 3px 3px;
  content: "";
  height: 10px;
  left: 50%;
  position: absolute;
  top: -9px;
  transform: translateX(-50%);
  width: 16px;
}

.medal.is-earned {
  color: #111827;
  transform: translateY(-2px);
}

.medal[data-medal="bronze"].is-earned {
  background: #d97706;
  border-color: #92400e;
}

.medal[data-medal="silver"].is-earned {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.medal[data-medal="gold"].is-earned {
  background: #facc15;
  border-color: #ca8a04;
}

.roles span {
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  color: #075985;
  font-size: 13px;
  padding: 7px 10px;
}

.career-panel {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  margin-top: 16px;
}

.career-card,
.career-album {
  backdrop-filter: blur(16px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(248, 250, 252, 0.76));
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  box-shadow:
    0 20px 48px rgba(24, 35, 58, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
  padding: 16px;
}

.career-card span {
  color: var(--accent);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.career-card strong {
  display: block;
  font-size: 20px;
  line-height: 1.18;
}

.career-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 8px 0;
}

.career-card em {
  color: #475569;
  display: block;
  font-size: 12px;
  font-style: normal;
}

.career-album > div:first-child {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.career-album strong {
  font-size: 14px;
}

.career-album span {
  color: var(--muted);
  font-size: 12px;
}

.career-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 92px;
  overflow: auto;
}

.career-list span {
  background: linear-gradient(180deg, #ffffff, #eef6ff);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  color: #334155;
  font-size: 12px;
  box-shadow: 0 6px 14px rgba(24, 35, 58, 0.06);
  padding: 7px 10px;
}

@media (max-width: 760px) {
  body {
    padding: 14px;
  }

  .topbar,
  .hud,
  .career-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 14px;
  }

  .career-panel {
    display: flex;
  }

  .stats,
  .medals,
  .roles {
    justify-content: flex-start;
  }

  .tip {
    white-space: normal;
  }
}
