:root {
  --ink: #03050a;
  --panel: #101527;
  --panel-deep: #090d18;
  --blue: #4d89ff;
  --blue-soft: #9cc1ff;
  --text: #f4f7ff;
  --muted: #8c93a4;
  --line: #283451;
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--ink);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.page-shell {
  width: min(1320px, calc(100% - 64px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0 54px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0 48px;
  text-align: center;
}

.hero__meta {
  display: block;
  margin-bottom: 24px;
  color: #596784;
  font: 700 11px/1.4 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.22em;
}

.hero h1 {
  margin: 0;
  color: var(--blue-soft);
  font: 800 clamp(34px, 5vw, 62px)/1.1 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.08em;
  text-shadow: 0 0 24px rgba(77, 137, 255, 0.38);
}

.hero h1 span {
  margin-left: 12px;
  letter-spacing: 0;
}

.hero__copy {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.4vw, 18px);
  line-height: 1.7;
}

.progress {
  display: grid;
  width: min(360px, 80vw);
  gap: 10px;
  margin-top: 22px;
  color: #7184ae;
  font: 700 12px/1.3 "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.12em;
}

.progress__line {
  display: block;
  height: 2px;
  overflow: hidden;
  background: #182037;
}

.progress__line span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 240ms ease;
}

.blind-box-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px;
}

.blind-box {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 0.86;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  border: 5px solid var(--blue);
  border-radius: 22px;
  background: var(--panel);
  color: var(--text);
  box-shadow:
    0 0 0 1px rgba(132, 177, 255, 0.3),
    0 0 20px rgba(60, 126, 255, 0.32),
    inset 0 0 30px rgba(44, 83, 170, 0.08);
  transition:
    transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.blind-box:hover {
  transform: translateY(-5px) scale(1.015);
  border-color: #75a6ff;
  box-shadow:
    0 0 0 1px rgba(159, 194, 255, 0.48),
    0 0 32px rgba(77, 137, 255, 0.5),
    inset 0 0 30px rgba(44, 83, 170, 0.1);
}

.blind-box:active {
  transform: translateY(-1px) scale(0.98);
}

.blind-box:focus-visible,
.action-button:focus-visible,
.reset-button:focus-visible {
  outline: 3px solid #d7e6ff;
  outline-offset: 4px;
}

.blind-box img {
  width: min(104px, 48%);
  aspect-ratio: 1;
  border-radius: 28px;
  object-fit: cover;
  mix-blend-mode: screen;
  transition: opacity 180ms ease, transform 180ms ease;
}

.blind-box.is-opened {
  border-color: #35588f;
  background: var(--panel-deep);
  box-shadow: 0 0 14px rgba(55, 104, 193, 0.2);
}

.blind-box.is-opened img {
  opacity: 0.34;
  transform: scale(0.88);
}

.box-number {
  position: absolute;
  top: 14px;
  left: 16px;
  color: #6d82b1;
  font: 700 11px/1 "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.1em;
}

.box-state {
  position: absolute;
  right: 0;
  bottom: 14px;
  left: 0;
  color: #7181a6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.reset-button {
  display: block;
  width: min(360px, 100%);
  min-height: 52px;
  margin: 34px auto 0;
  border: 1px solid var(--blue);
  border-radius: 12px;
  background: #152247;
  color: #dce8ff;
  font-weight: 800;
}

.reset-button[hidden] {
  display: none;
}

footer {
  padding: 54px 0 0;
  color: #46516a;
  font: 12px/1.5 "SFMono-Regular", Consolas, monospace;
  text-align: center;
  letter-spacing: 0.06em;
}

.modal-layer {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: start center;
  padding: 34px;
  background: rgba(0, 0, 0, 0.86);
  animation: layer-in 180ms ease-out;
}

.modal-layer[hidden],
.result-view[hidden],
.opening-state[hidden] {
  display: none;
}

.modal-layer.is-closing {
  animation: layer-out 180ms ease-in forwards;
}

.modal-layer.is-closing .reveal-modal {
  animation: modal-out 180ms ease-in forwards;
}

.reveal-modal {
  width: min(620px, 100%);
  margin: auto 0;
  border: 6px solid var(--blue);
  border-radius: 10px;
  background: #050814;
  box-shadow: 0 0 34px rgba(77, 137, 255, 0.48);
  animation: modal-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.opening-state {
  display: grid;
  min-height: 440px;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #a9bfe8;
  font: 700 13px/1.4 "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.14em;
}

.opening-state img {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 36px;
  object-fit: cover;
  mix-blend-mode: screen;
  animation: mark-pulse 760ms ease-in-out infinite alternate;
}

.opening-state p {
  margin: 0;
}

.result-view {
  padding: 24px;
}

.result-card {
  display: grid;
  place-items: center;
  gap: 24px;
  padding: 32px 36px 28px;
  border: 4px solid var(--blue-soft);
  background: #242733;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.result-card__title {
  max-width: 100%;
  margin: 0;
  padding: 10px 28px;
  border-radius: 9px;
  background: #b8d4ff;
  color: #17345d;
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow:
    0 4px 0 #6fa7ff,
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.result-card__visual {
  width: min(360px, 100%);
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #25262d;
  box-shadow: inset 0 0 0 1px rgba(157, 193, 255, 0.12);
}

.result-card__visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.result-card__message {
  width: 100%;
  margin: 0;
  color: #f1f4ff;
  font-size: clamp(15px, 2.4vw, 19px);
  line-height: 1.8;
  text-align: center;
}

.result-card__date {
  padding: 11px 20px;
  border: 2px solid var(--blue);
  background: #1b294d;
  color: #c9dcff;
  font: 700 clamp(13px, 2.2vw, 17px)/1.2 "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
}

.result-card__brand {
  margin: -6px 0 0;
  color: #b8becd;
  font: 16px/1.2 "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
}

.result-actions {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px auto 0;
}

.action-button {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: #3569ec;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.action-button:hover,
.reset-button:hover {
  background: #2858d0;
}

@keyframes layer-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes layer-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(12px) scale(0.98); }
}

@keyframes mark-pulse {
  from { opacity: 0.48; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1.04); }
}

@media (max-width: 1080px) {
  .blind-box-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 32px, 620px);
    padding-top: 18px;
  }

  .hero {
    padding: 24px 0 32px;
  }

  .hero__meta {
    max-width: 58%;
    font-size: 8px;
    letter-spacing: 0.1em;
    text-align: right;
  }

  .hero h1 {
    font-size: clamp(25px, 8.4vw, 40px);
  }

  .hero h1 span {
    display: block;
    margin: 8px 0 0;
  }

  .blind-box-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .blind-box {
    padding: 18px;
    border-width: 4px;
    border-radius: 18px;
  }

  .modal-layer {
    align-items: start;
    padding: 18px 12px;
  }

  .reveal-modal {
    border-width: 5px;
    border-radius: 8px;
  }

  .result-view {
    padding: 12px;
  }

  .result-card {
    gap: 18px;
    padding: 22px 16px 20px;
  }

  .result-card__visual {
    width: min(320px, 100%);
  }

  .result-actions {
    gap: 10px;
  }
}

@media (max-width: 420px) {
  .page-shell {
    width: calc(100% - 24px);
  }

  .hero__meta {
    display: none;
  }

  .blind-box-grid {
    gap: 12px;
  }

  .blind-box {
    border-width: 3px;
    border-radius: 15px;
  }

  .box-number {
    top: 10px;
    left: 11px;
    font-size: 9px;
  }

  .box-state {
    bottom: 10px;
    font-size: 9px;
  }

  .result-card {
    padding: 20px 13px 18px;
    border-width: 3px;
  }

  .result-card__title {
    padding: 9px 18px;
    font-size: 21px;
  }

  .result-card__message {
    font-size: 14px;
    line-height: 1.7;
  }

  .result-card__date {
    padding: 9px 12px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
