:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-gradient: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 50%, #94a3b8 100%);
  --card-bg: rgba(255, 255, 255, 0.92);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-sans);
  touch-action: manipulation;
}

/* === System Corporate UI Overlay === */
#ai-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#ai-ui.active {
  opacity: 1;
  pointer-events: auto;
}

/* === Top Header Bar === */
.system-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-logo {
  height: 44px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.stock-ticker {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  line-height: 1.25;
}

.ticker-symbol {
  font-weight: 700;
  color: var(--text-main);
}

.ticker-up {
  color: var(--success);
  font-weight: 700;
}

.ticker-status {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.role-pill {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
}

.score-pill {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
}

.high-pill {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.strikes-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.strikes-label {
  font-weight: bold;
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.strikes-icons {
  letter-spacing: 2px;
  white-space: nowrap;
}

.header-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.header-btn:hover {
  background: #e2e8f0;
}

.header-btn.active {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* === Screens Common === */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.screen.active {
  display: flex;
}

/* === Welcome Card (Main Menu) === */
.welcome-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.1);
  padding: 36px 40px;
  max-width: 780px;
  width: 100%;
  text-align: center;
  margin: auto;
  animation: fadeInScale 0.35s ease-out;
}

.card-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.portal-hero-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 10px 0 28px 0;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
  text-align: left;
}

.onboarding-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s;
}

.onboarding-box:hover {
  transform: translateY(-2px);
}

.box-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.onboarding-box h3 {
  font-size: 1.05rem;
  color: #1e293b;
  margin-bottom: 6px;
  font-weight: 700;
}

.onboarding-box p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.menu-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tech-btn {
  padding: 16px 36px;
  border: none;
  border-radius: 14px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.tech-btn.primary-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #ffffff;
}

.tech-btn.secondary-btn {
  background: #f1f5f9;
  color: #1e293b;
  border: 2px solid #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.tech-btn.secondary-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.tech-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.3);
}

.tech-btn:active {
  transform: translateY(1px);
}

.corporate-fine-print {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 22px;
}

/* === Intermission Box === */
.intermission-box {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  padding: 36px 44px;
  text-align: center;
  max-width: 580px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
}

.intermission-icon {
  font-size: 3.5rem;
  margin-bottom: 10px;
  animation: pulse 1s infinite alternate;
}

.intermission-status {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.command-highlight {
  display: inline-block;
  background: #0f172a;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 10px 24px;
  border-radius: 12px;
  margin: 18px 0;
  border: 1px solid #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
}

.progress-bar-container {
  width: 100%;
  height: 18px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 8px 0;
  border: 2px solid #cbd5e1;
}

#load-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.05s linear;
}

.subtext-loading {
  font-size: 0.75rem;
  color: #64748b;
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

/* === Exit Interview (Game Over) === */
.exit-card {
  background: #ffffff;
  border: 3px solid #ef4444;
  border-radius: 24px;
  padding: 36px 40px;
  max-width: 620px;
  width: 90%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(239, 68, 68, 0.2);
  position: relative;
  overflow: hidden;
}

.exit-stamp {
  position: absolute;
  top: 24px;
  right: -24px;
  background: transparent;
  color: #ef4444;
  font-size: 1.1rem;
  font-weight: 900;
  border: 4px solid #ef4444;
  padding: 6px 36px;
  border-radius: 8px;
  transform: rotate(18deg);
  letter-spacing: 2px;
  opacity: 0.85;
  pointer-events: none;
}

.fatal-title {
  color: #ef4444;
  font-size: 2.2rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.fatal-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.summary-tile {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 8px;
}

.tile-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.tile-val {
  font-size: 1.3rem;
  font-weight: 900;
  color: #0f172a;
}

.manager-remark {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #991b1b;
  font-size: 0.9rem;
  text-align: left;
  margin-bottom: 24px;
}

/* === Practice Modal === */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: 20px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 28px 32px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #94a3b8;
}

.close-btn:hover {
  color: #0f172a;
}

.practice-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.practice-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.15s;
}

.practice-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.tech-btn-small {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

/* === Microgame Container === */
#module-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 1;
  display: none;
}

#module-container.active {
  display: block;
}

/* === Utility Animations === */
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.info-text { color: var(--primary); }

.blink {
  animation: blinkAnim 0.75s infinite alternate;
}

@keyframes blinkAnim {
  from { opacity: 1; }
  to { opacity: 0.35; }
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes alienWiggle {
  from { transform: rotate(-6deg) scale(0.95); }
  to { transform: rotate(6deg) scale(1.05); }
}

.shake {
  animation: screenShake 0.45s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes screenShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .system-header {
    padding: 6px 10px;
    gap: 6px;
  }
  .header-left {
    gap: 6px;
  }
  .company-logo {
    height: 26px;
  }
  .stock-ticker {
    font-size: 0.68rem;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
  }
  .ticker-status {
    display: none;
  }
  .header-right {
    gap: 5px;
  }
  .hud-pill {
    padding: 4px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
  }
  .strikes-wrapper {
    padding: 4px 7px;
    font-size: 0.74rem;
  }
  .strikes-icons {
    letter-spacing: 0px;
  }
  .header-btn {
    padding: 5px 8px;
    font-size: 0.74rem;
    white-space: nowrap;
  }
  #btn-fullscreen {
    display: none;
  }
  .screen {
    padding: 8px 10px;
    justify-content: flex-start;
  }
  .welcome-card {
    padding: 14px 14px;
    border-radius: 16px;
    margin: auto 0;
  }
  .card-badge {
    font-size: 0.64rem;
    padding: 3px 10px;
    margin-bottom: 4px;
  }
  .portal-hero-title {
    font-size: clamp(1.22rem, 5vw, 1.75rem);
    line-height: 1.15;
  }
  .hero-subtitle {
    font-size: 0.8rem;
    margin: 4px 0 10px 0;
    line-height: 1.25;
  }
  .onboarding-grid {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
  }
  .onboarding-box {
    padding: 8px 10px;
    border-radius: 12px;
    display: grid;
    grid-template-columns: 32px 1fr;
    column-gap: 10px;
    row-gap: 1px;
    align-items: center;
  }
  .box-icon {
    grid-row: 1 / 3;
    font-size: 1.5rem;
    margin-bottom: 0;
    text-align: center;
    line-height: 1;
  }
  .onboarding-box h3 {
    grid-column: 2;
    font-size: 0.88rem;
    margin-bottom: 0;
  }
  .onboarding-box p {
    grid-column: 2;
    font-size: 0.75rem;
    line-height: 1.25;
  }
  .menu-actions {
    gap: 7px;
  }
  .tech-btn {
    padding: 11px 16px;
    font-size: 0.9rem;
    border-radius: 12px;
    width: 100%;
  }
  .tech-btn.secondary-btn {
    padding: 9px 14px;
    font-size: 0.82rem;
  }
  .corporate-fine-print {
    font-size: 0.62rem;
    margin-top: 8px;
    line-height: 1.2;
  }
  .intermission-box {
    padding: 24px 18px;
    width: 95%;
    margin: auto 0;
  }
  .intermission-icon {
    font-size: 2.6rem;
  }
  .intermission-status {
    font-size: 1.4rem;
  }
  .command-highlight {
    font-size: 1.1rem;
    padding: 8px 16px;
    margin: 12px 0;
  }
  .exit-card {
    padding: 24px 16px;
    width: 96%;
    margin: auto 0;
  }
  .exit-stamp {
    top: 14px;
    right: -28px;
    font-size: 0.8rem;
    padding: 4px 28px;
  }
  .fatal-title {
    font-size: 1.6rem;
  }
  .stats-summary-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }
  .summary-tile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
  }
  .tile-label {
    margin-bottom: 0;
  }
  .tile-val {
    font-size: 1.05rem;
  }
  .modal-backdrop {
    padding: 10px;
  }
  .modal-card {
    padding: 18px 16px;
    max-height: 90dvh;
  }
  .practice-card {
    padding: 10px 12px;
    gap: 10px;
  }
}

@media (max-width: 540px) {
  .header-center {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .hud-pill {
    flex: 1;
    text-align: center;
    padding: 4px 6px;
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .strikes-label,
  .header-btn .btn-label {
    display: none;
  }
}
