:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #101214;
  color: #f5f3ed;
  letter-spacing: 0;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #101214;
  background-size: 100% 44px;
}

button {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid #303438;
  background: rgba(16, 18, 20, 0.94);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand strong {
  color: #f2b643;
  font-size: 20px;
}

.brand span {
  color: #8f979e;
  font-size: 13px;
}

.odds {
  display: flex;
  gap: 8px;
  color: #afb5ba;
  font-size: 13px;
}

.odds span {
  padding: 6px 9px;
  border: 1px solid #373c40;
  border-radius: 4px;
}

.app-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
  gap: 32px;
  align-items: start;
}

.opening-section {
  min-width: 0;
}

.opening-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 460px;
  overflow: hidden;
  border-block: 1px solid #353a3e;
  background:
    radial-gradient(circle at center, rgba(242, 182, 67, 0.14), transparent 46%),
    #171a1d;
}

.opening-stage::before,
.opening-stage::after {
  position: absolute;
  left: 50%;
  width: 1px;
  height: 66px;
  content: "";
  background: #f2b643;
  opacity: 0.6;
}

.opening-stage::before {
  top: 0;
}

.opening-stage::after {
  bottom: 0;
}

.case-art {
  width: min(360px, 70%);
  height: auto;
  filter: drop-shadow(0 24px 28px rgba(0, 0, 0, 0.5));
  transform-origin: 50% 70%;
}

.opening-stage.is-opening .case-art {
  animation: case-shake 180ms linear infinite;
}

.opening-stage.is-revealed .case-art {
  animation: case-pop 500ms ease-out;
}

@keyframes case-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-5px) rotate(-1deg); }
  75% { transform: translateX(5px) rotate(1deg); }
}

@keyframes case-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); filter: drop-shadow(0 0 28px rgba(242, 182, 67, 0.65)); }
  100% { transform: scale(1); }
}

.result-panel {
  position: absolute;
  inset: auto 24px 24px;
  z-index: 2;
  min-height: 108px;
  padding: 18px 22px;
  border-left: 4px solid #f2b643;
  background: rgba(12, 14, 16, 0.94);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}

.result-panel[hidden] {
  display: none;
}

.result-panel.red {
  border-color: #e14949;
}

.result-panel.knife {
  border-color: #d9a5ff;
}

.result-panel.error {
  border-color: #e14949;
}

.result-kind {
  margin: 0 0 4px;
  color: #9da5ab;
  font-size: 12px;
}

.result-kind:empty {
  display: none;
}

.result-name {
  margin: 0;
  color: #fff;
  font-size: clamp(24px, 5vw, 38px);
  line-height: 1.15;
}

.result-wear {
  margin: 7px 0 0;
  color: #c8cdd0;
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.open-button {
  min-height: 50px;
  border: 1px solid #e0a935;
  border-radius: 4px;
  background: #f2b643;
  color: #17130c;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.open-button:hover:not(:disabled) {
  background: #ffc95f;
  transform: translateY(-1px);
}

.open-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.side-panel {
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #33383c;
}

.stat {
  min-width: 0;
  padding: 14px 10px;
  text-align: center;
  background: #181b1e;
}

.stat + .stat {
  border-left: 1px solid #33383c;
}

.stat span {
  display: block;
  color: #8e969c;
  font-size: 11px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.history-wrap {
  margin-top: 20px;
}

.history-wrap h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.history-empty {
  margin: 0;
  padding: 28px 12px;
  border-block: 1px solid #2d3235;
  color: #767f85;
  text-align: center;
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 6px;
  max-height: 490px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.history-item {
  display: grid;
  grid-template-columns: 34px 28px minmax(72px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border-left: 3px solid #d9a5ff;
  background: #1b1e21;
  font-size: 12px;
}

.history-item.red {
  border-color: #e14949;
}

.history-index {
  color: #666f75;
  font-variant-numeric: tabular-nums;
}

.history-rarity {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #4c5257;
  border-radius: 50%;
  color: #ddd;
}

.history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-wear {
  color: #939ba0;
  white-space: nowrap;
}

.history-time {
  grid-column: 3 / -1;
  color: #737c82;
  font-size: 11px;
}

@media (max-width: 780px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px;
  }

  .app-shell {
    width: min(100% - 28px, 620px);
    padding-top: 20px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .opening-stage {
    min-height: 420px;
  }

  .history-list {
    max-height: 360px;
  }
}

@media (max-width: 430px) {
  .brand span {
    display: none;
  }

  .odds {
    width: 100%;
  }

  .odds span {
    flex: 1;
    text-align: center;
  }

  .opening-stage {
    min-height: 380px;
  }

  .history-item {
    grid-template-columns: 28px 24px 1fr;
  }

  .history-wear,
  .history-time {
    grid-column: 3;
  }
}

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