/* THEMED SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,162,39,0.4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201,162,39,0.7); }

/* BAIZE BACKGROUND */
html {
  background-color: #060f09;
}

body {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% -10%, #2d6a3f 0%, #0d2b18 50%, #060f09 100%);
}

body.game-page {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

body.game-page::-webkit-scrollbar {
  display: none;
}

body.game-page main {
  overflow: clip;
}


/* reset button element when used as a card */
button.card {
  border: none;
  font: inherit;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
}

/* TABLE AREA */
#table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 900px;
}

.baize {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E"),
    var(--baize-base);
}

#played-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  height: 173px;
  width: 100%;
  background: rgba(0,0,0,0.15);
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 16px;
}

#played-cards.drop-active {
  border-color: rgba(201, 162, 39, 0.7);
  background: rgba(201, 162, 39, 0.08);
}

#played-cards .empty-msg {
  color: rgba(255,255,255,0.3);
  font-size: 14px;
  letter-spacing: 1px;
}

/* HAND AREA */
#hand-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 900px;
}

#hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: -10px;
  padding: 10px 0 4px;
}

/* CARD */
.card {
  width: 72px;
  height: 108px;
  background: #fff;
  border-radius: 8px;
  font-family: system-ui, -apple-system, sans-serif;
  box-shadow: 2px 4px 12px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

.card:hover {
  transform: rotate(var(--card-rotation, 0deg)) translateY(-20px) scale(1.05);
  box-shadow: 4px 12px 24px rgba(0,0,0,0.5);
  z-index: 100;
}

.card.not-playable:hover {
  transform: rotate(var(--card-rotation, 0deg));
}

.card.red { color: #d0021b; }
.card.black { color: #1a1a1a; }

.card .corner {
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
}

.card .corner.bottom {
  transform: rotate(180deg);
  align-self: flex-end;
}

.card .suit-center {
  font-size: 28px;
  text-align: center;
  line-height: 1;
}

@keyframes from-left {
  from { translate: -110vw 0; opacity: 0; }
  to   { translate: 0 0;      opacity: 1; }
}

@keyframes from-right {
  from { translate: 110vw 0; opacity: 0; }
  to   { translate: 0 0;     opacity: 1; }
}

.card.from-left  { animation: from-left  0.4s ease-out forwards; }
.card.from-right { animation: from-right 0.4s ease-out forwards; }

@keyframes trick-pile-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fly-to-bottom { to { translate:    0 110vh; opacity: 0; } }
@keyframes fly-to-right  { to { translate:  110vw 0;   opacity: 0; } }
@keyframes fly-to-left   { to { translate: -110vw 0;   opacity: 0; } }
@keyframes fadeInUp { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
@keyframes pencil-wiggle {
  0%, 100% { translate: 0 0; }
  25%       { translate: 3px -2px; }
  75%       { translate: -3px 2px; }
}
@keyframes score-write-in {
  from { opacity: 0; filter: blur(1px); }
  to   { opacity: 1; filter: blur(0); }
}
.end-reveal .score-row-new { opacity: 0; }
.end-reveal .score-row-new.score-written { animation: score-write-in 0.35s ease-out forwards; }
.pencil-writing { animation: pencil-wiggle 0.13s ease-in-out infinite; }

/* played card is smaller and non-interactive */
.card.played {
  width: 62px;
  height: 93px;
  cursor: default;
  transform: rotate(var(--tilt));
  transition: none;
  padding: 5px;
}

.card.played:hover {
  transform: rotate(var(--tilt));
  box-shadow: 2px 4px 12px rgba(0,0,0,0.4);
}

.card.played .corner { font-size: 12px; }
.card.played .suit-center { font-size: 22px; }

.card.not-playable {
  filter: brightness(0.78) grayscale(0.25);
  cursor: default;
}

.keyboard-selected {
  box-shadow: 0 0 0 3px rgba(250,204,21,0.9), 0 0 16px 4px rgba(250,204,21,0.5) !important;
}

.card.keyboard-selected {
  transform: rotate(var(--card-rotation, 0deg)) translateY(-20px) scale(1.05) !important;
}

.card.talon-card.keyboard-selected {
  transform: rotate(var(--talon-rot, 0deg)) translateY(-20px) scale(1.05) !important;
}

/* Face-up talon card */
.card.talon-card {
  transform: rotate(var(--talon-rot, 0deg));
  cursor: default;
}

.card.talon-card:hover {
  transform: rotate(var(--talon-rot, 0deg));
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.4);
}

.card.talon-card[draggable="true"] {
  cursor: grab;
}

.card.talon-card[draggable="true"]:hover {
  transform: rotate(var(--talon-rot, 0deg)) translateY(-20px) scale(1.05);
  box-shadow: 4px 12px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

/* Face-down card (bid phase) */
.talon-cards {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.face-down {
  background: #5a1010;
  cursor: default;
  flex-shrink: 0;
  transform: rotate(var(--talon-rot, 0deg));
}

.card.face-down::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 2px,
      transparent 2px,
      transparent 8px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 2px,
      transparent 2px,
      transparent 8px
    );
}

/* SCORE PAPER */
#score-paper-wrapper {
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}

#score-paper-wrapper.open {
  transform: translateY(0) !important;
}

#score-paper-wrapper .score-full-list {
  display: none;
  max-height: calc(36px * 8);
  overflow-y: auto;
}

#score-paper-wrapper.open .score-peek-row {
  display: none !important;
}

#score-paper-wrapper.open .score-full-list {
  display: block;
  height: calc(36px * 8);
}

/* LEFT PLAYER SCORE PAPER */
#score-paper-left-wrapper {
  position: fixed;
  left: clamp(8px, 2.5vw, 36px);
  top: calc(5rem + 10vh);
  transform-origin: left top;
  transform: rotate(90deg);
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: 90;
  cursor: pointer;
}

#score-paper-left-wrapper.open {
  transform: rotate(0deg);
}

#score-paper-left-wrapper .score-full-list {
  display: none;
  height: calc(36px * 8);
  overflow-y: auto;
}

#score-paper-left-wrapper.open .score-peek-row {
  display: none !important;
}

#score-paper-left-wrapper.open .score-full-list {
  display: block;
}

/* RIGHT PLAYER SCORE PAPER */
#score-paper-right-wrapper {
  position: fixed;
  right: clamp(8px, 2.5vw, 36px);
  top: calc(5rem + 10vh);
  transform-origin: right top;
  transform: rotate(-90deg);
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: 90;
  cursor: pointer;
}

#score-paper-right-wrapper.open {
  transform: rotate(0deg);
}

#score-paper-right-wrapper .score-full-list {
  display: none;
  height: calc(36px * 8);
  overflow-y: auto;
}

#score-paper-right-wrapper.open .score-peek-row {
  display: none !important;
}

#score-paper-right-wrapper.open .score-full-list {
  display: block;
}

.score-paper {
  position: relative;
  cursor: pointer;
}

.score-paper::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background: linear-gradient(
    225deg,
    #c8bfa0 0%,
    #d8cfb2 42%,
    rgba(0, 0, 0, 0.2) 48%,
    transparent 54%
  );
  border-radius: 0 3px 0 6px;
  box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.2);
}

.trick-count-stack .card.face-down {
  box-shadow: 0 0 0 1px #000, 2px 4px 12px rgba(0,0,0,0.4);
}

.card.face-down:hover {
  transform: rotate(var(--talon-rot, 0deg));
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   MOBILE GAME PAGE
   ============================================================ */

body.game-page-mobile {
  overflow: hidden;
}

body.game-page-mobile > nav {
  display: none;
}

body.game-page-mobile main {
  padding: 0 !important;
  align-items: stretch !important;
}

.mobile-game {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 12px 12px;
  box-sizing: border-box;
  gap: 12px;
}

/* Table panel */
.mobile-table-area {
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-page-mobile #played-cards {
  height: 110px;
  width: 100%;
  background: rgba(0,0,0,0.15);
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 10px;
}

.game-page-mobile #played-cards.drop-active {
  border-color: rgba(201,162,39,0.7);
  background: rgba(201,162,39,0.08);
}

.game-page-mobile .card.talon-card,
.game-page-mobile .card.face-down,
.game-page-mobile .card.played {
  width: 54px;
  height: 82px;
  padding: 5px;
}

.game-page-mobile .card.talon-card .corner,
.game-page-mobile .card.played .corner { font-size: 13px; }
.game-page-mobile .card.talon-card .suit-center,
.game-page-mobile .card.played .suit-center { font-size: 26px; }


.game-page-mobile #hand-area.drop-active {
  border-color: rgba(201,162,39,0.7);
  box-shadow: 0 0 0 2px rgba(201,162,39,0.4), 0 4px 32px rgba(0,0,0,0.5);
}

/* Hand panel */
.mobile-hand-area {
  padding: 16px 16px 20px;
}

/* Mobile card — slightly smaller, same proportions */
.card.mobile-card {
  width: 54px;
  height: 82px;
  padding: 5px;
}

.card.mobile-card .corner {
  font-size: 13px;
}

.card.mobile-card .suit-center {
  font-size: 26px;
}

.card.mobile-card:hover {
  transform: rotate(var(--card-rotation, 0deg)) translateY(-16px) scale(1.05);
}

.card.mobile-card.not-playable:hover {
  transform: rotate(var(--card-rotation, 0deg));
}

/* Mobile card — compact size for 11+ cards in hand */
.card.mobile-card-sm {
  width: 44px;
  height: 67px;
  padding: 4px;
}

.card.mobile-card-sm .corner {
  font-size: 11px;
}

.card.mobile-card-sm .suit-center {
  font-size: 20px;
}

/* ============================================================
   DEAL SHOW — NAV ARROWS & MOBILE
   ============================================================ */

.deal-nav-btn {
  font-size: 2.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1.5px solid rgba(201,162,39,0.3);
  background: rgba(201,162,39,0.07);
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

a.deal-nav-btn:hover {
  background: rgba(201,162,39,0.18);
  border-color: rgba(201,162,39,0.7);
}

/* Mobile-first: deal cards start small, scale up on wider screens */
.deal-show {
  padding: 0 4px;
}

.deal-row {
  padding: 6px 8px !important;
  gap: 6px !important;
}

.deal-row > div:first-child {
  width: 18px !important;
}

.deal-row [id^="avatar-player-"] {
  width: 52px !important;
}

.deal-show .card.played {
  width: 34px;
  height: 51px;
  padding: 3px;
}
.deal-show .card.played .corner { font-size: 8px; }
.deal-show .card.played .suit-center { font-size: 14px; }

.deal-hand-cards {
  flex-wrap: nowrap;
  gap: 0;
  flex: 1;
  overflow: visible;
}
.deal-hand-cards .card.played {
  margin-right: -18px;
  flex-shrink: 0;
  position: relative;
}
.deal-hand-cards .card.played:last-child {
  margin-right: 0;
}

.deal-trick-col {
  width: 34px !important;
  height: 51px !important;
}
.deal-trick-col .card {
  width: 34px;
  height: 51px;
  padding: 3px;
  cursor: default;
}
.deal-trick-col .card .corner { font-size: 8px; }
.deal-trick-col .card .suit-center { font-size: 14px; }

/* Desktop: restore full card size */
@media (min-width: 641px) {
  .deal-show {
    padding: 0;
  }

  .deal-row {
    padding: 12px 16px !important;
    gap: 16px !important;
  }

  .deal-row > div:first-child {
    width: 36px !important;
  }

  .deal-row [id^="avatar-player-"] {
    width: 110px !important;
  }

  .deal-show .card.played {
    width: 62px;
    height: 93px;
    padding: 5px;
  }
  .deal-show .card.played .corner { font-size: 12px; }
  .deal-show .card.played .suit-center { font-size: 22px; }

  .deal-hand-cards {
    flex-wrap: wrap;
    gap: 4px;
  }
  .deal-hand-cards .card.played {
    margin-right: 0;
  }

  .deal-trick-col {
    width: 72px !important;
    height: 108px !important;
  }
  .deal-trick-col .card {
    width: 72px;
    height: 108px;
    padding: 6px;
  }
  .deal-trick-col .card .corner { font-size: 14px; }
  .deal-trick-col .card .suit-center { font-size: 28px; }
}
