:root {
  color-scheme: dark;
  --felt: #065b3d;
  --felt-dark: #04251f;
  --gold: #ffd35a;
  --red: #e3344f;
  --blue: #25a8ff;
  --pink: #ff64b8;
  --ink: #09070a;
  --panel: #161019;
  --line: #5a284d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 39, 67, 0.28), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(54, 255, 221, 0.16), transparent 25%),
    radial-gradient(circle at 50% 105%, rgba(255, 211, 90, 0.12), transparent 32%),
    linear-gradient(135deg, #08070c 0, #10101c 42%, #17070d 100%);
  color: #f6f7fb;
}

.shell {
  --side-width: clamp(260px, 30vw, 340px);
  --play-width: min(640px, calc(66.6667vh - 18.6667px), calc(100vw - var(--side-width) - 46px));
  --play-width: min(640px, calc(66.6667dvh - 18.6667px), calc(100vw - var(--side-width) - 46px));
  display: grid;
  grid-template-columns: var(--side-width) var(--play-width);
  gap: 18px;
  width: calc(var(--side-width) + var(--play-width) + 18px);
  max-width: calc(100vw - 28px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  align-items: center;
  padding: 14px 0;
}

.side-panel {
  align-self: center;
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  width: 100%;
  height: min(960px, calc(100vh - 28px));
  height: min(960px, calc(100dvh - 28px));
  min-height: 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 211, 90, 0.55) rgba(7, 6, 12, 0.7);
  border: 3px solid #050304;
  border-radius: 8px;
  background:
    radial-gradient(circle at 22% 8%, rgba(255, 211, 90, 0.22), transparent 18%),
    radial-gradient(circle at 78% 4%, rgba(255, 49, 90, 0.18), transparent 22%),
    linear-gradient(145deg, rgba(8, 68, 45, 0.92), rgba(7, 6, 12, 0.98) 54%, rgba(42, 9, 25, 0.92)),
    #06080d;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.54),
    0 0 42px rgba(255, 48, 75, 0.22),
    inset 0 0 0 2px rgba(255, 211, 90, 0.48),
    inset 0 0 38px rgba(0, 0, 0, 0.62);
}

.side-panel::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(255, 248, 231, 0.18);
  border-radius: 5px;
  box-shadow: inset 0 0 0 2px rgba(255, 211, 90, 0.14);
}

.side-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 18px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 22px);
  mix-blend-mode: screen;
  opacity: 0.5;
}

.game-wrap {
  position: relative;
  display: block;
  justify-self: center;
  width: var(--play-width);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  container-type: inline-size;
  border: 3px solid #09070a;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 211, 90, 0.08), transparent 70%),
    #06080d;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.62),
    0 0 42px rgba(255, 48, 75, 0.2),
    inset 0 0 0 2px rgba(255, 211, 90, 0.28);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 2 / 3;
  background: radial-gradient(circle at center, #101018 0, #050308 70%);
  image-rendering: pixelated;
  touch-action: none;
}

.hud {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0;
  pointer-events: none;
}

.hud > div,
.power-meter,
.blackjack,
.instructions {
  border: 2px solid rgba(255, 211, 90, 0.42);
  background:
    radial-gradient(circle at 50% 0, rgba(255, 211, 90, 0.14), transparent 44%),
    linear-gradient(180deg, rgba(14, 76, 52, 0.94), rgba(14, 8, 18, 0.94)),
    rgba(21, 13, 22, 0.9);
  backdrop-filter: blur(12px);
}

.hud > div {
  position: relative;
  min-width: 0;
  padding: 9px 10px 10px;
  border-radius: 8px;
  box-shadow:
    inset 0 0 14px rgba(0, 0, 0, 0.34),
    0 4px 0 rgba(0, 0, 0, 0.34);
}

.hud > div::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 8px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow:
    0 0 0 2px rgba(15, 10, 12, 0.8),
    0 0 12px rgba(255, 211, 90, 0.56);
}

.label {
  display: block;
  color: #ffd35a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 2px;
  color: #fff8e7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 0 10px rgba(255, 211, 90, 0.3);
}

.hud strong.danger {
  color: #ff5a76;
  text-shadow: 0 0 12px rgba(255, 90, 118, 0.7);
}

.hud strong.hot {
  color: #fff19a;
  text-shadow: 0 0 14px rgba(255, 211, 90, 0.9), 2px 2px 0 #8f174d;
}

.power-meter {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 9px;
  padding: 10px 12px 12px;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 211, 90, 0.18),
    0 8px 22px rgba(0, 0, 0, 0.28);
}

.power-meter__top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.power-meter strong {
  color: #fff8e7;
  font: 900 19px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-shadow: 0 0 12px rgba(255, 211, 90, 0.45);
}

.power-track {
  height: 14px;
  overflow: hidden;
  border: 2px solid rgba(255, 248, 231, 0.28);
  border-radius: 4px;
  background: #08070a;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.65);
}

.power-track span {
  display: block;
  width: 0%;
  height: 100%;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.42) 0 4px, transparent 4px 9px),
    linear-gradient(90deg, #ff315a, #ffd35a);
  box-shadow: 0 0 16px rgba(255, 211, 90, 0.58);
  transition: width 90ms linear;
}

.blackjack {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
  min-height: 230px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(255, 211, 90, 0.18), 0 8px 22px rgba(0, 0, 0, 0.28);
}

.blackjack.hidden {
  display: none;
}

.hand {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  gap: 6px;
  align-items: end;
}

.cards {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  min-height: 52px;
  align-items: center;
  flex-wrap: wrap;
}

.card {
  display: grid;
  place-items: center;
  width: 38px;
  height: 50px;
  border-radius: 6px;
  background: linear-gradient(145deg, #fffaf0, #eadfcb);
  color: #16181f;
  border: 2px solid #fff8e7;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22);
}

.card.red {
  color: #c92e3f;
}

.status {
  order: -1;
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  text-align: center;
}

.status strong {
  font-size: 20px;
}

.status span {
  color: #cbd3e2;
  font-size: 13px;
  line-height: 1.3;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(6, 91, 61, 0.26), transparent 34%),
    linear-gradient(180deg, rgba(255, 48, 75, 0.12), transparent 45%),
    rgba(3, 5, 9, 0.8);
}

.overlay.hidden {
  display: none;
}

.cutscene-skip {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  min-width: 94px;
  min-height: 40px;
  border: 2px solid rgba(255, 248, 231, 0.8);
  background: rgba(9, 7, 12, 0.82);
  color: #fff8e7;
  box-shadow: 0 0 18px rgba(255, 211, 90, 0.36), inset 0 0 0 2px rgba(255, 211, 90, 0.18);
}

.cutscene-skip:hover,
.cutscene-skip:focus-visible {
  background: #ffd35a;
  color: #15120a;
}

.hidden {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 211, 90, 0.48), 4px 4px 0 #8f174d;
  font-size: clamp(38px, 14cqw, 92px);
  line-height: 0.9;
}

.overlay p {
  max-width: 86%;
  margin: 0 auto;
  color: #d5dbea;
  font-size: clamp(12px, 3.2cqw, 18px);
}

button {
  justify-self: center;
  min-width: 150px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe27a, #d99520);
  color: #15120a;
  box-shadow: 0 4px 0 #4b2307, 0 0 18px rgba(255, 211, 90, 0.34);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.score-form {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.score-form label {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score-entry {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.score-entry input {
  width: 92px;
  min-height: 44px;
  border: 2px solid rgba(255, 211, 90, 0.72);
  border-radius: 8px;
  background: #08070a;
  color: #fff8e7;
  box-shadow: inset 0 0 16px rgba(255, 211, 90, 0.16);
  font: 900 24px/1 monospace;
  text-align: center;
  text-transform: uppercase;
}

.score-entry input:focus {
  outline: 3px solid #fff8e7;
  outline-offset: 2px;
}

.leaderboard {
  width: min(360px, 100%);
  padding: 12px;
  border: 2px solid rgba(255, 211, 90, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(16, 53, 38, 0.92), rgba(13, 9, 17, 0.92)),
    rgba(21, 13, 22, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 100, 184, 0.14);
}

.leaderboard h2 {
  color: var(--gold);
  font-size: 18px;
  text-align: center;
}

.leaderboard ol {
  display: grid;
  gap: 5px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  color: #f6f7fb;
  font: 900 15px/1.2 monospace;
}

.leaderboard .empty-score {
  color: #cbd3e2;
  font-size: 14px;
  text-align: center;
}

.instructions {
  position: relative;
  z-index: 1;
  align-self: stretch;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 100, 184, 0.15);
}

.instructions h2 {
  font-size: 22px;
}

.instructions p {
  color: #d1d8e8;
  line-height: 1.45;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #5c6578;
  border-radius: 5px;
  background: #101621;
  color: #fff;
  font-size: 0.9em;
}

@media (max-width: 900px) {
  .shell {
    --play-width: min(640px, calc(66.6667vh - 110px));
    --play-width: min(640px, calc(66.6667dvh - 110px));
    grid-template-columns: 1fr;
    align-content: start;
    gap: 8px;
    width: min(100%, 660px);
    max-width: 100%;
    padding: 8px;
  }

  .side-panel {
    align-self: auto;
    height: auto;
    max-height: none;
    min-height: auto;
    grid-template-rows: auto;
    gap: 6px;
    padding: 8px;
    overflow: visible;
  }

  .game-wrap {
    width: min(100%, var(--play-width));
  }

  .shell:has(.blackjack:not(.hidden)) {
    --play-width: min(640px, calc(66.6667vh - 238px));
    --play-width: min(640px, calc(66.6667dvh - 238px));
  }

  .instructions {
    display: none;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .hud > div {
    min-height: 53px;
    padding: 7px 7px 8px;
    border-radius: 5px;
  }

  .hud > div::after {
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
  }

  .label {
    font-size: 9px;
  }

  .hud strong {
    font-size: 18px;
  }

  .blackjack {
    grid-template-columns: 1fr 0.9fr 1fr;
    gap: 6px;
    min-height: 122px;
    padding: 8px;
  }

  .cards {
    min-height: 38px;
    gap: 3px;
  }

  .card {
    width: 29px;
    height: 38px;
    border-radius: 4px;
    font-size: 11px;
  }

  .status strong {
    font-size: 14px;
  }

  .status span {
    font-size: 10px;
  }

  .power-meter {
    gap: 5px;
    padding: 7px 9px 8px;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .shell,
  .shell:has(.blackjack:not(.hidden)) {
    --play-width: min(640px, calc(66.6667vh - 10.6667px));
    --play-width: min(640px, calc(66.6667dvh - 10.6667px));
    grid-template-columns: minmax(0, 1fr) var(--play-width);
    align-content: center;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 8px;
  }

  .side-panel {
    align-self: center;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .game-wrap {
    width: var(--play-width);
  }
}
