:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #111;
  color: #f5f1dc;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center top, #2d3430 0, #161a18 38%, #080908 100%);
}

.machine {
  width: min(1100px, calc(100vw - 32px));
  min-height: min(720px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 22px;
  padding: 32px;
  border: 8px solid #c6a24a;
  border-radius: 8px;
  background: linear-gradient(180deg, #183d35 0%, #0c281f 100%);
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.5);
}

.machine-header {
  text-align: center;
  text-transform: uppercase;
}

.kicker {
  margin: 0 0 6px;
  color: #dfc873;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  color: #fff6c7;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 4px 0 #4f1d18;
}

.pay-table {
  border: 2px solid rgb(255 246 199 / 0.55);
  border-radius: 8px;
  background: rgb(0 0 0 / 0.22);
  overflow: hidden;
}

.pay-table h2 {
  margin: 0;
  padding: 8px 12px;
  background: #c6a24a;
  color: #1b1202;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pay-table-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr) 52px);
  gap: 0;
  padding: 8px 10px;
}

.pay-table-grid span,
.pay-table-grid strong {
  padding: 5px 8px;
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
  font-size: 0.92rem;
  line-height: 1.1;
  text-transform: uppercase;
}

.pay-table-grid strong {
  color: #f7d962;
  text-align: right;
}

.meters {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
}

.meter {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 2px solid rgb(255 246 199 / 0.35);
  border-radius: 8px;
  background: rgb(0 0 0 / 0.25);
  text-align: center;
  text-transform: uppercase;
}

.meter span {
  color: #dfc873;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
}

.meter strong {
  color: #fff6c7;
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  line-height: 1;
}

.table {
  display: grid;
  align-items: center;
  gap: 22px;
  padding: 24px 0;
  border-top: 2px solid rgb(255 255 255 / 0.14);
  border-bottom: 2px solid rgb(0 0 0 / 0.35);
}

.card-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 184px));
  justify-content: center;
  gap: clamp(10px, 2vw, 22px);
}

.card-slot {
  appearance: none;
  aspect-ratio: 184 / 256;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid rgb(255 246 199 / 0.65);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.12), rgb(255 255 255 / 0)),
    #12322b;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.35);
  cursor: default;
  padding: 0;
}

.card-slot.card-back {
  background:
    url("Cards/cardback.png") center / cover no-repeat,
    linear-gradient(135deg, rgb(255 255 255 / 0.12), rgb(255 255 255 / 0)),
    #12322b;
}

.card-slot:disabled {
  opacity: 1;
}

.card-slot img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-slot.card-face-fallback {
  background: #f8f3df;
  color: #111;
  font-size: clamp(1.2rem, 3vw, 2.2rem);
  font-weight: 900;
}

.card-slot.can-hold {
  cursor: pointer;
}

.card-slot.can-hold:hover,
.card-slot.can-hold:focus-visible {
  border-color: #f7d962;
  outline: 0;
}

.card-slot.recommended {
  border-color: #52d7ff;
  box-shadow:
    inset 0 0 0 2px rgb(0 0 0 / 0.35),
    0 0 22px rgb(82 215 255 / 0.38);
}

.card-slot.held {
  border-color: #f7d962;
  box-shadow:
    inset 0 0 0 2px rgb(0 0 0 / 0.35),
    0 0 22px rgb(247 217 98 / 0.42);
}

.card-slot.recommended::before {
  content: "BEST";
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 4px;
  background: #52d7ff;
  color: #02151b;
  font-size: clamp(0.7rem, 1.3vw, 1rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
}

.card-slot.held::after {
  content: "HOLD";
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 4px;
  background: #f7d962;
  color: #211300;
  font-size: clamp(0.7rem, 1.3vw, 1rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
}

.strategy-advice {
  min-height: 1.2em;
  margin: -4px 0 0;
  color: #c9f3ff;
  font-size: clamp(0.95rem, 1.8vw, 1.2rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hand-value {
  min-height: 1.4em;
  margin: 0;
  color: #fff6c7;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 #4f1d18;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.controls button {
  min-width: 180px;
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f7d962 0%, #b77b1e 100%);
  color: #211300;
  font: 800 1.5rem/1 Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 7px 0 #6e3f13, 0 14px 26px rgb(0 0 0 / 0.38);
}

#simulate-button {
  min-width: 250px;
  background: linear-gradient(180deg, #52d7ff 0%, #1f86b2 100%);
  color: #02151b;
  box-shadow: 0 7px 0 #0f4f6c, 0 14px 26px rgb(0 0 0 / 0.38);
}

#simulate-button:active {
  box-shadow: 0 3px 0 #0f4f6c, 0 8px 18px rgb(0 0 0 / 0.38);
}

#reset-simulation-button {
  min-width: 220px;
  background: linear-gradient(180deg, #f4f1df 0%, #a7a08d 100%);
  color: #211300;
  box-shadow: 0 7px 0 #615c4e, 0 14px 26px rgb(0 0 0 / 0.38);
}

#reset-simulation-button:active {
  box-shadow: 0 3px 0 #615c4e, 0 8px 18px rgb(0 0 0 / 0.38);
}

.controls button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #6e3f13, 0 8px 18px rgb(0 0 0 / 0.38);
}

.controls button:focus-visible {
  outline: 4px solid #fff6c7;
  outline-offset: 4px;
}

.high-hand {
  min-width: 180px;
  display: grid;
  gap: 5px;
  padding: 10px 14px;
  border: 2px solid rgb(255 246 199 / 0.35);
  border-radius: 8px;
  background: rgb(0 0 0 / 0.25);
  text-align: center;
  text-transform: uppercase;
}

.high-hand span {
  color: #dfc873;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
}

.high-hand strong {
  color: #fff6c7;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  line-height: 1.1;
}

.simulation-panel {
  border: 2px solid rgb(255 246 199 / 0.35);
  border-radius: 8px;
  background: rgb(0 0 0 / 0.22);
  overflow: hidden;
}

.simulation-panel h2 {
  margin: 0;
  padding: 8px 12px;
  background: rgb(82 215 255 / 0.85);
  color: #02151b;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.simulation-summary,
.simulation-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0;
  padding: 8px 10px;
}

.simulation-summary span,
.simulation-counts span {
  padding: 5px 8px;
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
  color: #fff6c7;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .machine {
    min-height: calc(100vh - 20px);
    width: calc(100vw - 20px);
    gap: 16px;
    padding: 18px;
    border-width: 5px;
  }

  .pay-table-grid {
    grid-template-columns: minmax(150px, 1fr) 52px;
  }

  .meters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .controls button {
    min-width: 150px;
    min-height: 56px;
    font-size: 1.25rem;
  }

  #simulate-button {
    min-width: 220px;
  }

  #reset-simulation-button {
    min-width: 220px;
  }

  .controls {
    flex-wrap: wrap;
  }

  .high-hand {
    min-width: 150px;
  }

  .simulation-summary,
  .simulation-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
