:root {
  --felt: #13211b;
  --felt-2: #1e3b2d;
  --ink: #fff7e8;
  --muted: rgba(255, 247, 232, 0.68);
  --line: rgba(255, 247, 232, 0.18);
  --gold: #e7bd63;
  --red: #d64b45;
  --card: #fffaf0;
  --card-ink: #17231d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(231, 189, 99, 0.15), transparent 24rem),
    linear-gradient(135deg, #0c1713, var(--felt) 45%, #101817);
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 900px);
  min-height: 100vh;
  margin: 0 auto;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.8rem;
  text-align: center;
  padding: 2rem;
}

.loading-mark {
  width: 5.4rem;
  height: 5.4rem;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--card);
  color: var(--card-ink);
  font-size: 2rem;
  font-weight: 900;
  transform: rotate(-4deg);
  box-shadow: var(--shadow);
}

.loading-screen h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 4rem);
}

.loading-screen p {
  margin: 0;
  color: var(--muted);
}

.game-board {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(210px, 1fr) auto auto;
  gap: 0.8rem;
  padding: max(0.9rem, env(safe-area-inset-top)) 0.85rem max(1rem, env(safe-area-inset-bottom));
}

.top-bar,
.score-strip,
.opponent-zone,
.status-panel,
.hand-zone,
.admin-panel {
  border: 1px solid var(--line);
  background: rgba(11, 23, 18, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
}

.eyebrow,
.metric-label {
  display: block;
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.top-bar h1 {
  margin: 0;
  font-size: clamp(1.45rem, 7vw, 2.4rem);
  line-height: 0.95;
}

.admin-pill {
  border: 1px solid rgba(231, 189, 99, 0.45);
  color: var(--gold);
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

.hidden {
  display: none;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  padding: 0.75rem;
  border-radius: 8px;
}

.score-strip > div,
.admin-panel > div {
  min-width: 0;
}

.score-strip strong,
.admin-panel strong {
  font-size: 1.2rem;
}

.red-text {
  color: var(--red);
}

.opponent-zone,
.hand-zone {
  padding: 0.75rem;
  border-radius: 8px;
}

.player-copy {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.55rem;
  color: var(--muted);
}

.player-copy strong {
  color: var(--ink);
}

.bot-stack {
  position: relative;
  min-height: 78px;
}

.card-back {
  position: absolute;
  left: calc(var(--i) * 21px);
  top: calc(var(--i) * 1px);
  width: 52px;
  height: 74px;
  border-radius: 7px;
  border: 1px solid rgba(255, 247, 232, 0.5);
  background:
    linear-gradient(135deg, rgba(231, 189, 99, 0.26), transparent 38%),
    repeating-linear-gradient(45deg, #213f33 0 5px, #172b24 5px 10px);
  box-shadow: 0 9px 20px rgba(0, 0, 0, 0.28);
}

.empty-stack {
  color: var(--muted);
  display: grid;
  min-height: 74px;
  place-items: center;
}

.table-zone {
  position: relative;
  z-index: 1;
  min-height: 210px;
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 0.7rem;
  align-items: stretch;
}

.deck-widget {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.5rem;
}

.deck-card {
  width: 58px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 247, 232, 0.46);
  background:
    repeating-linear-gradient(-45deg, #244738 0 6px, #162820 6px 12px);
  color: var(--gold);
  font-weight: 900;
}

.trump-card {
  transform: rotate(7deg);
}

.battlefield {
  min-height: 210px;
  border: 1px dashed rgba(255, 247, 232, 0.28);
  border-radius: 8px;
  padding: 0.7rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  align-content: center;
  gap: 0.75rem;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03), transparent),
    rgba(255, 247, 232, 0.03);
}

.battlefield.empty {
  display: grid;
  place-items: center;
}

.table-hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.pair {
  min-height: 124px;
  position: relative;
  display: grid;
  place-items: center;
}

.pair .defense-slot {
  position: absolute;
  left: 30px;
  top: 34px;
  min-width: 66px;
  min-height: 92px;
  display: grid;
  place-items: center;
  color: rgba(255, 247, 232, 0.52);
  font-size: 0.72rem;
  text-align: center;
}

.card {
  width: 66px;
  height: 92px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background:
    radial-gradient(circle at 50% 44%, rgba(231, 189, 99, 0.2), transparent 1.2rem),
    var(--card);
  color: var(--card-ink);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.card.small {
  width: 46px;
  height: 64px;
  transform: rotate(92deg);
}

.card.red {
  color: var(--red);
}

button.card {
  cursor: pointer;
}

button.card:disabled {
  cursor: default;
  opacity: 0.55;
  filter: saturate(0.7);
  pointer-events: none;
}

button.card.playable {
  z-index: 3;
  box-shadow: 0 16px 28px rgba(231, 189, 99, 0.24);
  outline: 2px solid rgba(231, 189, 99, 0.7);
}

button.card.playable:active {
  transform: scale(0.98);
}

.card-rank {
  font-size: 1.55rem;
  font-weight: 900;
}

.card-suit {
  position: absolute;
  bottom: 0.62rem;
  right: 0.62rem;
  font-size: 1.05rem;
}

.card-corner {
  position: absolute;
  top: 0.38rem;
  left: 0.42rem;
  font-size: 0.74rem;
  font-weight: 800;
}

.card-placeholder {
  width: 66px;
  height: 92px;
  border-radius: 7px;
  border: 1px dashed rgba(255, 247, 232, 0.35);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.status-panel {
  position: relative;
  z-index: 3;
  border-radius: 8px;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: center;
}

.status-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-panel strong {
  display: block;
  margin-top: 0.16rem;
  line-height: 1.25;
}

.actions {
  display: flex;
  gap: 0.45rem;
}

.icon-action,
.result-panel button {
  min-height: 42px;
  border: 1px solid rgba(231, 189, 99, 0.42);
  background: rgba(231, 189, 99, 0.16);
  color: var(--ink);
  border-radius: 7px;
  padding: 0 0.72rem;
  cursor: pointer;
  font-weight: 800;
}

.icon-action.danger {
  border-color: rgba(214, 75, 69, 0.45);
  background: rgba(214, 75, 69, 0.16);
}

.icon-action:disabled {
  cursor: default;
  opacity: 0.42;
  pointer-events: none;
}

.icon-action:not(:disabled) {
  position: relative;
  z-index: 2;
}

.hand {
  min-height: 110px;
  display: flex;
  gap: 0.48rem;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0.95rem 0.15rem 0.25rem;
  scrollbar-width: thin;
}

.hand-zone {
  position: relative;
  z-index: 4;
}

.admin-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  padding: 0.75rem;
  border-radius: 8px;
}

.result-modal {
  position: fixed;
  inset: 0;
  padding: 1rem;
  background: rgba(5, 9, 7, 0.72);
  display: grid;
  place-items: center;
  z-index: 20;
}

.result-panel {
  width: min(100%, 420px);
  border-radius: 8px;
  border: 1px solid rgba(231, 189, 99, 0.42);
  background:
    linear-gradient(135deg, rgba(231, 189, 99, 0.12), transparent),
    #14221c;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.result-panel span {
  color: var(--gold);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.result-panel h2 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.45rem;
  line-height: 1.1;
}

.result-panel p {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 30;
  margin: auto;
  width: min(430px, calc(100% - 2rem));
  border: 1px solid rgba(231, 189, 99, 0.45);
  background: #172820;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.82rem 0.9rem;
  box-shadow: var(--shadow);
}

.toast-error {
  border-color: rgba(214, 75, 69, 0.55);
}

@media (max-width: 520px) {
  .game-board {
    gap: 0.6rem;
    padding-left: 0.58rem;
    padding-right: 0.58rem;
  }

  .score-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 0.62rem;
  }

  .score-strip strong {
    font-size: 1rem;
  }

  .table-zone {
    grid-template-columns: 62px 1fr;
    min-height: 190px;
  }

  .deck-card {
    width: 47px;
    height: 68px;
  }

  .battlefield {
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
    min-height: 190px;
    padding: 0.52rem;
  }

  .card {
    width: 58px;
    height: 82px;
  }

  .card.small {
    width: 42px;
    height: 58px;
  }

  .card-rank {
    font-size: 1.35rem;
  }

  .pair {
    min-height: 112px;
  }

  .pair .defense-slot {
    left: 25px;
    top: 30px;
  }

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

  .actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .icon-action {
    padding: 0 0.45rem;
  }
}
