:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f8fafc;
  background: #07130d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  background:
    radial-gradient(circle at 80% 0%, rgb(255 255 255 / 0.08), transparent 32%),
    linear-gradient(135deg, #05110b, #0e2a1b);
}

.sidebar {
  overflow: auto;
  max-height: 100vh;
  padding: 20px;
  background: #101820;
  border-right: 1px solid rgb(255 255 255 / 0.1);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.menu {
  position: relative;
  z-index: 8;
}

.menu > summary {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 7px;
  background: #facc15;
  color: #111827;
  cursor: pointer;
  font-size: 24px;
  font-weight: 900;
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-panel {
  position: absolute;
  top: 44px;
  right: 0;
  width: 230px;
  display: grid;
  gap: 9px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgb(255 255 255 / 0.16);
  background: #18232d;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.35);
}

.menu-panel a,
.menu-panel button {
  display: grid;
  min-height: 34px;
  align-items: center;
  border-radius: 6px;
  color: #f8fafc;
  background: rgb(255 255 255 / 0.08);
  text-decoration: none;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.menu-panel button {
  border: 0;
  text-align: left;
}

.menu-toggle {
  color: #d7e1ef;
}

.menu-toggle select {
  margin-top: 5px;
}

.sidebar header p {
  color: #aebccd;
  margin-top: 8px;
  line-height: 1.4;
}

.config {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.account-card,
.config-section,
.panel {
  background: rgb(255 255 255 / 0.08);
  border: 1px solid rgb(255 255 255 / 0.13);
  border-radius: 8px;
  padding: 14px;
}

.account-card h2,
.config-section summary,
.panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.config-section summary {
  cursor: pointer;
  font-weight: 800;
}

.config-section:not([open]) summary {
  margin-bottom: 0;
}

.account-card {
  margin-top: 18px;
}

.account-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.account-header strong {
  color: #fde68a;
  font-size: 12px;
  text-align: right;
}

.auth-form {
  display: grid;
  gap: 9px;
}

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

.auth-actions button {
  min-height: 34px;
  font-size: 12px;
}

.auth-message {
  color: #bfdbfe;
  font-size: 12px;
  line-height: 1.35;
}

.auth-message.error {
  color: #fecaca;
}

.account-page {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 0%, rgb(250 204 21 / 0.12), transparent 28%),
    linear-gradient(135deg, #05110b, #101820);
}

.account-shell {
  width: min(720px, 100%);
  display: grid;
  gap: 16px;
}

.account-title {
  display: grid;
  gap: 8px;
}

.account-title a {
  color: #fde68a;
  font-weight: 800;
}

.account-title p {
  color: #aebccd;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: #d7e1ef;
  font-size: 12px;
}

input,
select {
  min-width: 0;
  height: 36px;
  border-radius: 6px;
  border: 1px solid rgb(255 255 255 / 0.18);
  background: #f8fafc;
  color: #0f172a;
  padding: 0 9px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: #facc15;
  color: #111827;
  font-weight: 800;
  cursor: pointer;
}

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

#newGame {
  width: 100%;
}

.table-area {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.felt {
  position: relative;
  min-height: 680px;
  overflow: hidden;
  border-radius: 18px;
  border: 10px solid #5b321c;
  background:
    repeating-linear-gradient(45deg, rgb(255 255 255 / 0.025) 0 2px, transparent 2px 7px),
    radial-gradient(ellipse at center, #16754d 0%, #095b3b 56%, #073b29 100%);
  box-shadow: inset 0 0 80px rgb(0 0 0 / 0.35), 0 20px 50px rgb(0 0 0 / 0.35);
  padding: 22px;
}

.felt-mark {
  position: absolute;
  inset: 28% 0 auto;
  text-align: center;
  font-size: clamp(22px, 4.2vw, 58px);
  font-weight: 900;
  color: rgb(255 255 255 / 0.055);
  pointer-events: none;
  letter-spacing: 0.02em;
}

.felt-logo {
  position: absolute;
  left: 50%;
  top: 60%;
  width: min(420px, 48%);
  opacity: 0.075;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: brightness(0) invert(1);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  position: relative;
  z-index: 2;
}

.hud div {
  background: rgb(0 0 0 / 0.22);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 8px;
  padding: 10px;
}

.hud span {
  display: block;
  color: #bfdbfe;
  font-size: 12px;
}

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

.dealer-zone {
  margin-top: 34px;
  text-align: center;
}

.dealer-zone h2 {
  font-size: 18px;
  margin-bottom: 10px;
}

.cards {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0;
  min-height: 128px;
}

.card {
  width: 76px;
  height: 108px;
  margin-left: -18px;
  perspective: 800px;
  flex: 0 0 auto;
}

.card:first-child {
  margin-left: 0;
}

.card.sideways {
  width: 108px;
  height: 76px;
  margin-left: -2px;
  position: relative;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.card.flip .card-inner {
  animation: flipIn 420ms ease-out both;
}

.card.sideways.flip .card-inner {
  animation: flipInSideways 420ms ease-out both;
}

.card.back .card-inner {
  animation: none;
  transform: rotateY(180deg);
}

.card.sideways .card-inner {
  position: absolute;
  width: 76px;
  height: 108px;
  left: 16px;
  top: -16px;
  transform: rotate(90deg);
}

.card-face,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgb(0 0 0 / 0.28);
}

.card-face {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 7px;
  background: #fffaf0;
  color: #111827;
  border: 1px solid #e5e7eb;
}

.card-face strong {
  place-self: center;
  font-size: 30px;
}

.card-face span:last-child {
  place-self: end;
  transform: rotate(180deg);
}

.card.red .card-face {
  color: #b91c1c;
}

.card-back {
  transform: rotateY(180deg);
  border: 5px solid #f8fafc;
  background:
    linear-gradient(135deg, transparent 38%, rgb(255 255 255 / 0.25) 38% 44%, transparent 44%),
    repeating-linear-gradient(45deg, #1d4ed8 0 7px, #1e40af 7px 14px);
}

@keyframes flipIn {
  from {
    transform: rotateY(180deg) translateY(-8px);
  }
  to {
    transform: rotateY(0deg) translateY(0);
  }
}

@keyframes flipInSideways {
  from {
    transform: rotateY(180deg) rotate(90deg) translateY(-8px);
  }
  to {
    transform: rotateY(0deg) rotate(90deg) translateY(0);
  }
}

.player-hands {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  margin-top: 54px;
  min-height: 190px;
}

.player-hand {
  min-width: 190px;
  max-width: 300px;
  padding: 10px;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.18);
  border: 2px solid transparent;
}

.player-hand.active {
  border-color: #facc15;
  box-shadow: 0 0 0 4px rgb(250 204 21 / 0.15);
}

.hand-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
  margin-bottom: 8px;
}

.chip-area {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 12px;
  margin: 3px 0 8px;
}

.chip-area.collected {
  min-height: 31px;
  align-items: center;
  color: #fecaca;
}

.chip-group {
  display: grid;
  gap: 3px;
}

.chip-group.payout {
  padding-left: 10px;
  border-left: 1px solid rgb(255 255 255 / 0.16);
}

.chip-label {
  color: #bfdbfe;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.chip-row {
  display: flex;
  min-height: 24px;
  align-items: center;
  gap: 0;
}

.chip {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: -6px;
  border-radius: 999px;
  border: 3px dashed rgb(255 255 255 / 0.75);
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.25);
  color: #fff;
  font-size: 8px;
  font-weight: 900;
}

.chip:first-child {
  margin-left: 0;
}

.chip-white {
  background: #f8fafc;
  color: #111827;
}

.chip-red {
  background: #dc2626;
}

.chip-green {
  background: #15803d;
}

.chip-black {
  background: #111827;
}

.chip-purple {
  background: #7e22ce;
}

.chip-pink {
  background: #db2777;
}

.chip-gray {
  background: #64748b;
}

.hand-result {
  min-height: 20px;
  margin-top: 8px;
  color: #dbeafe;
  font-size: 13px;
}

.action-panel {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 12px;
  z-index: 3;
}

.status {
  min-height: 28px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.28);
  color: #f8fafc;
  font-weight: 800;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.buttons button[hidden] {
  display: none;
}

kbd {
  display: inline-grid;
  min-width: 21px;
  min-height: 21px;
  place-items: center;
  margin-left: 5px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.18);
  font-size: 12px;
}

.bottom-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  line-height: 1.35;
}

.list p {
  padding-bottom: 8px;
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
}

.muted {
  color: #aebccd;
}

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

  .sidebar {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .table-area {
    padding: 6px;
  }

  .felt {
    min-height: 720px;
    padding: 10px;
    border-width: 7px;
    border-radius: 14px;
  }

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

  .hud div {
    padding: 6px;
    border-radius: 6px;
  }

  .hud span {
    font-size: 9px;
    line-height: 1.1;
  }

  .hud strong {
    font-size: clamp(14px, 4vw, 18px);
    line-height: 1.05;
  }

  .dealer-zone {
    margin-top: 22px;
  }

  .player-hands {
    margin-top: 32px;
    min-height: 172px;
  }

  .player-hand {
    min-width: min(190px, 100%);
    padding: 8px;
  }

  .action-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    gap: 8px;
  }

  .status {
    min-height: 0;
    padding: 8px 10px;
    font-size: 14px;
  }

  .buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .buttons button {
    min-height: 46px;
    font-size: 15px;
  }

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

  .bottom-panels {
    grid-template-columns: 1fr;
  }

  .player-hands {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(0 0 0 / 0.58);
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(420px, 100%);
  border-radius: 10px;
  border: 1px solid rgb(255 255 255 / 0.22);
  background: #102217;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.45);
  padding: 22px;
  text-align: center;
}

.modal-content h2 {
  margin-bottom: 10px;
}

.modal-content p {
  color: #dbeafe;
  margin-bottom: 18px;
}
