.is-hidden { display: none !important; }

/* Card system matched to The Hidden Ace reference */
.card-face {
  border-radius: 7px;
}

.card-back {
  border: 2px solid #b78f3d;
  background:
    linear-gradient(45deg, transparent 46%, rgba(232,195,111,.16) 47% 49%, transparent 50%),
    linear-gradient(-45deg, transparent 46%, rgba(232,195,111,.12) 47% 49%, transparent 50%),
    radial-gradient(circle at center, #20201c 0 16%, #0c0d0b 17% 38%, #2a2923 39% 42%, #090a08 43%);
  background-size: 17px 17px, 17px 17px, auto;
}

.card-back::before {
  content: "AS";
  width: 49%;
  color: #e9c56f;
  font-size: clamp(.72rem, 1.45vw, 1rem);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  letter-spacing: .04em;
}

.card-front {
  color: #111816;
  border: 1px solid #85918e;
  background:
    linear-gradient(135deg, rgba(255,255,255,.2), transparent 35%),
    #afbbb8;
  box-shadow: 0 7px 14px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.18);
}

.card-front.red { color: #a92f34; }

.card.flipped:not(.discarded) .card-front {
  border-color: #f0ca71;
  box-shadow:
    0 7px 14px rgba(0,0,0,.28),
    inset 0 0 0 3px #e8bd60,
    inset 0 0 0 4px rgba(255,255,255,.72);
}

.card.discarded .card-front {
  filter: grayscale(.7) brightness(.7);
  opacity: .48;
}

.card .corner {
  top: 6px;
  left: 7px;
  color: currentColor;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(.7rem, 1.45vw, .94rem);
  text-shadow: 0 1px rgba(255,255,255,.5);
}

.card .corner.bottom {
  top: auto;
  left: auto;
  right: 7px;
  bottom: 6px;
}

.card-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
}

.pip-face {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  filter: drop-shadow(0 1px rgba(255,255,255,.45));
}

.court-face {
  font-family: "Apple Symbols", "Noto Sans Symbols 2", "Segoe UI Symbol", serif;
  font-size: clamp(2.35rem, 5vw, 3.6rem);
  line-height: 1;
  transform: translateY(1px);
  filter: drop-shadow(0 1px rgba(255,255,255,.45));
}

.ace-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #10201c;
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  line-height: .75;
}

.ace-face small {
  margin-top: 9px;
  font-size: .23em;
  font-weight: 900;
  letter-spacing: .16em;
}

.card.replaceable .card-front {
  animation: replacePulse 1.1s ease-in-out infinite;
  cursor: pointer;
}

.card.flipped.replaceable:hover .card-inner {
  transform: rotateY(180deg) translateY(-4px);
}

@keyframes replacePulse {
  0%, 100% { box-shadow: inset 0 0 0 3px #e8bd60, 0 0 0 rgba(232,189,96,0); }
  50% { box-shadow: inset 0 0 0 3px #f3d991, 0 0 20px rgba(232,189,96,.48); }
}

.hand-ranking {
  display: grid;
  gap: 6px;
}

.hand-ranking > div {
  display: grid;
  grid-template-columns: 27px 1fr;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,.065);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.022);
  font-size: .76rem;
}

.hand-ranking strong {
  color: var(--gold-light);
  font-family: Georgia, serif;
  text-align: center;
}

.hand-preview {
  display: inline-flex;
  gap: 4px;
  margin-top: 6px;
}

.hand-chip {
  min-width: 27px;
  padding: 4px 5px;
  border: 1px solid rgba(215,173,85,.28);
  border-radius: 5px;
  color: var(--gold-light);
  background: rgba(0,0,0,.22);
  text-align: center;
  font-family: Georgia, serif;
  font-weight: 800;
}

.mode-card.variant-card { min-height: 108px; }

@media (max-width: 700px) {
  .card .corner { top: 4px; left: 5px; font-size: .62rem; }
  .card .corner.bottom { right: 5px; bottom: 4px; }
  .court-face { font-size: 2rem; }
  .pip-face { font-size: 1.65rem; }
  .ace-face { font-size: 1.9rem; }
  .mode-card.variant-card { min-height: 86px; }
}

/* Exact face artwork reused from El As Oculto. */
.card-back {
  background:
    repeating-linear-gradient(45deg, transparent 0, transparent 5px, rgba(223,184,106,.045) 5px, rgba(223,184,106,.045) 6px),
    linear-gradient(135deg, #65252a, #371317);
  border-color: #b48f54;
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 6px;
  width: auto;
  aspect-ratio: auto;
  transform: none;
  border: 1px solid rgba(202,161,93,.48);
  border-radius: 3px;
  background: transparent;
}

.card-back::after {
  inset: 10px;
  border-color: rgba(202,161,93,.16);
}

.back-emblem {
  position: relative;
  z-index: 1;
  width: 47%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #d7b478;
  border: 1px solid #b78f57;
  background: #44171c;
  transform: rotate(45deg);
  font: 700 clamp(.95rem, 2.2vw, 1.45rem) Georgia, serif;
}

.back-emblem > span { transform: rotate(-45deg); }

.card-front {
  color: #242820;
  border-color: #e3d7bb;
  background: #f2eee3;
}

.card-front.red { color: #a22f3b; }

.card-front .corner {
  z-index: 3;
  top: 6px;
  left: 6px;
  font-size: clamp(.68rem, 1.35vw, .9rem);
  line-height: .9;
}

.card-front .corner.bottom {
  top: auto;
  left: auto;
  right: 6px;
  bottom: 6px;
}

.court-art {
  position: absolute;
  inset: 5% 17% 13%;
  width: 66%;
  height: 82%;
  object-fit: contain;
  mix-blend-mode: normal;
  pointer-events: none;
}

.ace-card {
  overflow: hidden;
  border-color: #d8b65d;
  background: #fffdf8;
}

.ace-card-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 6px;
  pointer-events: none;
}

.ace-royal-label {
  position: absolute;
  z-index: 4;
  left: 30%;
  right: 30%;
  bottom: 2.5%;
  height: 11%;
  display: grid;
  place-items: center;
  color: #15130f;
  background: #fffdf8;
  font: 800 clamp(.36rem, .72vw, .52rem) Georgia, serif;
  letter-spacing: .08em;
}

.pip-face {
  font-size: clamp(1.75rem, 3.8vw, 2.65rem);
}

@media (max-width: 700px) {
  .court-art { inset: 6% 18% 14%; width: 64%; height: 80%; }
  .ace-royal-label { font-size: .32rem; }
}

/* Grand Royal room: the supplied mat becomes the game environment. */
body {
  position: relative;
  background:
    linear-gradient(180deg, rgba(2, 7, 5, .2), rgba(2, 7, 5, .58)),
    url("./art/hidden-royal-mat.png") center top / cover fixed no-repeat;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 0 28%, rgba(0, 0, 0, .24) 72%),
    linear-gradient(90deg, rgba(0, 0, 0, .14), transparent 18% 82%, rgba(0, 0, 0, .14));
}

.app {
  background: linear-gradient(180deg, rgba(2, 10, 7, .18), rgba(2, 10, 7, .42));
}

.topbar {
  padding: 10px 14px;
  border: 1px solid rgba(234, 190, 91, .42);
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(21, 4, 6, .9), rgba(3, 22, 15, .86), rgba(21, 4, 6, .9));
  box-shadow: 0 16px 42px rgba(0, 0, 0, .42), inset 0 0 24px rgba(232, 184, 77, .06);
  backdrop-filter: blur(8px);
}

.table-shell {
  border: 2px solid rgba(226, 179, 70, .72);
  background:
    linear-gradient(180deg, rgba(4, 31, 22, .84), rgba(2, 19, 13, .91)),
    radial-gradient(ellipse at center, rgba(31, 112, 75, .4), transparent 68%);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, .65),
    0 0 0 5px rgba(48, 12, 14, .75),
    0 0 0 7px rgba(220, 170, 61, .28),
    inset 0 0 100px rgba(0, 0, 0, .48);
  backdrop-filter: blur(3px);
}

.table-shell::before {
  border-color: rgba(245, 206, 112, .38);
  box-shadow: inset 0 0 28px rgba(229, 178, 63, .07);
}

.side-panel,
.dialog {
  border-color: rgba(225, 178, 67, .46);
  background: linear-gradient(145deg, rgba(4, 23, 16, .94), rgba(15, 7, 8, .94));
  box-shadow: 0 18px 45px rgba(0, 0, 0, .5), inset 0 0 28px rgba(220, 166, 52, .045);
  backdrop-filter: blur(10px);
}

/* More tactile, jewel-box card styling. */
.card-face {
  border-radius: 9px;
}

.card-back {
  border: 2px solid #e5bb59;
  background:
    linear-gradient(45deg, transparent 47%, rgba(255, 216, 125, .11) 48% 50%, transparent 51%),
    linear-gradient(-45deg, transparent 47%, rgba(255, 216, 125, .08) 48% 50%, transparent 51%),
    radial-gradient(circle at 50% 40%, rgba(177, 39, 48, .4), transparent 34%),
    linear-gradient(145deg, #711d28, #3b0d15 58%, #21080d);
  background-size: 18px 18px, 18px 18px, auto, auto;
  box-shadow:
    0 11px 22px rgba(0, 0, 0, .45),
    inset 0 0 0 2px rgba(64, 9, 14, .85),
    inset 0 0 0 5px rgba(229, 187, 89, .35),
    inset 0 0 28px rgba(0, 0, 0, .48);
}

.card-back::before {
  inset: 7px;
  border: 1px solid rgba(255, 218, 133, .66);
  border-radius: 5px;
  box-shadow: inset 0 0 0 3px rgba(91, 18, 25, .7);
}

.card-back::after {
  inset: 12px;
  border-color: rgba(255, 218, 133, .28);
}

.back-emblem {
  width: 48%;
  color: #ffe5a0;
  border: 1px solid #e1b650;
  background: radial-gradient(circle, #781f29, #360b12 72%);
  box-shadow: 0 0 0 4px rgba(63, 10, 16, .86), 0 0 0 5px rgba(224, 181, 79, .45), 0 5px 16px rgba(0, 0, 0, .5);
  text-shadow: 0 1px 0 #6e4810, 0 0 12px rgba(255, 215, 111, .32);
}

.card-front {
  border: 2px solid #d8ae50;
  background:
    radial-gradient(circle at 32% 20%, rgba(255, 255, 255, .9), transparent 30%),
    linear-gradient(145deg, #fffdf4, #efe3c7 68%, #d5bf91);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, .42),
    inset 0 0 0 2px rgba(255, 255, 255, .75),
    inset 0 0 18px rgba(103, 60, 19, .13);
}

.card.flipped:not(.discarded) .card-front {
  border-color: #f4ce70;
  box-shadow:
    0 13px 26px rgba(0, 0, 0, .48),
    0 0 20px rgba(235, 185, 72, .22),
    inset 0 0 0 2px #fff4ce,
    inset 0 0 0 4px rgba(180, 126, 28, .38);
}

.card.active:not(:disabled):hover .card-back {
  border-color: #ffe29a;
  box-shadow:
    0 16px 30px rgba(0, 0, 0, .52),
    0 0 24px rgba(240, 190, 72, .42),
    inset 0 0 0 2px rgba(64, 9, 14, .85),
    inset 0 0 0 5px rgba(250, 210, 110, .48);
}

.court-art,
.ace-card-art {
  filter: saturate(.93) contrast(1.06) drop-shadow(0 2px 2px rgba(76, 42, 9, .26));
}

.card .corner {
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8), 0 0 1px currentColor;
}

@media (max-width: 900px) {
  body { background-position: 50% top; }
  .topbar { border-radius: 14px; }
}

/* Premium playing cards: larger scale, fuller court art and true ten-pip faces. */
.board {
  gap: 3px;
  padding-inline: 0;
}

.card-row {
  grid-template-columns: 62px repeat(5, minmax(82px, 94px)) 76px;
  justify-content: center;
  column-gap: clamp(9px, 1.15vw, 15px);
  min-height: 132px;
  padding: 3px 4px;
}

.card-wrap {
  width: min(100%, 90px);
  aspect-ratio: 5 / 7;
  perspective: 1000px;
}

.card {
  border-radius: 12px;
}

.card-face {
  border-radius: 11px;
  box-shadow: 0 15px 28px rgba(0, 0, 0, .48);
}

.card-back {
  border-width: 2px;
  background-size: 22px 22px, 22px 22px, auto, auto;
  box-shadow:
    0 16px 30px rgba(0, 0, 0, .5),
    inset 0 0 0 3px rgba(64, 9, 14, .88),
    inset 0 0 0 7px rgba(229, 187, 89, .35),
    inset 0 0 34px rgba(0, 0, 0, .5);
}

.card-back::before {
  inset: 9px;
  border-radius: 6px;
}

.card-back::after {
  inset: 15px;
}

.back-emblem {
  width: 50%;
  border-width: 2px;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.card-front {
  border-width: 2px;
  background:
    radial-gradient(circle at 26% 14%, rgba(255, 255, 255, .98), transparent 29%),
    linear-gradient(145deg, #fffef9 0%, #f7f0df 58%, #e1c99a 100%);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, .48),
    inset 0 0 0 2px rgba(255, 255, 255, .86),
    inset 0 0 23px rgba(103, 60, 19, .13);
}

.card-front::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: 2;
  border: 1px solid rgba(157, 112, 39, .32);
  border-radius: 7px;
  pointer-events: none;
}

.card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(118deg, rgba(255, 255, 255, .2), transparent 28% 72%, rgba(115, 71, 19, .06));
}

.card-front .corner {
  top: 8px;
  left: 8px;
  z-index: 4;
  font-size: clamp(.82rem, 1.25vw, 1.02rem);
  font-weight: 800;
  line-height: .88;
}

.card-front .corner .suit {
  margin-top: 2px;
  font-size: .92em;
}

.card-front .corner.bottom {
  right: 8px;
  bottom: 8px;
}

.court-art {
  inset: 5% 9% 6%;
  width: 82%;
  height: 89%;
  z-index: 1;
  object-fit: contain;
  filter: saturate(1.04) contrast(1.08) drop-shadow(0 3px 2px rgba(76, 42, 9, .22));
}

.ace-card-art {
  z-index: 1;
  filter: saturate(1.02) contrast(1.06) drop-shadow(0 3px 2px rgba(76, 42, 9, .18));
}

.ace-royal-label {
  z-index: 4;
  bottom: 3.2%;
  height: 10%;
  font-size: clamp(.48rem, .7vw, .62rem);
}

.ten-pips {
  position: absolute;
  inset: 0;
  z-index: 1;
  color: #a22f3b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(.9rem, 1.35vw, 1.16rem);
  line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9));
}

.ten-pips i {
  position: absolute;
  display: grid;
  width: 22%;
  aspect-ratio: 1;
  place-items: center;
  font-style: normal;
  transform: translate(-50%, -50%);
  -webkit-text-stroke: .2px rgba(105, 22, 31, .55);
}

.ten-pips i:nth-child(1)  { left: 34%; top: 21%; }
.ten-pips i:nth-child(2)  { left: 66%; top: 21%; }
.ten-pips i:nth-child(3)  { left: 34%; top: 37%; }
.ten-pips i:nth-child(4)  { left: 66%; top: 37%; }
.ten-pips i:nth-child(5)  { left: 50%; top: 45%; }
.ten-pips i:nth-child(6)  { left: 50%; top: 55%; transform: translate(-50%, -50%) rotate(180deg); }
.ten-pips i:nth-child(7)  { left: 34%; top: 63%; transform: translate(-50%, -50%) rotate(180deg); }
.ten-pips i:nth-child(8)  { left: 66%; top: 63%; transform: translate(-50%, -50%) rotate(180deg); }
.ten-pips i:nth-child(9)  { left: 34%; top: 79%; transform: translate(-50%, -50%) rotate(180deg); }
.ten-pips i:nth-child(10) { left: 66%; top: 79%; transform: translate(-50%, -50%) rotate(180deg); }

.ten-card {
  background:
    radial-gradient(ellipse at center, rgba(194, 145, 55, .08), transparent 48%),
    radial-gradient(circle at 26% 14%, rgba(255, 255, 255, .98), transparent 29%),
    linear-gradient(145deg, #fffef9 0%, #f7f0df 58%, #e1c99a 100%);
}

@media (min-width: 1180px) {
  .layout { max-width: 1420px; grid-template-columns: minmax(0, 1fr) 340px; }
  .card-wrap { width: min(100%, 94px); }
  .card-row { min-height: 138px; }
}

@media (max-width: 1030px) {
  .card-row {
    grid-template-columns: 58px repeat(5, minmax(76px, 92px)) 72px;
    min-height: 130px;
  }
  .card-wrap { width: min(100%, 88px); }
}

@media (max-width: 700px) {
  .board { gap: 4px; padding-top: 9px; }
  .card-row {
    grid-template-columns: 38px repeat(5, minmax(42px, 1fr));
    column-gap: 5px;
    min-height: 79px;
    padding: 4px 2px;
  }
  .card-wrap { width: min(100%, 52px); }
  .card-face { border-radius: 7px; }
  .card-front .corner { top: 5px; left: 5px; font-size: .66rem; }
  .card-front .corner.bottom { right: 5px; bottom: 5px; }
  .court-art { inset: 7% 10% 8%; width: 80%; height: 85%; }
  .ten-pips { font-size: .66rem; }
  .ace-royal-label { font-size: .34rem; }
}

@media (max-width: 390px) {
  .card-row { grid-template-columns: 34px repeat(5, minmax(36px, 1fr)); column-gap: 3px; }
  .card-wrap { width: min(100%, 46px); }
}

/* Keep the clicked card in the DOM long enough for a tactile 3D reveal. */
.card-inner {
  transform-origin: 50% 50%;
  transition: transform .68s cubic-bezier(.18, .76, .2, 1);
  will-change: transform;
}

.card-face {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card.flipping {
  z-index: 6;
  animation: royalCardLift .68s cubic-bezier(.18, .76, .2, 1) both;
}

.card.flipping .card-face {
  box-shadow: 0 20px 38px rgba(0, 0, 0, .58), 0 0 24px rgba(239, 198, 101, .24);
}

@keyframes royalCardLift {
  0%, 100% { transform: translateY(0) scale(1); }
  48% { transform: translateY(-8px) scale(1.045); }
}

@media (prefers-reduced-motion: reduce) {
  .card.flipping { animation: none; }
}

/* Complete royal deck artwork supplied for Hidden Royal. */
.themed-card {
  overflow: hidden;
  background: #f7edd8;
}

.deck-card-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  border-radius: 8px;
  background-repeat: no-repeat;
  background-color: #f7edd8;
  filter: saturate(1.03) contrast(1.03);
}

html[data-deck="dark-spades"] .themed-card,
html[data-deck="dark-spades"] .deck-card-art {
  background-color: #090807;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

#startOverlay .dialog { width: min(620px, 100%); }

.deck-choice {
  min-width: 0;
  min-height: 62px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 7px 3px;
  color: #e9dfca;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 11px;
  background: rgba(255, 255, 255, .035);
  cursor: pointer;
}

.deck-choice span {
  font: 700 1.5rem/1 Georgia, "Times New Roman", serif;
}

.deck-choice b {
  max-width: 100%;
  font-size: .66rem;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
}

.deck-choice.diamonds span,
.deck-choice.hearts span { color: #d8494e; }
.deck-choice.clubs span { color: #35a76c; }
.deck-choice.spades span { color: #ece2cb; }
.deck-choice.dark { background: #080807; }
.deck-choice.dark span { color: #d6ad68; }

.deck-choice.selected {
  border-color: #edc665;
  background: rgba(215, 173, 85, .14);
  box-shadow: inset 0 0 0 1px rgba(239, 198, 101, .22), 0 6px 16px rgba(0, 0, 0, .2);
}

.board { gap: 0; }

.card-row {
  grid-template-columns: 58px repeat(5, minmax(90px, 102px)) 72px;
  column-gap: clamp(9px, 1vw, 13px);
  min-height: 143px;
}

.card-wrap { width: min(100%, 102px); }

@media (min-width: 1180px) {
  .layout { max-width: 1480px; grid-template-columns: minmax(0, 1fr) 338px; }
  .topbar { max-width: 1480px; }
  .card-row {
    grid-template-columns: 58px repeat(5, minmax(98px, 108px)) 74px;
    min-height: 148px;
  }
  .card-wrap { width: min(100%, 104px); }
}

@media (max-width: 1030px) {
  .card-row {
    grid-template-columns: 54px repeat(5, minmax(72px, 92px)) 68px;
    min-height: 132px;
  }
  .card-wrap { width: min(100%, 90px); }
}

@media (max-width: 700px) {
  .deck-grid { grid-template-columns: repeat(5, minmax(45px, 1fr)); gap: 5px; }
  .deck-choice { min-height: 54px; }
  .deck-choice span { font-size: 1.25rem; }
  .deck-choice b { font-size: .58rem; }
  .card-row {
    grid-template-columns: 38px repeat(5, minmax(42px, 1fr));
    column-gap: 5px;
    min-height: 79px;
  }
  .card-wrap { width: min(100%, 52px); }
  .deck-card-art { border-radius: 5px; }
}

@media (max-width: 390px) {
  .card-row { grid-template-columns: 34px repeat(5, minmax(36px, 1fr)); column-gap: 3px; }
  .card-wrap { width: min(100%, 46px); }
}
