/*
  styles.css gestaltet die Uno-Extreme-WebApp.
  Die Datei nutzt nur normales CSS, damit sie zu den Vorgaben HTML/CSS/JavaScript passt.
*/

:root {
  /* Zentrale Farbwerte machen das Design leichter wartbar. */
  --bg: #151515;
  --panel: #22262a;
  --panel-soft: #2d3338;
  --text: #f7f4ea;
  --muted: #b9c0bd;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #f5c542;
  --danger: #d83a34;
  --red: #d83a34;
  --yellow: #f5c542;
  --green: #2ea85c;
  --blue: #2f78d6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 18%, rgba(216, 58, 52, 0.22), transparent 25rem),
    radial-gradient(circle at 88% 12%, rgba(47, 120, 214, 0.24), transparent 24rem),
    linear-gradient(135deg, #161514 0%, #17201b 52%, #101418 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}

.app-header h1,
.setup-copy h2,
.turn-strip h2,
.scoreboard h2,
.log-panel h2,
.hand-header h2 {
  margin: 0;
  line-height: 1.1;
}

.app-header h1 {
  font-size: clamp(2rem, 7vw, 4.7rem);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem);
  gap: 2rem;
  align-items: start;
  min-height: 70vh;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 38, 42, 0.88);
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.26);
}

.setup-copy {
  max-width: 42rem;
}

.setup-copy h2 {
  font-size: clamp(2.4rem, 6vw, 5rem);
}

.setup-copy p {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.65;
}

.setup-form,
.scoreboard,
.log-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 24, 25, 0.7);
}

.setup-form {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.setup-form label {
  color: var(--muted);
  font-size: 0.9rem;
}

.setup-form input,
.setup-form select {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111618;
}

.setup-status {
  min-height: 1.3rem;
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.player-fields {
  display: grid;
  gap: 0.75rem;
}

.player-config {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.5rem;
  gap: 0.55rem;
}

.player-config label {
  grid-column: 1 / -1;
}

.public-games {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.public-games-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.public-games h3 {
  margin: 0;
  font-size: 1rem;
}

.public-games-list {
  display: grid;
  gap: 0.55rem;
}

.public-game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.public-game strong {
  display: block;
}

.public-game span {
  color: var(--muted);
  font-size: 0.86rem;
}

.primary-button,
.ghost-button,
.deck-button,
.uno-button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  margin-top: 0.6rem;
  color: #151515;
  background: var(--accent);
}

.ghost-button {
  padding: 0 1rem;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.game-view {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 18rem;
  gap: 1rem;
  align-items: start;
}

.lobby-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1rem;
  align-items: start;
}

.lobby-main {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 31, 31, 0.84);
}

.lobby-players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.admin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.admin-controls .primary-button,
.admin-controls .ghost-button {
  min-width: 12rem;
}

.scoreboard,
.log-panel {
  position: sticky;
  top: 1rem;
  padding: 1rem;
}

.players-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.player-row {
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.player-row.active {
  border-color: var(--accent);
  background: rgba(245, 197, 66, 0.12);
  animation: activePlayer 1150ms ease infinite alternate;
}

.player-row .name {
  font-weight: 800;
}

.player-row .meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.player-kind {
  display: inline-block;
  width: fit-content;
  margin-top: 0.25rem;
  padding: 0.12rem 0.45rem;
  color: #171717;
  border-radius: 999px;
  background: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.player-kind.admin {
  color: #171717;
  background: var(--accent);
}

.player-kind.robot {
  color: white;
  background: var(--blue);
}

.player-kind.remote {
  color: white;
  background: var(--green);
}

.table-area {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 31, 31, 0.84);
}

.round-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.round-panel > div {
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.round-panel strong {
  font-size: 1.2rem;
}

.round-panel .ghost-button {
  align-self: stretch;
}

.turn-strip,
.hand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.direction,
#handHint {
  color: var(--muted);
  font-size: 0.92rem;
}

.message-box {
  min-height: 2.8rem;
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  color: #171717;
  border-radius: 6px;
  background: var(--accent);
  font-weight: 800;
}

.message-box.bump {
  animation: messageBump 420ms ease;
}

.round-banner {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  width: min(28rem, calc(100vw - 2rem));
  padding: 1rem 1.25rem;
  color: #171717;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.38);
  font-size: clamp(1.7rem, 8vw, 3.4rem);
  font-weight: 950;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.round-banner.show {
  animation: roundBanner 980ms ease both;
}

.play-surface {
  position: relative;
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) minmax(9rem, 1fr) minmax(5.5rem, 8rem);
  gap: 1rem;
  align-items: center;
  min-height: 16rem;
  padding: 1rem;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    #1e5937;
  background-size: 32px 32px;
  overflow: hidden;
}

.play-surface.turn-pulse {
  animation: tablePulse 780ms ease;
}

.deck-button {
  display: grid;
  place-items: center;
  width: min(100%, 9rem);
  aspect-ratio: 3 / 4.15;
  color: #f8f8f8;
  border: 0.35rem solid #f8f8f8;
  background: #1b1b1b;
  box-shadow: 0 0.8rem 0 rgba(0, 0, 0, 0.28);
}

.deck-button:active {
  transform: translateY(0.16rem);
  box-shadow: 0 0.45rem 0 rgba(0, 0, 0, 0.25);
}

.deck-button.launching {
  animation: launcherShake 520ms ease;
}

.deck-button.draw-required {
  outline: 0.24rem solid var(--accent);
  animation: drawPulse 1100ms ease infinite;
}

.deck-top {
  font-size: clamp(1.5rem, 4vw, 2.7rem);
  font-weight: 950;
}

.deck-caption {
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.discard-zone {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
}

.draw-card-particle {
  position: absolute;
  z-index: 3;
  left: clamp(1.5rem, 13%, 7rem);
  top: 42%;
  width: 2.4rem;
  aspect-ratio: 3 / 4.2;
  border: 0.16rem solid white;
  border-radius: 5px;
  background: #1b1b1b;
  box-shadow: 0 0.45rem 1rem rgba(0, 0, 0, 0.28);
  pointer-events: none;
  animation: drawFlight 820ms ease var(--delay) both;
  transform: rotate(var(--tilt));
}

.card {
  position: relative;
  display: grid;
  place-items: center;
  width: 6.7rem;
  min-width: 5.4rem;
  aspect-ratio: 3 / 4.2;
  color: white;
  border: 0.28rem solid white;
  border-radius: 8px;
  box-shadow: 0 0.6rem 1.5rem rgba(0, 0, 0, 0.28);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-appearance: none;
}

.preview-card {
  width: min(12rem, 52vw);
}

.preview-card.card-drop {
  animation: cardDrop 460ms ease;
}

.hand .card {
  animation: handIn 260ms ease both;
  transition: transform 160ms ease, filter 160ms ease;
}

.hand .card.playable:hover,
.hand .card.playable:focus {
  transform: translateY(-0.55rem);
  filter: brightness(1.08);
}

.hand .card.blocked {
  opacity: 0.48;
}

.card::before {
  /* Das helle Oval imitiert die typische Uno-Kartenflaeche ohne Bilddatei. */
  content: "";
  position: absolute;
  inset: 19% 11%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(-24deg);
  pointer-events: none;
}

.card-value,
.card-corner {
  pointer-events: none;
}

.card-value {
  position: relative;
  z-index: 1;
  font-size: clamp(1.6rem, 7vw, 2.5rem);
  font-weight: 950;
  text-shadow: 0 0.12rem 0 rgba(0, 0, 0, 0.3);
}

.card-corner {
  position: absolute;
  z-index: 1;
  top: 0.35rem;
  left: 0.45rem;
  font-size: 0.9rem;
  font-weight: 900;
}

.card.red {
  background: var(--red);
}

.card.yellow {
  color: #151515;
  background: var(--yellow);
}

.card.green {
  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% 100%);
}

.uno-button {
  width: 100%;
  min-height: 4rem;
  color: white;
  background: var(--danger);
  box-shadow: 0 0.5rem 0 #8f231f;
}

.uno-button.active {
  color: #151515;
  background: var(--accent);
  box-shadow: 0 0.5rem 0 #a67805;
}

.color-chooser {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.color-chooser p {
  margin: 0;
  font-weight: 800;
}

.color-buttons {
  display: flex;
  gap: 0.55rem;
}

.color-dot {
  width: 2.4rem;
  aspect-ratio: 1;
  border: 0.2rem solid white;
  border-radius: 999px;
}

.color-dot.red {
  background: var(--red);
}

.color-dot.yellow {
  background: var(--yellow);
}

.color-dot.green {
  background: var(--green);
}

.color-dot.blue {
  background: var(--blue);
}

.hand {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.7rem, 1fr));
  gap: 0.75rem;
  align-items: start;
  margin-top: 0.85rem;
}

.hand button.card {
  border-width: 0.24rem;
}

.log-panel {
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.game-log {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

@media (max-width: 1050px) {
  .game-view,
  .lobby-view {
    grid-template-columns: 1fr;
  }

  .scoreboard,
  .log-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .setup-panel {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .player-config,
  .round-panel {
    grid-template-columns: 1fr;
  }

  .play-surface {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .hand {
    grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr));
    gap: 0.65rem;
  }

  .hand .card {
    width: 100%;
    max-width: 7.3rem;
    justify-self: center;
  }

  .deck-button,
  .uno-button {
    min-height: 4.4rem;
  }

  .turn-strip,
  .hand-header,
  .color-chooser {
    align-items: flex-start;
    flex-direction: column;
  }
}

@keyframes messageBump {
  0% {
    transform: translateY(0);
  }
  42% {
    transform: translateY(-0.22rem);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes roundBanner {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.84);
  }
  18%,
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(1.08);
  }
}

@keyframes tablePulse {
  0% {
    box-shadow: inset 0 0 0 0 rgba(245, 197, 66, 0);
  }
  45% {
    box-shadow: inset 0 0 0 0.35rem rgba(245, 197, 66, 0.36);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(245, 197, 66, 0);
  }
}

@keyframes launcherShake {
  0%,
  100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-5deg) translateX(-0.18rem);
  }
  40% {
    transform: rotate(5deg) translateX(0.18rem);
  }
  60% {
    transform: rotate(-3deg) translateX(-0.12rem);
  }
  80% {
    transform: rotate(3deg) translateX(0.12rem);
  }
}

@keyframes drawPulse {
  0%,
  100% {
    filter: brightness(1);
    transform: translateY(0);
  }
  50% {
    filter: brightness(1.18);
    transform: translateY(-0.12rem);
  }
}

@keyframes drawFlight {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(var(--tilt)) scale(0.72);
  }
  18% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(min(54vw, 33rem), 9.5rem) rotate(var(--tilt-end)) scale(1.05);
  }
}

@keyframes cardDrop {
  0% {
    opacity: 0;
    transform: translateY(-1.2rem) rotate(-7deg) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

@keyframes handIn {
  0% {
    opacity: 0;
    transform: translateY(0.65rem);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes activePlayer {
  from {
    box-shadow: 0 0 0 rgba(245, 197, 66, 0);
  }
  to {
    box-shadow: 0 0 1rem rgba(245, 197, 66, 0.22);
  }
}

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