:root {
  --bg-1: #050914;
  --bg-2: #090f24;
  --panel-soft: rgba(9, 17, 40, 0.85);
  --line: rgba(153, 197, 255, 0.35);
  --text: #e7f2ff;
  --text-soft: #acc6ef;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --card-width: 84px;
  --card-height: 122px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(45, 232, 242, 0.2), transparent 35%),
    radial-gradient(circle at 80% 15%, rgba(255, 75, 165, 0.18), transparent 32%),
    radial-gradient(circle at 60% 80%, rgba(72, 255, 145, 0.16), transparent 36%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 55%, #111c3d);
  padding: 16px;
}

.game-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.hud-title {
  min-width: 200px;
}

.hud-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(45, 232, 242, 0.6);
}

.subtitle {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 0.93rem;
}

.setting-field {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

.setting-field select {
  min-width: 102px;
  border: 1px solid rgba(120, 187, 255, 0.6);
  border-radius: 10px;
  background: linear-gradient(140deg, #1a2d58, #18254b);
  color: var(--text);
  padding: 7px 9px;
  font-weight: 700;
}

.hud-button {
  border: 1px solid rgba(120, 187, 255, 0.6);
  border-radius: 999px;
  background: linear-gradient(140deg, #1a2d58, #18254b);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.hud-button.secondary {
  background: linear-gradient(140deg, #3a1d4f, #2b163b);
}

.hud-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 16px rgba(45, 232, 242, 0.35);
  border-color: rgba(45, 232, 242, 0.85);
}

.hud-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  gap: 12px;
}

.opponents-wrap,
.center-area,
.player-zone {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow);
}

.opponents-wrap {
  padding: 12px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.opponent {
  position: relative;
  padding: 8px;
  text-align: center;
  border-radius: 12px;
  border: 1px solid rgba(125, 193, 255, 0.35);
  background: rgba(12, 24, 56, 0.75);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.opponent.current-turn {
  border-color: rgba(45, 232, 242, 0.8);
  box-shadow: 0 0 18px rgba(45, 232, 242, 0.35);
}

.opponent h2 {
  font-size: 0.86rem;
  margin-bottom: 6px;
}

.hidden-hand {
  height: 96px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 8px;
}

.count-label {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.center-area {
  position: relative;
  overflow: hidden;
  padding: 8px;
}

.table-direction-ghost {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 2px dashed rgba(128, 194, 255, 0.24);
  box-shadow: inset 0 0 16px rgba(45, 232, 242, 0.1);
  opacity: 0.72;
  pointer-events: none;
  z-index: 0;
  animation: direction-ghost-spin 6.8s linear infinite;
}

.table-direction-ghost::before {
  content: "";
  position: absolute;
  right: 13px;
  top: 9px;
  width: 14px;
  height: 14px;
  border-top: 3px solid rgba(161, 223, 255, 0.5);
  border-right: 3px solid rgba(161, 223, 255, 0.5);
  transform: rotate(34deg);
}

.table-direction-ghost[data-direction="counter"] {
  animation-direction: reverse;
}

.center-strip {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(200px, 1.15fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.pile {
  min-height: 152px;
  border-radius: 12px;
  border: 1px solid rgba(123, 193, 255, 0.5);
  background: linear-gradient(145deg, #12224a, #101b3a);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 8px;
  color: var(--text);
}

.draw-pile {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.22s ease;
}

.draw-pile:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(45, 232, 242, 0.3);
}

.draw-pile:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pile-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

.pile-count {
  font-size: 1.08rem;
  font-weight: 700;
}

.discard-slot {
  min-height: var(--card-height);
  display: grid;
  place-items: center;
}

.meta-panel {
  margin: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(132, 199, 255, 0.35);
  background: rgba(9, 18, 42, 0.8);
  position: relative;
  z-index: 1;
}

.meta-panel.compact-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.84rem;
}

.meta-row + .meta-row {
  margin-top: 6px;
}

.meta-row dt {
  color: var(--text-soft);
}

.meta-row dd {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.direction-indicator {
  gap: 6px;
}

.direction-arrow {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(125, 196, 255, 0.7);
  background: rgba(17, 37, 79, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(45, 232, 242, 0.3);
  transition: transform 0.24s ease;
  position: relative;
}

.direction-arrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-top: 2px solid rgba(192, 236, 255, 0.95);
  border-right: 2px solid rgba(192, 236, 255, 0.95);
  transform: rotate(45deg);
}

.direction-indicator[data-direction="counter"] .direction-arrow {
  transform: scaleX(-1);
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: #999;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

.player-zone {
  padding: 8px;
}

.status-text {
  margin-top: 4px;
  color: var(--text-soft);
  min-height: 20px;
  transition: opacity 0.18s ease;
}

.human-hand {
  margin-top: 10px;
  min-height: calc(var(--card-height) + 28px);
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  gap: 6px;
  justify-content: flex-start;
  padding: 8px 4px 10px;
}

.human-hand::-webkit-scrollbar {
  height: 10px;
}

.human-hand::-webkit-scrollbar-thumb {
  background: rgba(123, 193, 255, 0.38);
  border-radius: 999px;
}

.player-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.card-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.15rem, 1.8vw, 1.75rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.card-corner {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.card-corner.bottom {
  top: auto;
  left: auto;
  right: 8px;
  bottom: 6px;
  transform: rotate(180deg);
}

.card-button {
  flex: 0 0 auto;
  scroll-snap-align: center;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transform: translateY(0);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  animation: card-pop 0.24s ease both;
}

.card-button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.card-button.playable {
  transform: translateY(-10px) scale(1.02);
  box-shadow:
    0 0 0 2px rgba(111, 244, 255, 0.7),
    0 0 0 6px rgba(45, 232, 242, 0.2),
    0 0 26px rgba(45, 232, 242, 0.55);
  animation: playable-pulse 1.8s ease-in-out infinite;
}

.card-button.playable .card {
  border-color: rgba(224, 253, 255, 0.98);
  filter: saturate(1.08) brightness(1.06);
}

.card-button.playable:hover,
.card-button.playable:focus-visible {
  transform: translateY(-12px) scale(1.03);
  box-shadow:
    0 0 0 2px rgba(165, 248, 255, 0.98),
    0 0 0 7px rgba(45, 232, 242, 0.24),
    0 0 28px rgba(45, 232, 242, 0.68);
}

.card-button.drawn-card.playable {
  box-shadow: 0 0 0 2px rgba(255, 219, 95, 0.55), 0 0 16px rgba(255, 210, 84, 0.55);
}

.card.red {
  background: linear-gradient(155deg, #ff6a74, #d41d2f 58%, #8a0b16);
}

.card.yellow {
  background: linear-gradient(155deg, #ffe986, #ffbf1f 62%, #b67e00);
  color: #2b1a00;
}

.card.green {
  background: linear-gradient(155deg, #89ffa4, #26b653 60%, #0f6f30);
}

.card.blue {
  background: linear-gradient(155deg, #7fb2ff, #2e6fe4 60%, #123f9f);
}

.card.wild {
  background:
    linear-gradient(45deg, #d81e1e 0 25%, #ffd23f 25% 50%, #26b653 50% 75%, #2967df 75% 100%);
}

.card.back {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(15, 29, 66, 0.95),
      rgba(15, 29, 66, 0.95) 8px,
      rgba(34, 59, 122, 0.95) 8px,
      rgba(34, 59, 122, 0.95) 16px
    );
  border-color: rgba(120, 186, 255, 0.9);
  box-shadow: 0 0 12px rgba(45, 232, 242, 0.28);
}

.hidden-hand .card.back {
  margin-left: -40px;
}

.hidden-hand .card.back:first-child {
  margin-left: 0;
}

.opponent.bot-play {
  box-shadow: var(--shadow), 0 0 24px rgba(45, 232, 242, 0.45);
}

.opponent.bot-play::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 44%;
  width: 52px;
  height: 74px;
  transform: translateX(-50%);
  border-radius: 10px;
  border: 2px solid rgba(120, 186, 255, 0.9);
  background:
    repeating-linear-gradient(
      135deg,
      rgba(15, 29, 66, 0.95),
      rgba(15, 29, 66, 0.95) 7px,
      rgba(34, 59, 122, 0.95) 7px,
      rgba(34, 59, 122, 0.95) 14px
    );
  box-shadow: 0 0 12px rgba(45, 232, 242, 0.36);
  pointer-events: none;
  animation: bot-card-to-center 0.56s ease-out;
}

.draw-pile::after {
  content: "";
  width: var(--card-width);
  height: var(--card-height);
  border-radius: 12px;
  border: 2px solid rgba(120, 186, 255, 0.9);
  background:
    repeating-linear-gradient(
      135deg,
      rgba(15, 29, 66, 0.95),
      rgba(15, 29, 66, 0.95) 8px,
      rgba(34, 59, 122, 0.95) 8px,
      rgba(34, 59, 122, 0.95) 16px
    );
  box-shadow: 0 0 12px rgba(45, 232, 242, 0.35);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 16, 0.76);
  display: grid;
  place-items: center;
  z-index: 40;
}

.wild-picker {
  width: min(380px, calc(100vw - 30px));
  background: linear-gradient(145deg, #131e40, #0e1936);
  border: 1px solid rgba(141, 203, 255, 0.6);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.wild-picker h2 {
  text-align: center;
  margin-bottom: 12px;
}

.wild-colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.color-choice {
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-weight: 800;
  padding: 12px 8px;
  cursor: pointer;
}

.color-choice.red {
  background: linear-gradient(145deg, #ff5968, #b8132b);
}

.color-choice.yellow {
  background: linear-gradient(145deg, #ffe36d, #d49806);
  color: #291600;
}

.color-choice.green {
  background: linear-gradient(145deg, #6ef691, #1b8f44);
}

.color-choice.blue {
  background: linear-gradient(145deg, #71a7ff, #1f56c2);
}

.winner-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(145deg, rgba(12, 25, 54, 0.96), rgba(13, 19, 45, 0.96));
  border: 1px solid rgba(121, 190, 255, 0.75);
  border-radius: 999px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 22px rgba(45, 232, 242, 0.45);
  z-index: 50;
  animation: winner-in 0.22s ease-out both;
}

.winner-banner p {
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hidden {
  display: none !important;
}

@media (min-width: 981px) {
  :root {
    --card-width: 78px;
    --card-height: 114px;
  }

  body {
    padding: 14px;
  }

  .game-shell {
    width: min(1140px, 100%);
  }

  .hud {
    gap: 14px;
    margin-bottom: 12px;
  }

  .hud-controls {
    gap: 8px;
  }

  .setting-field {
    font-size: 0.74rem;
  }

  .setting-field select {
    min-width: 106px;
    padding: 7px 9px;
  }

  .hud-button {
    font-size: 0.86rem;
    padding: 8px 14px;
  }

  .table {
    gap: 14px;
  }

  .opponents-wrap {
    padding: 10px;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .opponent {
    padding: 9px;
  }

  .opponent h2 {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }

  .hidden-hand {
    height: 100px;
  }

  .count-label {
    font-size: 0.82rem;
  }

  .center-area {
    padding: 10px;
  }

  .table-direction-ghost {
    width: 78px;
    height: 78px;
    right: 10px;
    top: 8px;
    opacity: 0.75;
  }

  .pile {
    min-height: 160px;
    gap: 8px;
    padding: 8px;
  }

  .pile-title {
    font-size: 0.74rem;
  }

  .pile-count {
    font-size: 1.12rem;
  }

  .meta-panel {
    margin: 0;
    padding: 10px;
  }

  .meta-row {
    gap: 8px;
    font-size: 0.86rem;
  }

  .direction-indicator {
    gap: 8px;
  }

  .player-zone {
    padding: 10px;
  }

  .status-text {
    margin-top: 4px;
    min-height: 20px;
    font-size: 0.84rem;
  }

  .human-hand {
    margin-top: 10px;
    min-height: calc(var(--card-height) + 22px);
    gap: 6px;
    padding: 8px 4px 10px;
  }

  .player-actions {
    margin-top: 10px;
  }

  .card-content {
    font-size: clamp(1.2rem, 2vw, 1.85rem);
  }

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

  .card-button.playable {
    transform: translateY(-10px) scale(1.02);
  }

  .card-button.playable:hover,
  .card-button.playable:focus-visible {
    transform: translateY(-13px) scale(1.04);
  }
}
@media (max-width: 980px) {
  .opponents-wrap {
    display: grid;
    overflow: visible;
    gap: 6px;
    padding-bottom: 10px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .opponent {
    min-width: 0;
  }

  .center-strip {
    grid-template-columns: minmax(180px, 1.05fr) minmax(140px, 1fr) minmax(140px, 1fr);
    gap: 8px;
  }
}

@media (max-width: 760px) {
  :root {
    --card-width: 64px;
    --card-height: 92px;
  }

  body {
    padding: 8px;
  }

  .hud {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 10px;
  }

  .hud-controls {
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .setting-field {
    font-size: 0.66rem;
  }

  .setting-field select {
    min-width: 0;
    width: 100%;
    padding: 6px 8px;
    font-size: 0.84rem;
  }

  .hud-button {
    width: 100%;
    padding: 7px 9px;
    font-size: 0.82rem;
    border-radius: 12px;
  }

  .table {
    gap: 6px;
  }

  .opponents-wrap {
    padding: 8px;
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .opponent {
    padding: 6px 6px 7px;
  }

  .opponent h2 {
    font-size: 0.74rem;
    margin-bottom: 2px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hidden-hand {
    display: none;
  }

  .count-label {
    font-size: 0.72rem;
  }

  .center-area {
    padding: 8px;
  }

  .center-strip {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .compact-meta {
    grid-column: 1 / span 2;
  }

  .pile {
    min-height: 122px;
    gap: 6px;
    padding: 6px;
  }

  .pile-title {
    font-size: 0.68rem;
  }

  .pile-count {
    font-size: 1.02rem;
  }

  .meta-panel {
    margin: 0;
    padding: 8px;
  }

  .meta-row {
    font-size: 0.76rem;
  }

  .direction-arrow {
    width: 18px;
    height: 18px;
  }

  .player-zone {
    padding: 9px;
  }

  .status-text {
    margin-top: 4px;
    min-height: 18px;
    font-size: 0.72rem;
  }

  .human-hand {
    margin-top: 8px;
    min-height: auto;
    flex-wrap: wrap;
    overflow-x: visible;
    scroll-snap-type: none;
    justify-content: center;
    gap: 5px;
    padding: 4px 0 7px;
  }

  .card-button {
    scroll-snap-align: none;
  }

  .player-actions {
    margin-top: 8px;
  }

  .table-direction-ghost {
    width: 52px;
    height: 52px;
    top: 5px;
    right: 5px;
    opacity: 0.58;
  }
}

@media (max-width: 460px) {
  :root {
    --card-width: 56px;
    --card-height: 78px;
  }

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

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

@keyframes card-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes winner-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes direction-ghost-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes bot-card-to-center {
  from {
    opacity: 0;
    transform: translate(-50%, 0) rotate(-10deg) scale(0.95);
  }

  24% {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translate(-50%, 58px) rotate(5deg) scale(0.82);
  }
}

@keyframes playable-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(111, 244, 255, 0.7),
      0 0 0 6px rgba(45, 232, 242, 0.2),
      0 0 24px rgba(45, 232, 242, 0.52);
  }

  50% {
    box-shadow:
      0 0 0 2px rgba(166, 249, 255, 0.95),
      0 0 0 7px rgba(45, 232, 242, 0.28),
      0 0 30px rgba(45, 232, 242, 0.7);
  }
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(45, 232, 242, 0.95);
  outline-offset: 2px;
}






