.screen {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

/* ---------- Landing ---------- */
#screen-landing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  /* Safety net: the page itself is locked from scrolling everywhere (see
     base.css), so a screen whose content runs taller than the viewport (e.g.
     a long roster + all 4 pack descriptions on a small phone) still needs
     somewhere to scroll - internally, within itself, rather than never. The
     game screen deliberately has no such safety net: nothing on it should
     ever move except the hand row sliding. */
  overflow-y: auto;
}

.landing-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.app-title {
  text-align: center;
  font-size: 2.6rem;
  letter-spacing: 0.05em;
  color: var(--color-red);
  text-shadow: 2px 2px 0 var(--color-yellow);
}

.app-title-sub {
  display: block;
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-shadow: none;
  text-transform: uppercase;
}

.reconnecting-notice {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--text-dim);
}

.landing-forms {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.landing-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.landing-form input {
  padding: 0.7em 1em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}

/* ---------- Lobby ---------- */
#screen-lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto; /* safety net, see #screen-landing */
}

.lobby-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.room-code-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.room-code-row strong {
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  color: var(--text);
}

.roster {
  list-style: none;
  margin: 0 0 1.5rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.roster li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.5em 0.8em;
}

.roster .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}

.roster .dot.connected {
  background: #3ecf6e;
}

.roster .badge {
  font-size: 0.7rem;
  background: var(--accent);
  color: #fff;
  padding: 0.15em 0.5em;
  border-radius: 999px;
}

.roster .kick-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.packs-panel {
  margin-bottom: 1.5rem;
}

.pack-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.6rem;
  align-items: baseline;
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border);
}

.pack-toggle:last-child {
  border-bottom: none;
}

.pack-name {
  font-weight: 600;
}

.pack-desc {
  grid-column: 2;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.lobby-actions {
  display: flex;
  gap: 0.6rem;
}

.lobby-actions .btn {
  flex: 1;
}

/* ---------- Game ---------- */
#screen-game {
  position: relative;
}

.game-grid {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100vh;
  height: 100dvh;
}

.opponents-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.opponent-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 0.4em 0.9em;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.opponent-chip.current-turn {
  border-color: var(--accent);
}

.opponent-chip.next-turn {
  border-color: var(--text-dim);
  border-style: dashed;
}

.next-turn-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1em 0.5em;
}

.opponent-chip.vulnerable {
  border-color: var(--color-red);
  animation: vulnerablePulse 1.1s ease-in-out infinite;
}

.opponent-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
}

.opponent-chip .dot.connected {
  background: #3ecf6e;
}

.opponent-chip .catch-btn {
  border: none;
  background: var(--color-red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3em 0.8em;
  animation: catchPopIn 0.25s ease-out, catchAttention 1s ease-in-out 0.25s infinite;
}


.table-area {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1rem;
  gap: 1rem;
}

.table-left {
  display: flex;
  justify-content: center;
}

.table-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.pile.draw-pile {
  position: relative;
  background: none;
  border: none;
  padding: 0;
}

.pile-count {
  position: absolute;
  bottom: -0.6em;
  right: -0.6em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1em 0.5em;
  font-size: 0.75rem;
}

.table-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.direction-indicator {
  font-size: 1.4rem;
  color: var(--text-dim);
}

.direction-indicator.reversed {
  transform: scaleX(-1);
}

.direction-indicator.spin-once {
  animation: directionSpin 0.6s ease-in-out;
}

.active-color-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.active-color-chip .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.penalty-badge {
  position: absolute;
  top: -0.6rem;
  right: -2.2rem;
  background: var(--color-red);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 999px;
  padding: 0.2em 0.6em;
}

.penalty-badge.pop {
  animation: penaltyPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.special-effect-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  padding: 0.5em 1.2em;
  border-radius: 999px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 40;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.special-effect-overlay.fx-active {
  animation: fxPop 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.special-effect-overlay.fx-skip { background: radial-gradient(circle, #ff6a5c, var(--color-red)); }
.special-effect-overlay.fx-reverse { background: radial-gradient(circle, #7a8dff, #4a55c9); }
.special-effect-overlay.fx-draw { background: radial-gradient(circle, #ffb03a, var(--color-red)); }
.special-effect-overlay.fx-defense { background: radial-gradient(circle, #4fe0c4, #1f8f79); }
.special-effect-overlay.fx-swap { background: radial-gradient(circle, #c78bff, #7a3fc9); }
.special-effect-overlay.fx-wild {
  background: conic-gradient(var(--color-red), var(--color-yellow), var(--color-green), var(--color-blue), var(--color-red));
}

.turn-banner {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

.turn-banner.your-turn {
  animation: turnGlow 1.4s ease-in-out 2;
}

.turn-countdown {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 0.4em;
}

.next-player-text {
  display: block;
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.8rem;
  margin-top: 0.15em;
}

.hand-area {
  background: var(--surface);
  padding: 0.6rem 0.6rem 0.9rem;
}

.hand-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin: 0 auto 0.6rem;
  width: fit-content;
  /* Locked front-and-center above the hand: stays put and stays clickable
     regardless of hand scrolling or any flying-card animation passing behind it. */
  position: relative;
  z-index: 70;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.6rem;
}

/* 7 cards per row; the 8th+ wraps onto additional rows below rather than
   sliding or overlap-compressing. Grid columns are fr-based (not a fixed
   --card-w) so 7 cards always fit the available width on any screen size -
   no horizontal overflow, no need to slide. */
.hand-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
  align-items: start;
  justify-items: center;
  /* Roomy top padding keeps the hover-lift transform from being visually
     clipped if the hand ever grows tall enough to need its own scroll. */
  padding: 1rem 0.5rem 0.8rem;
  max-height: 46vh;
  overflow-y: auto;
  user-select: none;
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.hand-row .card {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
}

.finished-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.finished-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.finished-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.5rem;
}

.log-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(320px, 90vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.log-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem;
  border-bottom: 1px solid var(--border);
}

#logList {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.9rem;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 150;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 1.25rem;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.modal-actions .btn {
  flex: 1;
}

.modal-section {
  margin-bottom: 1rem;
}

.modal-section h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-swatches {
  display: flex;
  gap: 0.6rem;
}

.color-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
}

.color-swatch.selected {
  border-color: var(--text);
}

.target-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.target-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0.5em 0.8em;
  cursor: pointer;
}

.target-option.selected {
  border-color: var(--accent);
}

.give-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Animations ---------- */
@keyframes vulnerablePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 71, 58, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(229, 71, 58, 0); }
}

@keyframes catchPopIn {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes catchAttention {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes directionSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes penaltyPop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes fxPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  35% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes turnGlow {
  0%, 100% { background: var(--surface); }
  50% { background: color-mix(in srgb, var(--accent) 35%, var(--surface)); }
}
