*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --felt-green: #1a472a;
  --felt-dark: #0f2d1a;
  --felt-light: #2d6a4f;
  --gold: #d4a853;
  --gold-light: #f0d78c;
  --cream: #faf8f5;
  --card-white: #fffef9;
  --shadow: rgba(0, 0, 0, 0.35);
  --red: #c0392b;
  --black: #1a1a2e;
  --radius: 12px;
  --card-ratio: 1.4;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--felt-dark);
  color: var(--cream);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#root {
  min-height: 100dvh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

ul {
  list-style: none;
}
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, var(--felt-light) 0%, transparent 60%),
    linear-gradient(180deg, var(--felt-green) 0%, var(--felt-dark) 100%);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.05em;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  overflow: hidden;
}

.app-footer {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.35);
}

/* Buttons */
.btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
  color: var(--felt-dark);
  box-shadow: 0 4px 12px rgba(212, 168, 83, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(212, 168, 83, 0.5);
}

.btn-ghost {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

/* Welcome Screen */
.welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.welcome-content {
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.welcome-logo {
  font-size: 2.5rem;
  letter-spacing: 0.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.welcome-content h1 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 0.25rem;
}

.welcome-subtitle {
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.rules-summary {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.rules-summary h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.rules-summary li {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  padding: 0.35rem 0;
  padding-left: 1rem;
  position: relative;
}

.rules-summary li::before {
  content: '♦';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-size: 0.6rem;
  top: 0.5rem;
}

.start-options p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.75rem;
}

.start-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.score-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
}

.score-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-light);
}

.score-round {
  font-size: 0.75rem;
  color: #4ade80;
}

.score-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.score-target span {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

.score-target small {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
}

/* Game Board */
.game-board {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

/* Cards */
.card {
  position: relative;
  border-radius: 8px;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card-md {
  width: clamp(52px, 14vw, 72px);
  height: calc(clamp(52px, 14vw, 72px) * var(--card-ratio));
}

.card-lg {
  width: clamp(64px, 18vw, 90px);
  height: calc(clamp(64px, 18vw, 90px) * var(--card-ratio));
}

.card-sm {
  width: 40px;
  height: calc(40px * var(--card-ratio));
}

.card-front {
  background: var(--card-white);
  box-shadow:
    0 2px 8px var(--shadow),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.card-front:not(:disabled):hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 10;
}

.card-front.selected {
  transform: translateY(-12px);
  box-shadow: 0 0 0 3px var(--gold), 0 8px 24px var(--shadow);
}

.card-back {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f2440 100%);
  box-shadow: 0 2px 8px var(--shadow);
  border: 2px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.card-back-pattern {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 4px,
      rgba(255, 255, 255, 0.05) 4px,
      rgba(255, 255, 255, 0.05) 8px
    );
  border-radius: 6px;
}

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-size: clamp(0.55rem, 2.5vw, 0.75rem);
  font-weight: 700;
}

.card-corner.top {
  top: 4px;
  left: 5px;
}

.card-corner.bottom {
  bottom: 4px;
  right: 5px;
  transform: rotate(180deg);
}

.card-center {
  font-size: clamp(1.2rem, 5vw, 1.8rem);
}

.red { color: var(--red); }
.black { color: var(--black); }

/* Hand */
.hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0;
}

.hand-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.35rem;
}

.hand-cards {
  display: flex;
  justify-content: center;
  padding: 0 0.5rem;
}

.hand-card-wrapper {
  position: relative;
  margin-left: -16px;
}

.hand-card-wrapper:first-child {
  margin-left: 0;
}

.hand-card-wrapper .card-front:not(:disabled):active {
  transform: translateY(-4px) scale(0.98);
}

/* Table */
.table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0.5rem 0;
  position: relative;
}

.deck-info {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
}

.deck-count {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.table-pile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  width: 100%;
}

.table-empty {
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.85rem;
  font-style: italic;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 2rem 3rem;
}

.table-cards {
  position: relative;
  width: 100px;
  height: 140px;
  margin: 0 auto;
}

.table-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + var(--y, 0px))) rotate(var(--rot, 0deg));
  transform-origin: center bottom;
  transition: transform 0.25s ease;
}

.table-card-slot {
  display: block;
}

/* Kart oynama — elden masaya uçuş */
.card-playing {
  visibility: hidden;
  pointer-events: none;
}

.card-fly-ghost {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  will-change: transform;
}

.card-fly-ghost.card-front,
.card-fly-ghost.card-back {
  transform-origin: center center;
}

.table-pile.capture-flash {
  animation: captureFlash 0.4s ease-out;
}

@keyframes captureFlash {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}

.toast-error {
  border-color: rgba(248,113,113,0.5);
  color: #fca5a5;
}

.game-message {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  min-height: 1.5rem;
  transition: color 0.3s;
}

.game-message.your-turn {
  color: var(--gold-light);
  font-weight: 600;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Round End */
.round-end {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  gap: 1rem;
}

.round-end h2 {
  font-size: 1.75rem;
  color: var(--gold-light);
}

.round-message {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
}

.round-details {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius);
  padding: 1rem;
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.round-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  padding: 0.4rem 0;
  color: rgba(255, 255, 255, 0.65);
}

.round-detail-row span:first-child {
  font-weight: 600;
  color: var(--gold);
  min-width: 40px;
}

.round-actions {
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 480px) {
  .welcome-content h1 {
    font-size: 2.25rem;
  }

  .welcome-logo {
    font-size: 1.75rem;
    letter-spacing: 0.3rem;
  }

  .hand-card-wrapper {
    margin-left: -20px;
  }

  .scoreboard {
    gap: 1rem;
  }

  .score-value {
    font-size: 1.25rem;
  }

  .start-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .start-buttons .btn {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .app-header {
    padding: 1rem 2rem;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .app-main {
    padding: 1rem;
  }

  .hand-card-wrapper {
    margin-left: -12px;
  }

  .hand-card-wrapper .card-front:not(:disabled):hover {
    transform: translateY(-12px);
  }
}

@media (min-height: 700px) {
  .table-pile {
    min-height: 160px;
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .welcome {
    padding: 0.5rem;
  }

  .welcome-content h1 {
    font-size: 1.75rem;
  }

  .rules-summary {
    margin-bottom: 1rem;
    padding: 0.75rem;
  }

  .app-footer {
    display: none;
  }
}

/* Mode select */
.mode-select {
  margin-bottom: 1.5rem;
}

.mode-btn {
  width: 100%;
  font-size: 1rem;
  padding: 0.85rem;
}

.mode-divider {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.75rem;
}

/* Lobby */
.lobby,
.waiting-room {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lobby-content,
.waiting-content {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.lobby-back {
  margin-bottom: 1rem;
}

.lobby-content h2,
.waiting-content h2 {
  font-size: 1.75rem;
  color: var(--gold-light);
  margin-bottom: 0.25rem;
}

.lobby-subtitle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 1.5rem;
}

.lobby-name {
  text-align: left;
  margin-bottom: 1rem;
}

.lobby-name label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.35rem;
}

.lobby-name input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--cream);
  font-size: 1rem;
  font-family: inherit;
}

.lobby-name input:focus {
  outline: none;
  border-color: var(--gold);
}

.room-code-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-align: center;
}

.lobby-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lobby-tab {
  flex: 1;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.15s;
}

.lobby-tab.active {
  color: var(--gold-light);
  background: rgba(212, 168, 83, 0.15);
  border-color: rgba(212, 168, 83, 0.35);
}

.lobby-panel {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.75rem;
}

.lobby-action {
  width: 100%;
  margin-top: 1rem;
}

.lobby-error {
  margin-top: 1rem;
  color: #f87171;
  font-size: 0.85rem;
}

/* Waiting room */
.waiting-label {
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.75rem;
}

.room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px dashed rgba(212, 168, 83, 0.4);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.room-code-display span {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--gold-light);
}

.copy-btn {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
}

.waiting-info {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 1.25rem;
}

.waiting-players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.waiting-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.waiting-player.waiting-empty {
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.player-dot.pulse {
  background: var(--gold);
  animation: pulse 1.5s ease-in-out infinite;
}

.waiting-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.room-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.card.playable:not(:disabled) {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card.playable:not(:disabled):hover {
  transform: translateY(-14px) scale(1.05);
  box-shadow: 0 12px 28px var(--shadow);
}

/* Timer */
.turn-timer-wrap {
  margin: 0.5rem auto 0;
  opacity: 0.6;
  transition: opacity 0.3s;
}

.turn-timer-wrap.active {
  opacity: 1;
}

#turn-timer.urgent {
  color: #f87171;
}

.timer-label {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
}

#turn-timer {
  font-weight: 700;
  color: var(--gold-light);
}

/* Live score */
.score-live {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.45);
  margin-top: 0.15rem;
  text-align: center;
  line-height: 1.3;
}

.score-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
}

.score-rules span {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.15);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.round-num {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.15rem;
}

/* Toast */
.toast-box {
  position: fixed;
  top: 4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 1.25rem;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(-12px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  background: rgba(0,0,0,0.85);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-pisti {
  background: linear-gradient(135deg, #b8860b, #d4a853);
  color: var(--felt-dark);
  border: none;
  box-shadow: 0 4px 20px rgba(212,168,83,0.5);
}

.toast-capture {
  border-color: rgba(74,222,128,0.4);
  color: #4ade80;
}
