* { box-sizing: border-box; }

:root {
  --felt-dark: #0b4d2e;
  --felt-light: #0e6b3f;
  --gold: #e8c34a;
  --card-w: 84px;
  --card-h: 124px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at 50% 0%, var(--felt-light), var(--felt-dark) 70%);
  color: #fff;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(0,0,0,0.25);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  position: relative;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 1px;
}

.scoreboard {
  display: flex;
  gap: 16px;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 4px 14px;
  min-width: 56px;
}

.score .label {
  font-size: 0.7rem;
  opacity: 0.8;
  text-transform: uppercase;
}

.score .points {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--gold);
}

#new-game-btn, #play-again-btn {
  background: var(--gold);
  color: #222;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.1s ease;
}

#new-game-btn:hover, #play-again-btn:hover {
  transform: translateY(-2px);
}

.table {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: calc(100vh - 70px);
  padding: 10px;
  gap: 10px;
}

.ai-area, .player-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.middle-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
  width: 100%;
}

.status {
  min-height: 22px;
  font-size: 0.9rem;
  font-style: italic;
  opacity: 0.9;
}

.hand {
  display: flex;
  gap: 8px;
  min-height: calc(var(--card-h) + 10px);
  flex-wrap: wrap;
  justify-content: center;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  background: #fff;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 3px 8px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  color: #222;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
}

.player-hand .card {
  cursor: pointer;
}

.player-hand .card:hover {
  transform: translateY(-10px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.55);
}

.player-hand .card.disabled {
  cursor: default;
  filter: grayscale(0.2);
}

.card .corner {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: bold;
  font-size: 1.05rem;
  line-height: 1;
}

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

.card .corner .rank {
  font-size: 1.05rem;
}

.suit-icon svg {
  display: block;
}

.corner-icon svg {
  width: 18px;
  height: 18px;
}

.card .center-symbol {
  text-align: center;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card .center-symbol svg {
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25));
}

.center-symbol .court-icon svg {
  width: 52px;
  height: 52px;
}

.glyph-icon {
  line-height: 1;
  font-weight: bold;
}

.corner-icon .glyph-icon {
  font-size: 1.15rem;
}

.court-icon .glyph-icon {
  font-size: 3rem;
}

.suit-denari { color: #9a6b10; }
.suit-coppe { color: #c8273c; }
.suit-spade { color: #274b7a; }
.suit-bastoni { color: #6f4018; }

/* Asso: vistoso come una comunione a Napoli */
.card.asso {
  background: radial-gradient(circle at 50% 38%, #fffaea 0%, #ffe9a0 45%, #f6c94a 78%, #d9a52a 100%);
  border: 3px solid #d4a017;
  box-shadow: 0 0 0 2px #fff6da inset, 0 0 16px 4px rgba(255, 210, 70, 0.85), 0 4px 10px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
}

.card.asso::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 220%;
  height: 220%;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,0.85) 0deg 3deg, transparent 3deg 16deg);
  transform: translate(-50%, -50%) rotate(0deg);
  opacity: 0.5;
  animation: spin-rays 9s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes spin-rays {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.card.asso .corner,
.card.asso .center-symbol {
  position: relative;
  z-index: 1;
}

.card.asso .center-symbol svg {
  width: 58px;
  height: 58px;
  filter: drop-shadow(0 0 6px #fff1b8) drop-shadow(0 2px 3px rgba(0,0,0,0.35));
}

.card.asso .rank {
  font-size: 1.25rem;
  color: #a8730f;
  text-shadow: 0 1px 0 #fff8e0;
}

.sparkle {
  position: absolute;
  color: #fff3c4;
  text-shadow: 0 0 4px #ffdd66, 0 0 2px #fff;
  font-size: 0.9rem;
  z-index: 1;
  animation: twinkle 1.4s ease-in-out infinite;
}

.sparkle.s0 { top: 6px; left: 6px; animation-delay: 0s; }
.sparkle.s1 { top: 6px; right: 6px; animation-delay: 0.35s; }
.sparkle.s2 { bottom: 6px; left: 6px; animation-delay: 0.7s; }
.sparkle.s3 { bottom: 6px; right: 6px; animation-delay: 1.05s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.7) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.3) rotate(25deg); }
}

.card-back {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #7a1f1f, #7a1f1f 10px, #921f1f 10px, #921f1f 20px);
  border: 3px solid #d8b04a;
  box-shadow: 0 3px 8px rgba(0,0,0,0.45);
  flex-shrink: 0;
}

.ai-hand .card-back {
  width: 56px;
  height: 84px;
}

.deck-area {
  display: flex;
  align-items: center;
  gap: -10px;
  position: relative;
}

.deck-pile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-count-card {
  width: 70px;
  height: 104px;
}

.deck-count {
  position: absolute;
  bottom: -10px;
  background: var(--gold);
  color: #222;
  font-weight: bold;
  font-size: 0.75rem;
  border-radius: 10px;
  padding: 1px 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.briscola-slot {
  margin-left: -50px;
  transform: rotate(90deg) translateY(2px);
}

.briscola-slot .card {
  width: 70px;
  height: 104px;
}

.trick-area {
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: var(--card-h);
}

.trick-slot {
  width: var(--card-w);
  height: var(--card-h);
  border: 2px dashed rgba(255,255,255,0.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trick-slot .card {
  animation: drop-in 0.25s ease;
}

@keyframes drop-in {
  from { transform: translateY(-40px) scale(0.8); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.message {
  font-size: 1rem;
  font-weight: 600;
  background: rgba(0,0,0,0.3);
  padding: 8px 18px;
  border-radius: 20px;
  text-align: center;
  min-height: 1.4em;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.show {
  display: flex;
}

.end-card {
  background: #143;
  background: #0e3d24;
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.end-card h2 {
  margin-top: 0;
  color: var(--gold);
}

@media (max-width: 600px) {
  :root {
    --card-w: 62px;
    --card-h: 92px;
  }
  .topbar h1 { font-size: 1.1rem; }
  .center-symbol { font-size: 1.5rem; }
}
