.if-shell {
  --if-space: #050a16;
  --if-line: #1b2b47;
  --if-ink: #dcefff;
  --if-muted: #7f9cba;
  --if-teal: #6ff2d0;
  --if-amber: #ffd166;
  --if-red: #ff5d73;
  --if-magenta: #ff86d6;
  --if-focus: rgba(111, 242, 208, 0.7);
  --if-banner-line: rgba(111, 242, 208, 0.32);
  --if-banner-bg: rgba(5, 11, 24, 0.82);
  --if-overlay: rgba(3, 7, 16, 0.72);
  width: 100%;
  max-width: 760px;
  min-width: 0;
  margin: 0 auto;
  padding: 0 12px 12px;
  overflow-x: hidden;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.if-top {
  display: flex;
  flex-nowrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}

.if-stats {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.if-stat {
  flex: 1 1 0;
  min-width: 62px;
  padding: 6px 8px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  box-shadow: 0 6px 16px rgba(12, 26, 48, 0.12);
  text-align: center;
}

.if-stat span {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-transform: uppercase;
}

.if-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--cg-ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.15;
}

.if-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.if-btn,
.if-close {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(12, 26, 48, 0.12);
  -webkit-tap-highlight-color: transparent;
}

.if-btn:hover,
.if-close:hover {
  border-color: var(--if-teal);
}

.if-btn:focus-visible,
.if-close:focus-visible,
.if-canvas:focus-visible {
  outline: 3px solid var(--if-focus);
  outline-offset: 2px;
}

.if-icon {
  padding: 0;
  font-size: 18px;
}

.if-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.if-primary {
  border-color: transparent;
  background: var(--if-teal);
  color: #05202a;
}

.if-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--if-line);
  border-radius: 14px;
  background: var(--if-space);
  box-shadow: 0 0 0 1px rgba(111, 242, 208, 0.12), 0 14px 40px rgba(5, 12, 40, 0.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.if-stage::after {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0) 3px
  );
  content: "";
  pointer-events: none;
}

.if-canvas {
  display: block;
  width: 100%;
  height: 560px;
  background: var(--if-space);
  cursor: crosshair;
  touch-action: none;
}

.if-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 6px;
  width: min(88%, 420px);
  padding: 16px 18px;
  border: 1px solid var(--if-banner-line);
  border-radius: 12px;
  background: var(--if-banner-bg);
  color: var(--if-ink);
  text-align: center;
  box-shadow: 0 0 34px rgba(20, 90, 140, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.if-banner strong {
  color: var(--if-teal);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.05;
  text-transform: uppercase;
}

.if-banner span {
  color: var(--if-muted);
  font-size: 14px;
  line-height: 1.35;
}

.if-result {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 18px;
  background: rgba(4, 9, 20, 0.9);
  color: var(--if-ink);
  text-align: center;
}

.if-kicker {
  color: var(--if-red);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.if-final {
  color: var(--if-teal);
  font-size: 40px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
}

.if-sub,
.if-rank {
  margin: 0;
  color: var(--if-muted);
  font-size: 14px;
  line-height: 1.3;
}

.if-rank {
  color: var(--if-amber);
  font-weight: 800;
}

.if-result-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.if-result-row .if-btn {
  flex: 1 1 0;
  border-color: rgba(220, 239, 255, 0.25);
  background: rgba(220, 239, 255, 0.1);
  color: var(--if-ink);
}

.if-result-row .if-primary {
  border-color: transparent;
  background: var(--if-teal);
  color: #05202a;
}

.if-legend {
  margin: 10px 0 0;
  color: var(--cg-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.if-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--if-overlay);
}

.if-modal-card {
  position: relative;
  width: min(100%, 460px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px 22px 24px;
  border: 1px solid var(--if-line);
  border-radius: 16px;
  background: var(--cg-panel);
  box-shadow: var(--cg-shadow);
  color: var(--cg-ink);
}

.if-modal-card h2 {
  margin: 0 0 10px;
  color: var(--cg-ink);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.if-modal-card p {
  margin: 0 0 10px;
  color: var(--cg-muted);
  font-size: 14px;
  line-height: 1.5;
}

.if-modal-card p:last-child {
  margin-bottom: 0;
}

.if-close {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.if-is-hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .if-shell {
    padding: 0 8px 8px;
  }

  .if-top {
    flex-wrap: nowrap;
    gap: 4px;
    margin-bottom: 6px;
  }

  .if-stats {
    gap: 4px;
  }

  .if-stat-best {
    display: none;
  }

  .if-stat {
    min-width: 0;
    padding: 4px 4px;
  }

  .if-stat span {
    font-size: 9px;
  }

  .if-stat strong {
    font-size: 15px;
  }

  .if-actions {
    gap: 4px;
  }

  .if-legend {
    display: none;
  }

  .if-final {
    font-size: 34px;
  }
}

@media (pointer: coarse) {
  .if-legend {
    display: none;
  }
}
