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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 1rem;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  max-width: 420px;
}

h1 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
  color: #f0c040;
}

h2 {
  font-size: 1.1rem;
  margin: 1.2rem 0 0.6rem;
  color: #ccc;
}

.hidden {
  display: none !important;
}

.card-panel {
  background: #16213e;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

label {
  display: block;
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #334;
  border-radius: 8px;
  background: #0f1a30;
  color: #e0e0e0;
  font-size: 1rem;
  margin-bottom: 1rem;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #f0c040;
}

input[readonly] {
  cursor: text;
  user-select: all;
}

.btn {
  display: block;
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.8;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #f0c040;
  color: #1a1a2e;
}

.btn-small {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: #334;
  color: #e0e0e0;
}

.share-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.5rem;
}

.share-url-row input {
  flex: 1;
  margin-bottom: 0;
}

.share-url-row .btn-small {
  flex-shrink: 0;
  border-radius: 8px;
}

.label {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.3rem;
}

#player-list {
  list-style: none;
  padding: 0;
}

#player-list li {
  padding: 0.6rem 0.8rem;
  background: #0f1a30;
  border-radius: 8px;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#player-list li .host-badge {
  font-size: 0.75rem;
  background: #f0c040;
  color: #1a1a2e;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

#player-list li .you-badge {
  font-size: 0.75rem;
  color: #999;
  margin-left: 0.3rem;
}

#host-controls {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid #223;
}

#waiting-msg {
  margin-top: 1rem;
  text-align: center;
  color: #888;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #e74c3c;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#join-prompt {
  color: #ccc;
  margin-bottom: 0.8rem;
}

#screen-game {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 4rem);
}

#game-header {
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}

#score-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.score-chip {
  font-size: 0.75rem;
  background: #0f1a30;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  color: #bbb;
}

.score-chip.active-turn {
  border: 1px solid #f0c040;
  color: #f0c040;
}

.score-chip.is-me {
  font-weight: 600;
  color: #e0e0e0;
}

#round-info {
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  padding: 0.3rem 0;
}

#table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#other-players {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0.8rem;
}

.opponent-slot {
  text-align: center;
  font-size: 0.75rem;
  color: #999;
}

.opponent-slot .card-count {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ccc;
}

#played-cards {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 3rem;
}

.played-set {
  display: flex;
  gap: 0.2rem;
}

.played-set .label {
  font-size: 0.65rem;
  color: #888;
  text-align: center;
  margin-top: 0.2rem;
}

#round-result {
  margin-top: 0.5rem;
  padding: 0.6rem 1rem;
  background: #1a2a4a;
  border-radius: 8px;
  text-align: center;
  font-size: 0.85rem;
  color: #f0c040;
}

#hand-area {
  flex-shrink: 0;
  padding-top: 0.5rem;
  border-top: 1px solid #223;
}

#my-hand {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  padding: 0.3rem 0 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#my-hand::-webkit-scrollbar {
  display: none;
}

.card {
  flex-shrink: 0;
  width: 52px;
  height: 76px;
  background: #fff;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
  font-family: 'Georgia', serif;
}

.card:active {
  transform: scale(0.95);
}

.card.selected {
  transform: translateY(-8px);
  box-shadow: 0 6px 16px rgba(240, 192, 64, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
  outline: 2px solid #f0c040;
}

.card .card-value {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.card .card-suit {
  font-size: 0.9rem;
  line-height: 1;
  margin-top: 0.1rem;
}

.card.suit-hearts .card-value,
.card.suit-hearts .card-suit,
.card.suit-diamonds .card-value,
.card.suit-diamonds .card-suit {
  color: #c0392b;
}

.card.suit-clubs .card-value,
.card.suit-clubs .card-suit,
.card.suit-spades .card-value,
.card.suit-spades .card-suit {
  color: #2c3e50;
}

.card.suit-ezel {
  background: linear-gradient(135deg, #f0c040 0%, #e8a020 100%);
}

.card.suit-ezel .card-value {
  color: #1a1a2e;
  font-size: 0.75rem;
  font-weight: 700;
}

.card.mini {
  width: 36px;
  height: 52px;
  font-size: 0.7rem;
  cursor: default;
}

.card.mini .card-value {
  font-size: 0.8rem;
}

.card.mini .card-suit {
  font-size: 0.65rem;
}

#action-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

#action-bar .btn {
  flex: 1;
}

#action-bar .btn-small {
  flex: 0 0 auto;
  width: auto;
  padding: 0.85rem 1.5rem;
}

#screen-gameover .card-panel {
  text-align: center;
}

#gameover-title {
  font-size: 1.3rem;
  color: #f0c040;
  margin-bottom: 1rem;
}

#final-scores {
  margin-bottom: 1.5rem;
}

.final-score-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.8rem;
  background: #0f1a30;
  border-radius: 6px;
  margin-bottom: 0.3rem;
}

.final-score-row.winner {
  border: 1px solid #f0c040;
  color: #f0c040;
}
