:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #111013;
  --panel: #201e24;
  --panel-soft: #2a272f;
  --ink: #f6efe2;
  --muted: #b9ad9c;
  --line: rgba(246, 239, 226, 0.16);
  --gold: #e8b94d;
  --red: #bc4b51;
  --teal: #47b5a6;
  --violet: #8f74d6;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 6%, rgba(188, 75, 81, 0.24), transparent 28rem),
    radial-gradient(circle at 92% 18%, rgba(71, 181, 166, 0.18), transparent 25rem),
    linear-gradient(145deg, #111013 0%, #18151b 58%, #221d20 100%);
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px clamp(14px, 4vw, 36px) 38px;
}

.topbar,
.state-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  min-height: 88px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.1rem, 6vw, 4.6rem);
  line-height: 0.94;
}

.shuffle-button,
.primary,
.secondary {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.shuffle-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--gold);
  color: #22170b;
  box-shadow: var(--shadow);
}

.shuffle-button:hover,
.primary:hover,
.secondary:hover {
  transform: translateY(-1px);
}

.state-panel {
  margin: 16px 0 26px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(32, 30, 36, 0.82);
  box-shadow: var(--shadow);
}

.meter {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.meter-label,
.meter-limit,
#statusText,
.card-effect,
.card-feathers {
  color: var(--muted);
}

#featherCount {
  color: var(--gold);
  font-size: 2rem;
}

#statusText {
  max-width: 720px;
  font-size: 0.98rem;
  line-height: 1.45;
  text-align: right;
}

.deck {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(10px, 1.7vw, 18px);
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 2.5 / 3.55;
  border-radius: 8px;
  background: transparent;
  perspective: 1100px;
}

.card:disabled {
  cursor: default;
}

.card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 440ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.card.is-open .card-inner,
.card.is-peek .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(246, 239, 226, 0.2);
  border-radius: inherit;
  background: #161319;
  backface-visibility: hidden;
  box-shadow: var(--shadow);
}

.card-back {
  justify-content: flex-end;
  padding: 12px;
  background:
    linear-gradient(to top, rgba(17, 16, 19, 0.95), rgba(17, 16, 19, 0.08) 52%),
    var(--card-art);
  background-size: 400% 200%;
  background-position: 0% 0%;
}

.back-mark {
  display: grid;
  place-items: center;
  min-height: 50px;
  border: 1px solid rgba(232, 185, 77, 0.42);
  border-radius: 8px;
  background: rgba(17, 16, 19, 0.72);
  color: var(--gold);
  font-weight: 900;
}

.card-front {
  transform: rotateY(180deg);
}

.card-art {
  flex: 1 1 auto;
  min-height: 0;
  background-image: var(--card-art);
  background-size: 400% 200%;
  background-position: var(--art-pos);
}

.card-copy {
  min-height: 45%;
  padding: 12px;
  border-top: 1px solid rgba(246, 239, 226, 0.14);
  background: linear-gradient(180deg, rgba(32, 30, 36, 0.96), rgba(18, 16, 20, 0.98));
}

.card-title {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  line-height: 1.05;
}

.card-effect {
  display: block;
  min-height: 3.5em;
  font-size: clamp(0.72rem, 1.2vw, 0.88rem);
  line-height: 1.22;
}

.card-feathers {
  display: block;
  margin-top: 10px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.card.is-peek .card-face {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.card.is-locked:not(.is-open):not(.is-peek) {
  opacity: 0.58;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(9, 8, 10, 0.72);
  z-index: 10;
}

.modal.is-visible {
  display: grid;
}

.modal-panel {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-panel h2 {
  margin-bottom: 10px;
  font-size: 1.6rem;
}

#modalCardText {
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.primary {
  background: var(--teal);
  color: #061915;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

@media (max-width: 980px) {
  .deck {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app {
    padding-top: 18px;
  }

  .topbar,
  .state-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .shuffle-button {
    justify-content: center;
    width: 100%;
  }

  #statusText {
    text-align: left;
  }

  .deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-copy {
    min-height: 47%;
    padding: 10px;
  }

  .card-effect {
    font-size: 0.76rem;
  }
}

@media (max-width: 360px) {
  .deck {
    gap: 9px;
  }

  .card-copy {
    min-height: 51%;
    padding: 9px;
  }

  .card-title {
    font-size: 0.94rem;
  }

  .card-effect {
    font-size: 0.68rem;
  }
}
