@font-face {
  font-family: Vazirmatn;
  src: url('/fonts/vazirmatn-400.ttf') format('truetype');
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Vazirmatn;
  src: url('/fonts/vazirmatn-700.ttf') format('truetype');
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b101d;
  --bg-deep: #080c16;
  --surface: rgba(21, 29, 49, .82);
  --surface-raised: rgba(31, 42, 70, .9);
  --surface-soft: rgba(255, 255, 255, .055);
  --line: rgba(203, 216, 255, .16);
  --line-strong: rgba(203, 216, 255, .28);
  --text: #f7f8ff;
  --muted: #aeb9d1;
  --muted-strong: #ccd5e7;
  --red: #f04465;
  --yellow: #ffcb4a;
  --green: #24d7a2;
  --blue: #4ba3ff;
  --violet: #9a7cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  --shadow-card: 0 14px 30px rgba(0, 0, 0, .18);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html {
  direction: rtl;
  min-width: 320px;
  background: var(--bg-deep);
}

body {
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 6%, rgba(75, 163, 255, .2), transparent 28rem),
    radial-gradient(circle at 94% 18%, rgba(154, 124, 255, .16), transparent 24rem),
    linear-gradient(145deg, var(--bg-deep), var(--bg) 55%, #10182c);
  font-family: Vazirmatn, Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 22rem;
  height: 22rem;
  border: 1px solid rgba(255, 203, 74, .1);
  border-radius: 50%;
  content: '';
  pointer-events: none;
  animation: drift 13s ease-in-out infinite alternate;
}

body::before { top: -11rem; right: -8rem; box-shadow: 0 0 0 26px rgba(255, 203, 74, .025), 0 0 0 54px rgba(255, 203, 74, .018); }
body::after { bottom: -12rem; left: -9rem; border-color: rgba(75, 163, 255, .12); animation-delay: -4s; }

button,
input { font: inherit; }

button { cursor: pointer; }

.shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 72px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
  animation: rise-in .55s var(--ease) both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 900;
  letter-spacing: -.04em;
}

.brand::before {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 6px rgba(255, 203, 74, .13), 0 0 26px rgba(255, 203, 74, .6);
  content: '';
}

.brand i { color: var(--yellow); font-style: normal; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(28, 39, 66, .86), rgba(12, 18, 32, .88));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.hero > .panel {
  min-height: 332px;
  padding: clamp(24px, 4vw, 42px);
  animation: rise-in .65s var(--ease) both;
}

.hero > .panel:nth-child(2) { animation-delay: .08s; }

.hero > .panel:first-child::after {
  position: absolute;
  top: -100px;
  left: -70px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(240, 68, 101, .24);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(240, 68, 101, .035), 0 0 0 38px rgba(240, 68, 101, .02);
  content: '';
  pointer-events: none;
}

.eyebrow {
  display: inline-block;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .19em;
}

.hero h1 {
  max-width: 680px;
  margin: 18px 0 12px;
  font-size: clamp(38px, 7vw, 76px);
  line-height: 1.08;
  letter-spacing: -.07em;
}

.hero h1::after {
  display: block;
  width: 72px;
  height: 5px;
  margin-top: 20px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  content: '';
}

.hero p { max-width: 620px; color: var(--muted); line-height: 1.95; }

.muted { color: var(--muted); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

button.primary,
button.ghost {
  min-height: 48px;
  border-radius: 14px;
  padding: 11px 18px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s ease, background .2s ease;
}

button.primary {
  border: 1px solid rgba(255, 255, 255, .25);
  color: #1c1720;
  background: linear-gradient(135deg, var(--yellow), #ff9e4a);
  box-shadow: 0 12px 28px rgba(255, 178, 54, .18);
  font-weight: 800;
}

button.primary:hover { box-shadow: 0 16px 34px rgba(255, 178, 54, .3); transform: translateY(-2px); }

button.ghost {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, .05);
}

button.ghost:hover { border-color: rgba(255, 203, 74, .62); background: rgba(255, 203, 74, .1); transform: translateY(-2px); }

button:active { transform: translateY(0) scale(.98); }

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 96px;
  margin-top: 26px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(120deg, rgba(75, 163, 255, .15), rgba(255, 255, 255, .03));
  transition: border-color .2s ease, transform .2s var(--ease), background .2s ease;
}

.game-card:hover { border-color: rgba(75, 163, 255, .5); background: rgba(75, 163, 255, .12); transform: translateY(-2px); }
.game-card.future { opacity: .55; margin-top: 12px; }
.game-card h2 { margin: 0 0 4px; font-size: 20px; }
.game-card h3 { margin: 0 0 4px; font-size: 19px; }
.game-list { display: grid; gap: 12px; margin-top: 18px; }
.game-list .game-card { min-height: 76px; margin-top: 0; padding: 12px; }
.game-icon { display: grid; flex: 0 0 54px; place-items: center; width: 54px; height: 54px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 17px; color: var(--yellow); background: linear-gradient(135deg, rgba(240, 68, 101, .7), rgba(75, 163, 255, .65)); box-shadow: var(--shadow-card); font-size: 23px; }
.game-status { display: inline-flex; align-items: center; gap: 7px; margin-inline-start: auto; color: var(--muted-strong); font-size: 12px; white-space: nowrap; }
.game-status .fa-circle-check { color: var(--green); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-heading h2 { margin: 8px 0 0; font-size: clamp(23px, 4vw, 32px); letter-spacing: -.04em; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid rgba(255, 203, 74, .32); border-radius: 13px; padding: 9px 12px; color: var(--yellow); background: rgba(255, 203, 74, .08); cursor: pointer; transition: background .2s ease, border-color .2s ease, transform .2s var(--ease); }
.icon-button:hover { border-color: var(--yellow); background: rgba(255, 203, 74, .16); transform: translateY(-2px); }
.game-entry-form { padding-top: 15px; border-top: 1px solid var(--line); animation: form-in .28s var(--ease) both; }
.game-entry-form .actions { margin-top: 14px; }
.button-label, .primary > .fa-solid, .ghost > .fa-solid { display: inline-flex; align-items: center; gap: 8px; }
.game-live { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 800; }
.turn-message { min-height: 28px; color: var(--muted-strong); font-weight: 700; }
.turn-message .fa-circle-check { margin-inline-end: 6px; color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.uno-logo {
  position: relative;
  display: grid;
  flex: 0 0 78px;
  place-items: center;
  width: 78px;
  height: 78px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, .85);
  border-radius: 23px;
  color: white;
  background: conic-gradient(from 210deg, var(--red), var(--yellow), var(--green), var(--blue), var(--red));
  box-shadow: 0 12px 24px rgba(0, 0, 0, .25);
  font-size: 25px;
  font-weight: 900;
  transform: rotate(-7deg);
  transition: transform .3s var(--ease);
}

.uno-logo::after { position: absolute; width: 130%; height: 28%; border: 2px solid rgba(255, 255, 255, .75); border-radius: 50%; content: ''; transform: rotate(-22deg); }
.game-card:hover .uno-logo { transform: rotate(-2deg) scale(1.04); }

.rooms { padding: 25px clamp(20px, 4vw, 36px); animation: rise-in .7s var(--ease) .16s both; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.rooms h2 { margin: 8px 0 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; }
.room { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; border-top: 1px solid var(--line); animation: row-in .38s var(--ease) both; }
.room:first-child { margin-top: 20px; }
.room b { display: block; margin-bottom: 6px; font-size: 17px; }
.room .muted { font-size: 13px; }
.room-code { display: inline-block; margin-inline-start: 8px; color: var(--yellow); font-weight: 800; }

.entry-form {
  position: relative;
  z-index: 2;
  max-width: 540px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  animation: form-in .28s var(--ease) both;
}

.field { display: grid; gap: 8px; margin: 12px 0; }
.field label { color: var(--muted-strong); font-size: 14px; font-weight: 700; }
.field input { width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 13px; padding: 11px 14px; color: var(--text); background: rgba(4, 8, 16, .5); transition: border-color .2s ease, box-shadow .2s ease, background .2s ease; }
.field input::placeholder { color: #7f8aa2; }
.field input:focus { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255, 203, 74, .1); background: rgba(4, 8, 16, .72); outline: none; }
.toast { min-height: 24px; margin: 10px 0 0; color: #ffb4c4; }

.room-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 14px; }
.online-status, .online { color: var(--green); font-weight: 800; }
.offline { color: var(--muted); }
.players { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.player { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: rgba(0, 0, 0, .14); transition: border-color .2s ease, background .2s ease, transform .2s var(--ease); }
.player:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, .06); transform: translateY(-2px); }
.player b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .muted { margin-top: 8px; font-size: 12px; }
.player.active { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 203, 74, .12); }
.game-active .player.active { animation: turn-pulse 1.8s ease-in-out infinite; }
.room-wait, .uno-table { margin-top: 18px; padding: clamp(20px, 4vw, 34px); animation: rise-in .45s var(--ease) both; }
.room-wait h2 { margin-top: 0; }
.uno-table { text-align: center; }
.table-center { display: grid; min-height: 270px; place-items: center; border: 1px solid rgba(255, 255, 255, .08); border-radius: 30px; background: radial-gradient(circle at center, rgba(36, 215, 162, .12), transparent 42%), rgba(0, 0, 0, .16); }
.table-center .card { animation: card-deal .5s var(--ease) both; }
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 24px; }
.card { width: 72px; height: 104px; border: 4px solid rgba(255, 255, 255, .92); border-radius: 16px; color: #fff; background: var(--blue); box-shadow: 0 10px 20px rgba(0, 0, 0, .22); font-size: 18px; font-weight: 900; transition: transform .2s var(--ease), box-shadow .2s ease, filter .2s ease; }
button.card:hover { box-shadow: 0 16px 26px rgba(0, 0, 0, .3); filter: saturate(1.12); transform: translateY(-7px) rotate(-2deg); }
.game-active button.card[data-card] { animation: card-deal .5s var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
.card.red { background: var(--red); }
.card.yellow { color: #251800; background: var(--yellow); }
.card.green { color: #05281e; background: var(--green); }
.card.blue { background: var(--blue); }
.card.wild { background: linear-gradient(135deg, var(--red) 0 25%, var(--yellow) 25% 50%, var(--green) 50% 75%, var(--blue) 75%); }

@keyframes rise-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes row-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }
@keyframes form-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-deal { from { opacity: 0; transform: translateY(18px) rotate(5deg); } to { opacity: 1; transform: translateY(0) rotate(0); } }
@keyframes turn-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(255, 203, 74, .1); } 50% { box-shadow: 0 0 0 6px rgba(255, 203, 74, .2), 0 0 24px rgba(255, 203, 74, .12); } }
@keyframes drift { from { transform: translate3d(0, 0, 0) rotate(0); } to { transform: translate3d(24px, 16px, 0) rotate(8deg); } }

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 580px); padding-top: 20px; }
  .hero { grid-template-columns: 1fr; }
  .hero > .panel { min-height: auto; }
  .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
  .shell { width: calc(100% - 16px); padding-bottom: 40px; }
  .top { margin-bottom: 18px; }
  .brand { font-size: 21px; }
  .top > .ghost { padding-inline: 12px; }
  .hero > .panel, .rooms, .room-wait, .uno-table { border-radius: 21px; padding: 20px; }
  .hero h1 { font-size: clamp(35px, 13vw, 56px); }
  .panel-heading { align-items: flex-start; }
  .panel-heading h2 { font-size: 23px; }
  .game-status { display: none; }
  .row { align-items: flex-start; }
  .room { align-items: flex-start; }
  .room .ghost { flex: 0 0 auto; }
  .room-code { display: block; margin: 3px 0 0; }
  .players { gap: 8px; }
  .player { padding: 12px 10px; }
  .table-center { min-height: 210px; }
  .card { width: 62px; height: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
