:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f1fb;
  color: #272133;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.9), transparent 22%),
    radial-gradient(circle at 90% 18%, rgba(255, 223, 145, 0.34), transparent 25%),
    linear-gradient(135deg, #f6f1fb, #eaf6f2 52%, #fff1de);
}

button,
select {
  min-height: clamp(2.05rem, 5.8vh, 2.45rem);
  border-radius: 8px;
  border: 1px solid rgba(69, 54, 94, 0.2);
  font: inherit;
}

button {
  background: rgba(255, 255, 255, 0.76);
  color: #272133;
  font-weight: 850;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid #f4b95a;
  outline-offset: 2px;
}

.primary-button {
  border-color: #684aa0;
  background: #684aa0;
  color: #fffdf8;
}

.game-app {
  width: min(100%, 980px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: clamp(0.5rem, 1.65vw, 0.95rem);
  display: grid;
}

.screen {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.screen.is-active {
  display: grid;
  height: 100%;
  min-height: 0;
  gap: clamp(0.45rem, 1.25vh, 0.75rem);
  overflow: hidden;
}

#title-screen.screen.is-active,
#result-screen.screen.is-active {
  align-content: center;
  place-items: center;
}

#play-screen.screen.is-active {
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  align-content: stretch;
}

.panel {
  width: min(100%, 42rem);
  max-height: 100%;
  margin: 0 auto;
  border: 1px solid rgba(69, 54, 94, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
  padding: clamp(0.9rem, 3vw, 1.55rem);
  box-shadow: 0 1.4rem 3rem rgba(69, 54, 94, 0.14);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #684aa0;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 6vh, 3.05rem);
}

h2 {
  font-size: clamp(1.18rem, 3.5vh, 1.75rem);
}

.lead,
.note,
.status {
  color: #655c70;
  line-height: 1.48;
}

.lead {
  margin: 0.55rem 0 0;
}

.note {
  margin: 0.7rem 0 0;
  font-size: clamp(0.78rem, 2.1vh, 0.94rem);
}

.status {
  margin: 0;
  min-height: 1.35em;
  font-size: clamp(0.78rem, 2vh, 0.95rem);
}

.select-row {
  display: grid;
  gap: 0.4rem;
  margin: 0.85rem 0 0.65rem;
  font-weight: 850;
}

.hud {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(16rem, 1.6fr) auto;
  align-items: center;
  gap: clamp(0.45rem, 1.4vw, 0.75rem);
  border: 1px solid rgba(69, 54, 94, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  padding: clamp(0.48rem, 1.45vw, 0.72rem);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.35rem, 1vw, 0.5rem);
  margin: 0;
}

.stats div {
  border-radius: 8px;
  background: rgba(236, 229, 248, 0.82);
  padding: clamp(0.42rem, 1.1vw, 0.58rem);
}

.stats dt {
  color: #655c70;
  font-size: 0.72rem;
  font-weight: 800;
}

.stats dd {
  margin: 0.1rem 0 0;
  font-size: clamp(0.92rem, 2.7vh, 1.28rem);
  font-weight: 950;
}

.table {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) auto minmax(8rem, 1fr);
  align-items: center;
  min-height: 0;
  overflow: hidden;
  gap: clamp(0.7rem, 2vw, 1.2rem);
  border: 1px solid rgba(69, 54, 94, 0.15);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: clamp(0.55rem, 1.55vw, 0.9rem);
}

.card-area {
  display: grid;
  justify-items: center;
  gap: clamp(0.25rem, 0.8vh, 0.45rem);
  min-height: 0;
}

.hand-label {
  margin: 0;
  font-weight: 900;
  font-size: clamp(0.78rem, 1.9vh, 0.95rem);
}

.versus {
  color: #684aa0;
  font-size: clamp(1.8rem, 7vh, 3.6rem);
  font-weight: 950;
}

.card {
  display: grid;
  width: clamp(4.2rem, 16.5vh, 7rem);
  aspect-ratio: 5 / 7;
  place-items: center;
  border: 2px solid rgba(69, 54, 94, 0.12);
  border-radius: 8px;
  background: #fffdf8;
  color: #272133;
  box-shadow: 0 0.8rem 1.6rem rgba(69, 54, 94, 0.14);
  font-size: clamp(1.35rem, 5.8vh, 2.65rem);
  font-weight: 950;
  line-height: 1.15;
  text-align: center;
}

.card.red {
  color: #c04444;
}

.card-back {
  background: #684aa0;
  color: #fffdf8;
}

.risk {
  border: 1px solid rgba(69, 54, 94, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  padding: clamp(0.45rem, 1.2vw, 0.68rem);
  color: #655c70;
  font-size: clamp(0.76rem, 1.9vh, 0.92rem);
  font-weight: 750;
  line-height: 1.35;
}

.controls,
.result-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.35rem, 1vw, 0.55rem);
}

.controls button,
.result-actions button,
.toolbar button {
  flex: 1 1 9rem;
  padding-inline: 1rem;
}

@media (max-width: 760px) {
  .hud {
    grid-template-columns: 1fr;
  }

  .table {
    grid-template-columns: 1fr;
  }

  .versus {
    transform: rotate(90deg);
  }
}
