:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #13231d;
  color: #fff9ec;
}

* {
  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 16% 16%, rgba(255, 222, 145, 0.18), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(112, 195, 157, 0.18), transparent 30%),
    linear-gradient(145deg, #13231d, #214a37 52%, #192b25);
}

button,
select {
  min-height: clamp(2.05rem, 5.8vh, 2.45rem);
  border-radius: 8px;
  border: 1px solid rgba(255, 249, 236, 0.22);
  font: inherit;
}

button {
  background: rgba(255, 249, 236, 0.1);
  color: #fff9ec;
  font-weight: 850;
  cursor: pointer;
}

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

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

.primary-button {
  border-color: #ffcd61;
  background: #ffcd61;
  color: #17231e;
}

.game-app {
  width: min(100%, 1020px);
  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 minmax(0, 4rem);
  align-content: stretch;
}

.panel {
  width: min(100%, 44rem);
  max-height: 100%;
  margin: 0 auto;
  border: 1px solid rgba(255, 249, 236, 0.18);
  border-radius: 8px;
  background: rgba(16, 31, 26, 0.78);
  padding: clamp(0.9rem, 3vw, 1.55rem);
  box-shadow: 0 1.4rem 3.4rem rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #ffcd61;
  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, 3rem);
}

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

.lead,
.note,
.status {
  color: rgba(255, 249, 236, 0.76);
  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);
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0.85rem 0 0.65rem;
}

.setup-grid label {
  display: grid;
  gap: 0.35rem;
  font-weight: 850;
}

.hud {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(14rem, 1.4fr) auto;
  align-items: center;
  gap: clamp(0.45rem, 1.4vw, 0.75rem);
  border: 1px solid rgba(255, 249, 236, 0.14);
  border-radius: 8px;
  background: rgba(16, 31, 26, 0.72);
  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(255, 249, 236, 0.1);
  padding: clamp(0.42rem, 1.1vw, 0.58rem);
}

.stats dt {
  color: rgba(255, 249, 236, 0.66);
  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;
  min-height: 0;
  align-content: center;
  gap: clamp(0.45rem, 1.3vh, 0.75rem);
  overflow: hidden;
  border: 1px solid rgba(255, 249, 236, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(58, 125, 90, 0.68), rgba(30, 84, 59, 0.74)),
    #255b42;
  padding: clamp(0.55rem, 1.55vw, 0.9rem);
  box-shadow: inset 0 0 0 2px rgba(255, 249, 236, 0.05);
}

.hand-label {
  margin: 0 0 clamp(0.28rem, 0.75vh, 0.42rem);
  font-weight: 900;
}

.hand-row {
  min-height: 0;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.32rem, 1vh, 0.48rem);
  min-height: 0;
}

.card {
  display: grid;
  width: clamp(3.15rem, 9.4vh, 5rem);
  aspect-ratio: 5 / 7;
  place-items: center;
  border-radius: 8px;
  background: #fff9ec;
  color: #17231e;
  box-shadow: 0 0.6rem 1rem rgba(0, 0, 0, 0.18);
  font-weight: 950;
}

.card.red {
  color: #bf3d42;
}

.card.hidden {
  background: #263c8a;
  color: transparent;
}

.card span {
  text-align: center;
  font-size: clamp(0.95rem, 3.5vh, 1.55rem);
  line-height: 1.15;
}

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

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

.history {
  display: grid;
  min-height: 0;
  gap: 0.2rem;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
  padding-left: 1.35rem;
  color: rgba(255, 249, 236, 0.72);
  font-size: clamp(0.72rem, 1.8vh, 0.86rem);
  line-height: 1.32;
}

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

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

  .controls button {
    flex: 1 1 6rem;
  }
}
