:root {
  color-scheme: dark;
  --blue-1: #8dd2ef;
  --blue-2: #f29c96;
  --blue-3: #f6d96f;
  --ink: #111827;
  --paper: #fffaf0;
  --panel: rgba(255, 255, 255, 0.2);
  --line: rgba(255, 255, 255, 0.22);
  --yellow: #ffd44d;
  --red: #e9483f;
  --green: #24a65a;
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  min-height: 100vh;
  max-height: 100vh;
  overflow-x: hidden;
  overflow-y: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.24), transparent 34%),
    radial-gradient(circle at 78% 18%, rgba(255, 212, 77, 0.28), transparent 34%),
    radial-gradient(circle at 76% 86%, rgba(255, 255, 255, 0.18), transparent 38%),
    linear-gradient(135deg, #07162f 0%, #0b2447 42%, #c99a2e 72%, #fff7df 100%);
  color: white;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.card-pattern {
  position: fixed;
  inset: 8vh 0 -8vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.pattern-card {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(120px, 13vw, 190px);
  aspect-ratio: 0.68;
  border: 2px solid rgba(255, 247, 223, 0.72);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.34);
  color: rgba(11, 36, 71, 0.68);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(1.55rem, 2.6vw, 3.2rem);
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
  padding: 12px;
  box-shadow:
    inset 0 0 0 7px rgba(255, 255, 255, 0.14),
    0 20px 55px rgba(70, 84, 110, 0.14);
  opacity: 0.9;
  text-shadow: none;
}

.skip-card {
  grid-template-rows: 1fr auto;
  align-items: center;
}

.skip-card b {
  display: block;
  font-size: clamp(5rem, 9vw, 8.8rem);
  line-height: 0.8;
}

.skip-card small {
  display: block;
  align-self: end;
  font-size: clamp(1.2rem, 2vw, 2rem);
  line-height: 1;
  text-transform: uppercase;
}

.reverse-card {
  background: rgba(255, 255, 255, 0.42);
  color: rgba(11, 36, 71, 0.7);
}

.skip-card {
  background: rgba(255, 247, 223, 0.42);
  color: rgba(201, 154, 46, 0.76);
}

.plus-two-card {
  background: rgba(11, 36, 71, 0.32);
  color: rgba(255, 255, 255, 0.74);
}

.plus-four-card {
  background:
    linear-gradient(135deg, rgba(11, 36, 71, 0.44), rgba(201, 154, 46, 0.5), rgba(255, 255, 255, 0.42));
  color: rgba(255, 255, 255, 0.78);
}

.pattern-card:nth-child(1) {
  left: -2vw;
  top: -2vh;
  transform: rotate(-12deg);
}

.pattern-card:nth-child(2) {
  left: 14vw;
  top: 6vh;
  transform: rotate(5deg);
}

.pattern-card:nth-child(3) {
  left: 31vw;
  top: -4vh;
  transform: rotate(-8deg);
}

.pattern-card:nth-child(4) {
  right: 30vw;
  top: 4vh;
  transform: rotate(8deg);
}

.pattern-card:nth-child(5) {
  right: 12vw;
  top: -3vh;
  transform: rotate(-7deg);
}

.pattern-card:nth-child(6) {
  right: -2vw;
  top: 9vh;
  transform: rotate(13deg);
}

.pattern-card:nth-child(7) {
  left: 5vw;
  top: 32vh;
  transform: rotate(-9deg);
}

.pattern-card:nth-child(8) {
  left: 38vw;
  top: 34vh;
  transform: rotate(11deg);
}

.pattern-card:nth-child(9) {
  right: 16vw;
  top: 32vh;
  transform: rotate(-12deg);
}

.pattern-card:nth-child(10) {
  right: -3vw;
  top: 42vh;
  transform: rotate(8deg);
}

.pattern-card:nth-child(11) {
  display: none;
}

.pattern-card:nth-child(12) {
  display: none;
}

.pattern-card:nth-child(13) {
  left: 7vw;
  top: 64vh;
  transform: rotate(-13deg);
}

.pattern-card:nth-child(14) {
  left: 39vw;
  top: 70vh;
  transform: rotate(6deg);
}

.pattern-card:nth-child(15) {
  right: 6vw;
  top: 62vh;
  transform: rotate(11deg);
}

.pattern-card:nth-child(16) {
  right: 25vw;
  top: 74vh;
  transform: rotate(-7deg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  min-height: 44px;
  padding: 0 16px;
  background: var(--yellow);
  color: #1f1600;
  font-weight: 950;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100vw - 28px));
  height: 100vh;
  margin: 0 auto;
  padding: 10px 0;
}

.cover {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(14px, 2.3vh, 24px);
  align-content: center;
  justify-items: center;
  height: calc(100vh - 20px);
  padding: clamp(14px, 3vh, 32px);
  border: 0;
  background: transparent;
  transform: none;
}

.cover.hidden {
  display: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--yellow);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(6.8rem, 22vw, 15rem);
  font-weight: 900;
  line-height: 0.74;
  letter-spacing: 0;
  text-shadow: 0 12px 0 rgba(0, 0, 0, 0.18);
}

h1 span {
  display: inline-block;
  background: linear-gradient(135deg, #07162f 0 28%, #f6c84c 46%, #fff7df 64%, #ffffff 100%);
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, 0.32);
  -webkit-background-clip: text;
  background-clip: text;
}

.cover-copy p:last-child {
  max-width: 560px;
  margin: 16px 0 0;
  color: #dbeafe;
  font-size: 1.08rem;
}

.lobby-panel {
  display: grid;
  gap: 12px;
  width: min(520px, 100%);
}

label {
  display: grid;
  gap: 6px;
  color: #dbeafe;
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

input,
select {
  height: 44px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 0 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.actions {
  display: grid;
  gap: clamp(18px, 3.2vh, 34px);
  grid-template-columns: 1fr;
}

.mode-card {
  display: grid;
  gap: 10px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(139, 232, 225, 0.52);
  padding: 14px 20px;
  box-shadow: 0 18px 45px rgba(70, 84, 110, 0.18);
}

#botModeCard {
  background: linear-gradient(135deg, rgba(7, 22, 47, 0.76), rgba(11, 36, 71, 0.56));
}

#friendsModeCard {
  background: linear-gradient(135deg, rgba(201, 154, 46, 0.74), rgba(255, 212, 77, 0.52));
}

#tournamentModeCard {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 247, 223, 0.42));
}

.mode-card.active {
  box-shadow: 0 18px 45px rgba(70, 84, 110, 0.26);
}

.mode-card button {
  width: 100%;
  min-height: auto;
  padding: 0;
  background: transparent;
  color: #ffffff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(1.4rem, 3.2vh, 1.8rem);
  letter-spacing: 0;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

#tournamentModeCard button {
  color: #0b2447;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.38);
}

.mode-card label {
  color: rgba(255, 255, 255, 0.9);
}

.mode-name.hidden {
  display: none;
}

.mode-card input,
.mode-card select {
  border: 0;
  background: rgba(255, 255, 255, 0.92);
}

.win-banner strong {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.online-panel {
  display: grid;
  grid-template-columns: minmax(82px, 0.7fr) minmax(130px, auto);
  gap: 8px;
  align-items: end;
}

.online-panel.hidden,
#startOnlineButton.hidden,
.win-banner.hidden,
.difficulty-modal.hidden {
  display: none;
}

.difficulty-modal {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  background: rgba(3, 14, 30, 0.48);
  padding: 18px;
}

.difficulty-modal-panel {
  width: min(500px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  border: 2px solid rgba(255, 255, 255, 0.62);
  background:
    linear-gradient(135deg, rgba(7, 22, 47, 0.9), rgba(201, 154, 46, 0.84), rgba(255, 255, 255, 0.82));
  color: #ffffff;
  padding: 22px;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  animation: popIn 180ms ease-out;
}

.difficulty-modal.bot-modal .difficulty-modal-panel {
  background: linear-gradient(135deg, rgba(7, 22, 47, 0.94), rgba(11, 36, 71, 0.8));
}

.difficulty-modal.friends-modal .difficulty-modal-panel {
  background: linear-gradient(135deg, rgba(201, 154, 46, 0.94), rgba(255, 212, 77, 0.78));
}

.difficulty-modal.tournament-modal .difficulty-modal-panel {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 223, 0.82));
  color: #0b2447;
}

.difficulty-modal-panel h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

.difficulty-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.difficulty-buttons button {
  min-height: 66px;
  border: 2px solid rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-size: 1.15rem;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.color-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(3, 14, 30, 0.74);
  padding: 18px;
}

.color-modal.hidden {
  display: none;
}

.color-modal-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  background: rgba(6, 25, 48, 0.96);
  padding: 18px;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
}

.color-modal-panel h2 {
  margin: 0;
  font-size: 1.6rem;
}

.color-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.color-buttons button {
  min-height: 64px;
  color: white;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.red-choice {
  background: #dc2626;
}

.yellow-choice {
  background: #eab308;
  color: #111827 !important;
  text-shadow: none !important;
}

.green-choice {
  background: #16a34a;
}

.blue-choice {
  background: #2563eb;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.confetti.hidden {
  display: none;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 18px;
  background: var(--yellow);
  animation: confetti-fall 2200ms linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

.online-panel label {
  min-width: 0;
}

.join-code-label input {
  width: 100%;
  min-width: 126px;
  text-align: center;
  letter-spacing: 0.08em;
}

.room-card {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 212, 77, 0.5);
  background: rgba(0, 0, 0, 0.24);
  padding: 12px;
  text-align: center;
}

.room-card span,
.room-card small {
  display: block;
  color: #dbeafe;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.room-card strong {
  display: block;
  color: var(--yellow);
  font-size: 2.5rem;
  line-height: 1;
  letter-spacing: 0;
}

.table {
  display: grid;
  grid-template-rows: auto minmax(130px, auto) minmax(220px, 1fr) auto auto;
  gap: 14px;
  min-height: 62vh;
  padding-top: 16px;
}

.table.hidden {
  display: none;
}

.topbar,
.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.home-link {
  display: inline-grid;
  min-height: 46px;
  place-items: center;
  padding: 0 18px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 247, 223, 0.92);
  color: #0b2447;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.home-link-strong {
  background: #f6c84c;
  border-color: #fff7df;
  color: #0b2447;
}

.turn-chip,
.status,
.opponent,
.center {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}

.turn-chip {
  padding: 10px 14px;
  font-weight: 950;
}

.opponents {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.opponent {
  min-height: 118px;
  padding: 12px;
}

.opponent h2,
.opponent p {
  margin: 0;
}

.opponent h2 {
  font-size: 1rem;
}

.opponent p {
  color: #dbeafe;
  font-size: 0.85rem;
  margin-top: 4px;
}

.mini-hand {
  display: flex;
  margin-top: 10px;
  min-height: 54px;
}

.mini-card {
  width: 34px;
  height: 50px;
  margin-right: -18px;
  border: 2px solid white;
  background: #172554;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.22);
}

.center {
  display: grid;
  grid-template-columns: minmax(160px, 240px) 1fr;
  gap: 18px;
  align-items: center;
  justify-items: center;
  min-height: 230px;
  padding: 18px;
}

.draw-pile {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.discard-wrap {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.discard-wrap p {
  margin: 0;
  color: #dbeafe;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.discard-pile {
  position: relative;
  width: 164px;
  height: 222px;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
}

.status p {
  flex: 1;
  margin: 0;
  font-weight: 850;
}

.status.is-ended #callUnoButton {
  display: none;
}

.end-home-link,
.win-actions a {
  display: inline-grid;
  min-height: 54px;
  place-items: center;
  padding: 0 26px;
  background: #f6c84c;
  border: 2px solid #fff7df;
  color: #0b2447;
  font-size: 1.05rem;
  font-weight: 950;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.end-home-link.hidden {
  display: none;
}

.hand {
  display: flex;
  align-items: end;
  min-height: 180px;
  overflow-x: auto;
  padding: 16px 4px 4px;
}

.card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 112px;
  height: 154px;
  flex: 0 0 112px;
  border: 4px solid white;
  border-radius: 8px;
  padding: 8px;
  color: white;
  font-weight: 1000;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
  user-select: none;
}

.hand .card {
  margin-right: -28px;
  transition: transform 140ms ease, margin 140ms ease;
  cursor: pointer;
}

.hand .card:hover,
.hand .card:focus {
  z-index: 4;
  margin-right: 0;
  transform: translateY(-18px);
  outline: 0;
}

.card.disabled {
  cursor: not-allowed;
  filter: grayscale(0.45) brightness(0.72);
}

.card.back {
  place-items: center;
  grid-template-rows: 1fr;
  background:
    radial-gradient(ellipse at center, #ef4444 0 38%, transparent 39%),
    #111827;
  font-size: 1.8rem;
}

.card.red {
  background: #dc2626;
}

.card.yellow {
  background: #eab308;
  color: #111827;
}

.card.green {
  background: #16a34a;
}

.card.blue {
  background: #2563eb;
}

.card.wild {
  background:
    linear-gradient(135deg, #dc2626 0 25%, #eab308 25% 50%, #16a34a 50% 75%, #2563eb 75%);
}

.card .corner {
  font-size: 1rem;
}

.card .value {
  align-self: center;
  justify-self: center;
  font-size: 2.4rem;
  line-height: 1;
}

.card .corner:last-child {
  align-self: end;
  justify-self: end;
  transform: rotate(180deg);
}

.discard-pile .card {
  position: absolute;
  left: 26px;
  top: 28px;
  transform: rotate(5deg);
}

.win-banner {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  gap: 18px;
  align-content: center;
  background: rgba(4, 18, 38, 0.78);
  text-align: center;
}

.win-banner strong {
  color: var(--yellow);
  font-size: clamp(4rem, 14vw, 12rem);
  line-height: 0.88;
  text-shadow: 0 12px 0 rgba(0, 0, 0, 0.25);
}

.win-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

@media (max-width: 760px) {
  .cover,
  .center {
    grid-template-columns: 1fr;
  }

  .opponents {
    grid-template-columns: 1fr;
  }

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

  .opponent {
    min-height: 92px;
  }

  .card {
    width: 92px;
    height: 130px;
    flex-basis: 92px;
  }

  .card .value {
    font-size: 1.8rem;
  }

  .discard-pile {
    width: 140px;
    height: 174px;
  }
}
