:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1726;
  color: #f8fbff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #0d1726;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  overflow: hidden;
  background: #07111f;
  user-select: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  top: clamp(16px, 3vw, 32px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 96px;
  padding: 14px 20px;
  border: 1px solid rgba(147, 197, 253, 0.46);
  border-radius: 18px;
  width: min(1240px, calc(100% - 24px));
  background: rgba(7, 17, 31, 0.86);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.32), inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  transition: opacity 160ms ease;
}

.release-meter {
  flex: 1 1 65%;
  min-width: 360px;
  padding: 3px 5px;
  border-radius: 12px;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

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

.release-meter__title {
  color: #dbeafe;
  font-size: 1.15rem;
  font-weight: 950;
  letter-spacing: 0.18em;
}

#deadlineValue {
  color: #86efac;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 950;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.release-meter__track {
  height: 25px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
}

#deadlineBar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #86efac);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.5);
  transform-origin: left center;
  transition: width 120ms linear, background 180ms ease;
}

.release-meter--warning #deadlineBar {
  background: linear-gradient(90deg, #f97316, #fbbf24);
}

.release-meter--danger #deadlineBar {
  background: linear-gradient(90deg, #dc2626, #fb7185);
}

.release-meter--danger {
  animation: release-danger-pulse 1.15s ease-in-out infinite;
}

.release-meter--danger .release-meter__track {
  border-color: rgba(251, 113, 133, 0.85);
  box-shadow: 0 0 22px rgba(244, 63, 94, 0.36);
}

@keyframes release-danger-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.16); }
}

.hud--hidden {
  opacity: 0;
  pointer-events: none;
}

.hud__distance {
  display: grid;
  justify-items: end;
  min-width: 116px;
}

.hud__status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.hud__lives {
  color: #fb7185;
  font-size: clamp(1.45rem, 2.7vw, 2rem);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 10px rgba(251, 113, 133, 0.35);
  white-space: nowrap;
}

.hud__label {
  color: #bed2e5;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#workTimeValue {
  margin-top: 2px;
  font-size: clamp(1.75rem, 3.3vw, 2.5rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.event-feed {
  --laptop-rise: 110px;
  position: absolute;
  top: 160px;
  left: 28%;
  z-index: 3;
  display: grid;
  justify-items: start;
  gap: 8px;
  width: min(390px, calc(100% - 24px));
  pointer-events: none;
  transition: left 35ms linear, top 35ms linear;
}

.event-card {
  --card-accent: #60a5fa;
  width: min(350px, 100%);
  padding: 12px 16px 15px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--card-accent) 70%, white 12%);
  border-left: 6px solid var(--card-accent);
  border-radius: 14px;
  background: rgba(8, 18, 32, 0.96);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38), 0 0 24px color-mix(in srgb, var(--card-accent) 18%, transparent);
  color: #f8fafc;
  transform-origin: 0 100%;
  animation: event-card-in 300ms cubic-bezier(0.18, 1.45, 0.35, 1) both;
}

.event-card--high {
  width: min(380px, 100%);
  padding: 14px 18px 17px;
}

.event-card--leaving {
  animation: event-card-out 260ms ease both;
}

.event-card__label {
  margin: 0 0 7px;
  color: var(--card-accent);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.event-card__message {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 850;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.event-card--high .event-card__message {
  font-size: clamp(1.9rem, 3.5vw, 2.65rem);
}

.event-card--bug { --card-accent: #f87171; }
.event-card--meet { --card-accent: #60a5fa; }
.event-card--urgent { --card-accent: #fb923c; }
.event-card--alert { --card-accent: #fb7185; }
.event-card--success { --card-accent: #4ade80; }
.event-card--deadline { --card-accent: #f43f5e; }

@keyframes event-card-in {
  0% { opacity: 0; transform: translate(-34px, var(--laptop-rise)) scale(0.18) rotate(-4deg); filter: brightness(2); }
  62% { opacity: 1; transform: translate(0, -7px) scale(1.08) rotate(0.6deg); filter: brightness(1.18); }
  100% { opacity: 1; transform: translate(0, 0) scale(1); filter: brightness(1); }
}

@keyframes event-card-out {
  to { opacity: 0; transform: translateY(-22px) scale(0.92); }
}

.debug-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 4;
  min-width: 230px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(74, 222, 128, 0.55);
  border-radius: 8px;
  background: rgba(4, 18, 12, 0.86);
  color: #86efac;
  font: 700 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
  white-space: pre-wrap;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 16, 29, 0.38);
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: clamp(28px, 6vw, 48px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  background: rgba(13, 23, 38, 0.92);
  box-shadow: 0 24px 80px rgba(5, 12, 22, 0.38);
  text-align: center;
  backdrop-filter: blur(14px);
}

.panel__eyebrow {
  margin: 0 0 10px;
  color: #60a5fa;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel h1,
.panel h2 {
  margin: 0;
  font-size: clamp(2.4rem, 10vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.panel__subtitle {
  margin: 12px 0 24px;
  color: #93c5fd;
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-weight: 750;
}

.panel__message {
  margin: 22px auto 26px;
  color: #c9d8e8;
  line-height: 1.55;
}

.rules {
  display: grid;
  gap: 9px;
  margin: 0 0 26px;
  padding: 0;
  color: #c9d8e8;
  line-height: 1.4;
  list-style: none;
  text-align: left;
}

.rules li::before {
  content: "•";
  margin-right: 10px;
  color: #60a5fa;
}

.button {
  min-width: 170px;
  padding: 13px 24px;
  border: 0;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.38);
  transition: transform 120ms ease, background 120ms ease;
}

.button:hover {
  background: #3b82f6;
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 3px solid #bfdbfe;
  outline-offset: 4px;
}

.button--secondary {
  background: #334155;
  box-shadow: none;
}

.button--secondary:hover {
  background: #475569;
}

.panel__actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.diagnosis {
  margin: 18px auto;
  color: #fbbf24;
  font-weight: 800;
}

.result-reason {
  margin: -8px 0 18px;
  color: #fca5a5;
  font-size: 1.05rem;
  font-weight: 850;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 24px;
}

.result-grid div {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.result-grid dt {
  color: #8fa7bd;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-grid dd {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.panel__hint {
  margin: 18px 0 0;
  color: #7f96ad;
  font-size: 0.78rem;
}

@media (max-height: 520px) {
  .panel {
    padding: 22px 30px;
  }

  .panel__hint {
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  .result-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 24px 20px;
  }
}

@media (max-width: 620px) {
  .hud {
    width: calc(100% - 24px);
    flex-wrap: wrap;
    gap: 10px;
  }

  .release-meter {
    flex-basis: 100%;
    min-width: 0;
  }

  .hud__status {
    gap: 5px;
    padding-left: 10px;
  }

  .event-feed {
    top: 206px;
    left: 12px;
    width: calc(100% - 24px);
  }

  .event-card,
  .event-card--high {
    width: min(360px, 100%);
    padding: 13px 15px 15px;
  }

  .event-card__message,
  .event-card--high .event-card__message {
    font-size: 1.48rem;
  }
}
