:root {
  --cm-bg: #020502;
  --cm-panel: #0a0f0a;
  --cm-line: rgba(74, 246, 38, 0.2);
  --cm-green: #4af626;
  --cm-white: #ffffff;
  --cm-danger: #dc2626;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--cm-bg);
  color: var(--cm-green);
  font-family: 'IBM Plex Mono', monospace;
  overflow-x: hidden;
}

button,
canvas {
  font: inherit;
}

#app {
  min-height: 100vh;
}

.cm-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.cm-shell--glitch {
  filter: hue-rotate(15deg) blur(0.5px);
}

.cm-device {
  position: relative;
  width: min(100%, 400px);
  height: 780px;
  background: var(--cm-panel);
  border: 12px solid #222;
  border-radius: 3.5rem;
  box-shadow: 0 0 100px rgba(0, 0, 0, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--cm-green);
}

.cm-device--glitch {
  transform: translateX(1px);
}

.cm-crt-lines,
.cm-crt-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cm-crt-lines {
  z-index: 100;
  opacity: 0.07;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 3px, 3px 100%;
}

.cm-crt-vignette {
  z-index: 90;
  background: radial-gradient(circle at center, rgba(74, 246, 38, 0.04) 0%, transparent 90%);
}

.cm-screen__boot,
.cm-status,
.cm-content,
.cm-footer,
.cm-modal {
  position: relative;
  z-index: 1;
}

.cm-screen__boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 48px;
  text-align: center;
}

.cm-boot__cpu {
  opacity: 0.8;
}

.cm-boot__title {
  margin: 0;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.1em;
}

.cm-boot__subtitle {
  margin: 12px 0 0;
  font-size: 10px;
  opacity: 0.4;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.cm-boot__button,
.cm-decode-button,
.cm-blocked__button,
.cm-nav-button,
.cm-modal__header button {
  border: 0;
  background: transparent;
  color: inherit;
}

.cm-boot__button {
  width: 100%;
  padding: 20px 16px;
  border: 2px solid var(--cm-green);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: all 160ms ease;
}

.cm-boot__button:hover,
.cm-decode-button:hover,
.cm-nav-button:hover,
.cm-blocked__button:hover,
.cm-modal__header button:hover {
  background: var(--cm-green);
  color: #000;
}

.cm-status {
  padding: 24px 24px 0;
  border-bottom: 1px solid var(--cm-line);
  background: rgba(13, 20, 13, 0.4);
}

.cm-status__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
}

.cm-status__right {
  text-align: right;
}

.cm-status__label {
  font-size: 9px;
  opacity: 0.4;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.cm-status__value {
  font-size: 20px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.04em;
}

.cm-status__value--energy {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.cm-status__energy-number {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--cm-green);
  font-style: italic;
}

.cm-status__energy-unit {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.9;
  font-style: italic;
}

.cm-status__value span {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.6;
}

.cm-energy-bar {
  height: 6px;
  background: rgba(74, 246, 38, 0.1);
  border: 1px solid rgba(74, 246, 38, 0.3);
  overflow: hidden;
}

.cm-energy-bar span,
.cm-progress span {
  display: block;
  height: 100%;
  background: var(--cm-green);
  box-shadow: 0 0 10px var(--cm-green);
}

.cm-status__hint {
  margin: 12px 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  opacity: 0.4;
  font-style: italic;
}

.cm-status__economy {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.cm-economy-chip {
  padding: 10px 8px;
  border: 1px solid rgba(74, 246, 38, 0.18);
  background: rgba(74, 246, 38, 0.05);
  display: grid;
  gap: 4px;
  text-align: center;
}

.cm-economy-chip strong {
  font-size: 14px;
  color: var(--cm-white);
}

.cm-economy-chip span {
  font-size: 9px;
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cm-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow: hidden;
  position: relative;
}

.cm-main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cm-main-view--upgrades {
  animation: fadeIn 500ms ease;
}

.cm-main-view--archive {
  animation: fadeIn 500ms ease;
}

.cm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(74, 246, 38, 0.1);
  text-transform: uppercase;
}

.cm-section-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.cm-section-code {
  font-size: 9px;
  opacity: 0.3;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.cm-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
  padding-right: 12px;
  padding-bottom: 128px;
}

.cm-terminal-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cm-terminal-layout .cm-scroll {
  padding-bottom: 24px;
}

.cm-terminal-action-slot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(74, 246, 38, 0.1);
  background: linear-gradient(180deg, rgba(10, 15, 10, 0), rgba(10, 15, 10, 0.92) 20%);
}

.cm-stage-summary {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(74, 246, 38, 0.12);
  background: rgba(74, 246, 38, 0.04);
  font-size: 11px;
  line-height: 1.6;
  opacity: 0.8;
}

.cm-story-card {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-left: 1px solid rgba(74, 246, 38, 0.24);
  background: rgba(74, 246, 38, 0.03);
  transition: all 220ms ease;
}

.cm-story-card--active {
  border-left-color: var(--cm-green);
  background: rgba(74, 246, 38, 0.06);
}

.cm-story-card--past {
  opacity: 0.2;
}

.cm-story-card--critical {
  border-left-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.cm-story-card__eyebrow,
.cm-critical-panel__eyebrow,
.cm-subsection-title {
  margin-bottom: 8px;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.45;
}

.cm-story-card__title,
.cm-critical-panel h3,
.cm-ending-panel h3,
.cm-upgrade-card h4 {
  margin: 0 0 10px;
  color: var(--cm-white);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.cm-story-card__body,
.cm-critical-panel p,
.cm-ending-panel__body p,
.cm-events__list p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}

.cm-story-card__body--critical {
  opacity: 0.92;
}

.cm-story-card__reward {
  margin-top: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

.cm-blocked {
  padding: 20px;
  border: 2px solid var(--cm-danger);
  background: rgba(69, 10, 10, 0.2);
  color: #ef4444;
  font-size: 11px;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.15);
}

.cm-blocked,
.cm-critical-panel,
.cm-ending-panel,
.cm-upgrades,
.cm-events {
  margin-top: 18px;
}

.cm-blocked__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-style: italic;
}

.cm-blocked__meta {
  margin-bottom: 12px;
  font-size: 10px;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.cm-critical-panel,
.cm-ending-panel,
.cm-upgrades,
.cm-events {
  padding: 16px;
  border: 1px solid rgba(74, 246, 38, 0.12);
  background: rgba(74, 246, 38, 0.03);
}

.cm-critical-panel__actions,
.cm-ending-choice-list,
.cm-upgrade-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.cm-secondary-button,
.cm-upgrade-card__button,
.cm-ending-choice {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--cm-green);
  background: rgba(74, 246, 38, 0.04);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 160ms ease;
}

.cm-secondary-button:hover,
.cm-upgrade-card__button:hover,
.cm-ending-choice:hover {
  background: var(--cm-green);
  color: #000;
}

.cm-secondary-button:disabled,
.cm-upgrade-card__button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cm-ending-choice {
  display: grid;
  gap: 8px;
}

.cm-ending-choice strong {
  font-size: 12px;
  letter-spacing: 0.08em;
}

.cm-ending-choice span {
  font-size: 11px;
  line-height: 1.6;
  opacity: 0.8;
}

.cm-ending-panel__body {
  display: grid;
  gap: 12px;
}

.cm-upgrade-card {
  padding: 12px;
  border: 1px solid rgba(74, 246, 38, 0.1);
  background: rgba(0, 0, 0, 0.16);
}

.cm-upgrade-card--locked {
  opacity: 0.55;
}

.cm-upgrade-card__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.cm-upgrade-card__top p {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  opacity: 0.72;
}

.cm-upgrade-card__top span {
  font-size: 10px;
  opacity: 0.5;
}

.cm-upgrade-card__effect {
  margin-bottom: 10px;
  font-size: 10px;
  line-height: 1.6;
  opacity: 0.78;
}

.cm-events__list {
  display: grid;
  gap: 8px;
}

.cm-events__list p {
  font-size: 11px;
  opacity: 0.76;
}

.cm-upgrade-scroll {
  padding-bottom: 32px;
}

.cm-blocked p {
  margin: 0 0 12px;
  line-height: 1.6;
  opacity: 0.8;
}

.cm-blocked__button {
  width: 100%;
  padding: 8px 12px;
  background: #dc2626;
  color: #000;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.cm-decode-panel {
  padding-top: 4px;
}

.cm-decode-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.cm-decode-panel__header span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cm-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cm-progress {
  height: 4px;
  background: rgba(74, 246, 38, 0.2);
}

.cm-decode-button {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--cm-green);
  background: rgba(74, 246, 38, 0.05);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  cursor: pointer;
  transition: all 160ms ease;
}

.cm-archive-scroll {
  padding-bottom: 40px;
}

.cm-archive-entry {
  margin-bottom: 32px;
  padding-left: 16px;
  border-left: 1px solid rgba(74, 246, 38, 0.2);
}

.cm-archive-entry h3 {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.cm-archive-entry__body {
  display: grid;
  gap: 12px;
  opacity: 0.6;
  font-size: 13px;
  font-style: italic;
}

.cm-archive-entry__critical {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed rgba(74, 246, 38, 0.18);
}

.cm-archive-entry__critical strong {
  display: block;
  margin-bottom: 6px;
  color: var(--cm-white);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.cm-archive-entry__body p,
.cm-modal__footer {
  line-height: 1.65;
}

.cm-archive-empty {
  margin-top: 80px;
  text-align: center;
  font-size: 10px;
  opacity: 0.3;
  font-style: italic;
}

.cm-footer {
  padding: 28px;
  border-top: 1px solid var(--cm-line);
  background: rgba(13, 20, 13, 0.8);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.cm-nav-button {
  padding: 16px 8px;
  border: 1px solid var(--cm-green);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 160ms ease;
}

.cm-nav-button--active {
  background: var(--cm-green);
  color: #000;
  box-shadow: 0 0 20px rgba(74, 246, 38, 0.4);
}

.cm-nav-button--selected {
  background: rgba(74, 246, 38, 0.3);
}

.cm-nav-button--danger {
  border-color: #ef4444;
  background: #dc2626;
  color: #000;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
}

.cm-nav-button--disabled {
  opacity: 0.1;
  filter: grayscale(1);
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.2);
}

.cm-modal {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.98);
  display: flex;
  flex-direction: column;
  padding: 32px;
  animation: fadeZoom 300ms ease;
}

.cm-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(74, 246, 38, 0.2);
}

.cm-modal__header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.4em;
}

.cm-modal__header button {
  padding: 8px;
  color: rgba(74, 246, 38, 0.5);
  cursor: pointer;
}

.cm-modal__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cm-modal__footer {
  margin-top: 40px;
  padding: 16px;
  border: 1px solid rgba(74, 246, 38, 0.1);
  text-align: center;
  font-size: 9px;
  opacity: 0.4;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.shooter {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.shooter__meta {
  width: 100%;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(74, 246, 38, 0.2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.shooter canvas {
  background: #000;
  border: 1px solid rgba(74, 246, 38, 0.4);
  cursor: none;
  touch-action: none;
  box-shadow: 0 0 20px rgba(74, 246, 38, 0.15);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  transform-origin: center center;
}

.icon--xl {
  width: 72px;
  height: 72px;
}

.spin {
  animation: spin 1s linear infinite;
  will-change: transform;
}

.pulse-soft {
  animation: pulseSoft 2s ease-in-out infinite;
}

.bounce-soft {
  animation: bounceSoft 1s ease-in-out infinite;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 3px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(74, 246, 38, 0.02);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(74, 246, 38, 0.3);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(74, 246, 38, 0.5);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

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

@keyframes fadeZoom {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 440px) {
  .cm-device {
    height: 100vh;
    border-radius: 0;
    border-width: 0;
  }

  .cm-footer {
    gap: 10px;
    padding: 20px;
  }

  .cm-content,
  .cm-status {
    padding-left: 18px;
    padding-right: 18px;
  }
}
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.control,
.control-danger {
  width: 100%;
  min-height: 94px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  padding: 18px;
}

.control strong,
.control-danger strong {
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control span,
.control-danger span {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.control--active {
  background: linear-gradient(180deg, rgba(140, 240, 255, 0.18), rgba(25, 88, 108, 0.4));
}

.control--disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.control-danger {
  border-color: rgba(255, 106, 122, 0.55);
  background: linear-gradient(180deg, rgba(255, 106, 122, 0.22), rgba(72, 17, 26, 0.45));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(1, 3, 8, 0.84);
  backdrop-filter: blur(12px);
}

.modal__card {
  width: min(720px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 30px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(8, 13, 20, 0.97), rgba(6, 9, 14, 0.98));
  box-shadow: var(--shadow);
}

.modal__header button {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 24px;
}

.modal__hint {
  margin-top: 20px;
  color: var(--text-dim);
  line-height: 1.6;
}

.shooter {
  display: grid;
  gap: 16px;
  justify-items: center;
}

.shooter__meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shooter canvas {
  width: min(100%, 480px);
  max-width: 480px;
  height: auto;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: #02050a;
  touch-action: none;
}

.footer-note {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 6px 0 4px;
}

@media (max-width: 980px) {
  .boot,
  .dashboard__header,
  .dashboard__content {
    grid-template-columns: 1fr;
    display: grid;
  }

  .boot__hero {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }

  .boot__hero,
  .boot__sidebar,
  .dashboard,
  .brand,
  .chapter,
  .aside,
  .modal__card {
    padding: 18px;
  }

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

  .boot__title {
    font-size: 44px;
  }
}