/* --- Playing cards --- */
.uno-back {
  container-type: inline-size;
  background:
    linear-gradient(145deg, #253955, #101b30 48%, #162842);
}

.uno-back::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 1px solid #9cbde54d;
  border-radius: 11%;
  background:
    linear-gradient(#ff756d, #ff756d) left top / 23% 5%,
    linear-gradient(#ffc85e, #ffc85e) right top / 23% 5%,
    linear-gradient(#58d9aa, #58d9aa) left bottom / 23% 5%,
    linear-gradient(#65bfff, #65bfff) right bottom / 23% 5%,
    linear-gradient(135deg, transparent 47%, #8abcfb25 48% 51%, transparent 52%),
    linear-gradient(35deg, #70a8ef24, #101c2d90 55%, #6c98c424);
  background-repeat: no-repeat;
}

.uno-back::after {
  content: "JEDAN";
  position: absolute;
  inset: 40% 10%;
  display: grid;
  place-items: center;
  border-block: 1px solid #9cbde54d;
  background: #0a1529db;
  color: #f6faff;
  font: 900 22cqi/1 system-ui, sans-serif;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

#contactOverlay {
  width: min(480px, calc(100% - 24px));
  max-height: 90dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid #a7ceff57;
  border-radius: 18px;
  background: #111e32f5;
  backdrop-filter: blur(16px);
  color: #f1f6ff;
  box-shadow: 0 20px 60px #020813a6;
}

#contactOverlay::backdrop {
  background: #020815a8;
  backdrop-filter: blur(4px);
}

.contactForm { display: grid; gap: 10px; padding: clamp(12px, 4vw, 20px); }
.contactHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.contactHeader h2 { margin: 0; font: 750 19px/1.25 system-ui, sans-serif; }
.contactHeader .btn { padding: 4px 10px; font-size: 18px; }
.contactForm label { display: grid; gap: 5px; font-size: 13px; }
.contactForm textarea, .contactForm input, .contactForm select.select {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  border: 1px solid #a7ceff52;
  border-radius: 10px;
  background: #081327;
  color: #f1f6ff;
  font: 400 16px/1.4 system-ui, sans-serif;
  padding: 8px 10px;
}
.contactForm textarea { resize: vertical; }
.contactForm select.select { appearance: auto; }
.contactForm :is(input, select, textarea, button):focus-visible {
  outline: 2px solid #78caff;
  outline-offset: 2px;
}
.contactForm p, #contactCount, #contactStatus { margin: 0; font-size: 13px; }
#contactCount { justify-self: end; color: #bbcbe3; }
#contactStatus:empty { display: none; }
#contactStatus[data-state="error"] { color: #ffb2b2; }
#contactStatus[data-state="success"] { color: #88ecc5; }
.contactForm a { color: #8cd2ff; overflow-wrap: anywhere; }

.unoCard {
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), filter 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
  transform-origin: bottom center; /* Lifts from the bottom */
  transform: translateZ(0);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn, button, .lobbySeat, #drawPile, .quad {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ruleInfo {
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(191, 224, 255, 0.45);
  border-radius: 50%;
  background: rgba(196, 223, 255, 0.12);
  backdrop-filter: blur(8px);
  color: #e4f3ff;
  font: 700 12px/1 system-ui, sans-serif;
  cursor: help;
}

.ruleInfo:hover, .ruleInfo:focus-visible, .ruleInfo[aria-describedby] {
  outline: 2px solid rgba(125, 211, 252, 0.8);
  outline-offset: 2px;
  background: rgba(125, 211, 252, 0.22);
}

#ruleTooltip {
  position: fixed;
  z-index: 500000;
  width: max-content;
  max-width: min(320px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid rgba(191, 224, 255, 0.27);
  border-radius: 12px;
  background: rgba(9, 18, 32, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  color: #f0f7ff;
  font: 500 13px/1.45 system-ui, sans-serif;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

@media (hover: hover) and (pointer: fine) {
  .unoCard:hover {
    /* Lift high, scale up, and add a dramatic shadow */
    transform: translateY(-20px) scale(1.10) rotate(1.5deg);
    filter: drop-shadow(0 18px 24px rgba(0,0,0,0.55));
    z-index: 100; /* Keeps the hovered card on top of others in hand */
  }
}

/* --- UI Panel Cards (The 'Glass') --- */
.card {
  background: rgba(255,255,255, 0.05);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    /* Subtle lift and glow for containers */
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 15px rgba(85, 170, 255, 0.2);
  }
}

/* --- Game room safety: prevent UNO hover lift from being clipped --- */
.hand {
  position: relative;
  overflow-x: auto;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding-top: 34px;
  padding-bottom: 10px;
}

@media (max-width: 768px), (hover: none) {
  .hand {
    padding-top: 22px !important;
  }
  .hand .unoCard:hover,
  .hand.compact .unoCard:hover {
    transform: none;
  }
  .hand .unoCard.playable:hover {
    transform: translateY(-7px);
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .hand {
    padding-top: 14px !important;
    min-height: 0 !important;
  }
}

#hand {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: 0 !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.hand .unoCard {
  position: relative;
}

.hand .unoCard:hover {
  z-index: 2000 !important;
}

/* --- Global UNO popup (game-wide notification) --- */
.uno-popup{
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  z-index: 900000;
  pointer-events: none;

  --uno-accent: #f1c40f;
  padding: 16px 22px;
  border-radius: 18px;
  border: 2px solid color-mix(in srgb, var(--uno-accent) 75%, white 25%);
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(10px);

  font-weight: 1000;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-size: clamp(28px, 5vw, 64px);
  color: color-mix(in srgb, var(--uno-accent) 85%, white 15%);
  text-shadow:
    0 0 10px color-mix(in srgb, var(--uno-accent) 60%, transparent),
    0 0 26px color-mix(in srgb, var(--uno-accent) 45%, transparent),
    0 14px 40px rgba(0,0,0,0.55);
  box-shadow:
    0 18px 60px rgba(0,0,0,0.55),
    0 0 0 4px color-mix(in srgb, var(--uno-accent) 18%, transparent),
    0 0 36px color-mix(in srgb, var(--uno-accent) 35%, transparent);

  opacity: 0;
  animation: unoPop 2000ms ease forwards;
  will-change: transform, opacity, filter;
}

@keyframes unoPop{
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.70); filter: blur(1px); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1.06); filter: blur(0px); }
  22%  { transform: translate(calc(-50% - 6px), -50%) scale(1.02) rotate(-1deg); }
  30%  { transform: translate(calc(-50% + 6px), -50%) scale(1.03) rotate(1deg); }
  38%  { transform: translate(calc(-50% - 4px), -50%) scale(1.02) rotate(-0.6deg); }
  46%  { transform: translate(calc(-50% + 4px), -50%) scale(1.02) rotate(0.6deg); }
  58%  { transform: translate(-50%, -50%) scale(1.01) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}

/* ─── Magic animation style ──────────────────────────────────────────────── */

.magic-ghost{
  border-radius: var(--cardR, 12px);
  box-shadow:
    0 0 24px rgba(167,139,250,0.5),
    0 0 48px rgba(167,139,250,0.25),
    0 18px 38px rgba(0,0,0,0.35);
  filter: brightness(1.2) drop-shadow(0 0 18px rgba(167,139,250,0.7));
}

.flyCard.magic-play{
  position: fixed;
  width: var(--cardW, 82px);
  height: var(--cardH, 120px);
  border-radius: var(--cardR, 12px);
  border: 2px solid rgba(167,139,250,0.7);
  z-index: 250000;
  pointer-events: none;
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) scale(1);
  will-change: left, top, transform, opacity, filter;
  transition:
    left 450ms cubic-bezier(0.25, 1, 0.5, 1),
    top 450ms cubic-bezier(0.25, 1, 0.5, 1),
    transform 450ms cubic-bezier(0.25, 1, 0.5, 1),
    opacity 450ms cubic-bezier(0.25, 1, 0.5, 1),
    filter 450ms cubic-bezier(0.25, 1, 0.5, 1);
  filter: brightness(1.2);
}

.uno-popup.game-start-popup{
  animation: gameStartPop 1350ms cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.uno-popup.your-turn-popup{
  top: 50%;
  padding: 10px 22px;
  font-size: clamp(22px, 3.2vw, 38px);
  animation: yourTurnPop 1250ms cubic-bezier(0.25, 1, 0.5, 1) forwards;
  box-shadow:
    0 22px 66px rgba(0,0,0,0.62),
    0 0 0 4px color-mix(in srgb, var(--uno-accent) 24%, transparent),
    0 0 34px color-mix(in srgb, var(--uno-accent) 52%, transparent);
}

@keyframes gameStartPop{
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.76); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  62% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}

@keyframes yourTurnPop{
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.74);
    text-shadow:
      0 0 10px color-mix(in srgb, var(--uno-accent) 65%, transparent),
      0 0 28px color-mix(in srgb, var(--uno-accent) 45%, transparent),
      0 14px 40px rgba(0,0,0,0.55);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
    text-shadow:
      0 0 12px color-mix(in srgb, var(--uno-accent) 70%, transparent),
      0 0 36px color-mix(in srgb, var(--uno-accent) 55%, transparent),
      0 16px 46px rgba(0,0,0,0.62);
  }
  65% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}

/* Magic UNO popup — swirling glow */
.uno-popup.magic-uno-popup{
  animation: magicUnoPop 2400ms ease forwards;
  border-color: rgba(167,139,250,0.7);
  background: rgba(15,5,40,0.55);
  backdrop-filter: blur(14px);
  box-shadow:
    0 0 40px rgba(167,139,250,0.55),
    0 0 80px rgba(167,139,250,0.2),
    0 18px 60px rgba(0,0,0,0.55);
  text-shadow:
    0 0 14px color-mix(in srgb, var(--uno-accent) 70%, transparent),
    0 0 40px color-mix(in srgb, var(--uno-accent) 50%, transparent),
    0 14px 40px rgba(0,0,0,0.55);
}

@keyframes magicUnoPop{
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); filter: blur(6px) brightness(2); }
  10%  { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(2deg); filter: blur(0px) brightness(1.3); }
  20%  { transform: translate(-50%, -50%) scale(1.0) rotate(-1deg); filter: blur(0px) brightness(1.1); }
  35%  { transform: translate(-50%, -50%) scale(1.05) rotate(0.5deg); filter: brightness(1.05); }
  50%  { transform: translate(-50%, -50%) scale(1.02) rotate(0deg); }
  75%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1.05); filter: blur(2px) brightness(1.4); }
}

/* Magic game-start popup */
.uno-popup.magic-game-start{
  animation: magicGameStart 1600ms ease forwards;
  border-color: rgba(167,139,250,0.7);
  background: rgba(15,5,40,0.55);
  backdrop-filter: blur(14px);
  box-shadow:
    0 0 50px rgba(167,139,250,0.6),
    0 0 100px rgba(129,140,248,0.25),
    0 18px 60px rgba(0,0,0,0.5);
}

@keyframes magicGameStart{
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); filter: blur(8px) brightness(2.5); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); filter: blur(0) brightness(1.3); }
  30%  { transform: translate(-50%, -50%) scale(0.98); filter: brightness(1.1); }
  45%  { transform: translate(-50%, -50%) scale(1.04); }
  60%  { transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.08); filter: blur(3px) brightness(1.6); }
}
