:root {
  color-scheme: dark;
  --ink: #f7f1d7;
  --muted: #b7b09b;
  --panel: #20232a;
  --panel-2: #2d313a;
  --line: #535a66;
  --bad: #ff6b6b;
  --good: #91e283;
  --gold: #ffd166;
  --blue: #73d2ff;
  --red: #f56c7b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #12151c;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

button {
  border: 2px solid #0b0d12;
  border-radius: 6px;
  background: #d7dbe8;
  color: #151820;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 10px 12px;
  box-shadow: 0 4px 0 #0b0d12;
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0b0d12;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.8) brightness(0.7);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 72px);
  line-height: 0.9;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 16px;
}

#app,
#game {
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  image-rendering: pixelated;
}

.panel {
  position: absolute;
  inset: 0;
  background: rgba(18, 21, 28, 0.92);
  padding: 24px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hidden {
  display: none !important;
}

.title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(320px, 1fr) minmax(220px, 300px);
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.loadout-pane,
.collection-pane,
.progress-pane,
.modal {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.collection-pane,
.loadout-pane {
  min-height: 0;
  overflow: auto;
}

.progress-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.card {
  min-height: 142px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.18) inset;
}

.card.locked {
  opacity: 0.48;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.rarity-common {
  color: #d7dbe8;
}

.rarity-uncommon {
  color: #91e283;
}

.rarity-rare {
  color: #73d2ff;
}

.fine,
.card p,
.warning {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.warning {
  min-height: 36px;
  color: var(--bad);
}

.meter,
.statline {
  align-items: center;
  background: #151820;
  border: 2px solid #353b47;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
  padding: 10px;
}

.selected-list {
  display: grid;
  gap: 8px;
}

.achievement-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.achievement {
  background: #151820;
  border: 2px solid #353b47;
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 8px;
}

.achievement.done {
  border-color: rgba(145, 226, 131, 0.7);
}

.achievement strong {
  color: var(--ink);
  font-size: 13px;
}

.achievement span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.achievement.locked strong {
  color: var(--muted);
}

.selected-item {
  align-items: center;
  background: #151820;
  border: 2px solid #353b47;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  padding: 8px;
}

.wide {
  width: 100%;
}

.primary {
  background: var(--gold);
}

.alt {
  background: var(--blue);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.modal {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #20232a;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.choices .card {
  cursor: pointer;
}

.gacha-stage {
  align-items: center;
  display: grid;
  gap: 18px;
  grid-template-columns: 180px 1fr;
  margin: 18px 0;
}

.pact-circle {
  align-items: center;
  aspect-ratio: 1;
  background: #151820;
  border: 5px solid var(--gold);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
}

.pact-circle.flash-common {
  border-color: #d7dbe8;
}

.pact-circle.flash-uncommon {
  border-color: var(--good);
}

.pact-circle.flash-rare {
  border-color: var(--blue);
  box-shadow: 0 0 30px rgba(115, 210, 255, 0.65);
}

.roll-result {
  min-height: 120px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-2);
}

.odds {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
}

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

.reward-wide {
  grid-column: 1 / -1;
}

.run-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 13px;
}

.run-table th,
.run-table td {
  border-bottom: 1px solid #353b47;
  padding: 7px 5px;
  text-align: left;
}

.run-table th:last-child,
.run-table td:last-child {
  text-align: right;
}

.achievement-popups {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.achievement-popup {
  animation: achievement-pop 760ms cubic-bezier(0.2, 0.9, 0.25, 1.25) both;
  background: #151820;
  border: 2px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 0 22px rgba(255, 209, 102, 0.25);
  padding: 10px 12px;
}

.achievement-popup span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

@keyframes achievement-pop {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.94);
  }

  70% {
    opacity: 1;
    transform: translateY(0) scale(1.03);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 820px) {
  .panel {
    padding: 12px;
  }

  .room-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .progress-pane {
    min-height: 290px;
  }

  .gacha-stage {
    grid-template-columns: 1fr;
  }

  .pact-circle {
    width: 160px;
    margin: 0 auto;
  }
}
