* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: linear-gradient(160deg, #eef5ff, #fdf3e7);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app { width: 100%; max-width: 720px; padding: 20px; }

.screen { text-align: center; }
.screen.hidden { display: none; }

h1 { margin-bottom: 4px; }
.sub { color: #555; margin-top: 0; }
.hint { color: #888; font-size: 0.85em; }

#authUsername, #authPassword {
  display: block;
  width: 260px;
  font-size: 1.1em;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #ccc;
  margin: 8px auto;
}

.auth-buttons { margin-top: 10px; }

button {
  font-size: 1.05em;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  background: #4a7dff;
  color: white;
  cursor: pointer;
  margin: 4px;
}
button:hover { background: #3a66e0; }
button:disabled { background: #aaa; cursor: not-allowed; }
button.secondary { background: #e7eaf0; color: #333; }
button.secondary:hover { background: #d9dde6; }

.error { color: #d23; font-weight: bold; }

.spinner {
  width: 40px; height: 40px;
  margin: 24px auto;
  border: 5px solid #ddd;
  border-top-color: #4a7dff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hud {
  display: flex;
  justify-content: space-between;
  font-size: 0.95em;
  color: #444;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.hud-item {
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#oppArea { display: flex; justify-content: center; margin-bottom: 6px; min-height: 46px; }
#oppHandRow { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.mini-card-back {
  width: 24px;
  height: 34px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #6c7a96, #6c7a96 5px, #5a6680 5px, #5a6680 10px);
  box-shadow: 0 2px 3px rgba(0,0,0,0.25);
}

#board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 16px 0;
}

.card-slot {
  width: 110px;
  height: 150px;
}

.deck-pile {
  position: relative;
  width: 80px;
  height: 110px;
}
.deck-card {
  position: absolute;
  width: 80px;
  height: 110px;
  border-radius: 10px;
  background: repeating-linear-gradient(45deg, #6c7a96, #6c7a96 10px, #5a6680 10px, #5a6680 20px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);
  border: 2px solid rgba(255,255,255,0.3);
}
.deck-card-1 { top: 0; left: 0; }
.deck-card-2 { top: -4px; left: 3px; }
.deck-card-3 { top: -8px; left: 6px; }
.deck-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.1em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 5;
}

/* 카드 뒤집기(flip) 구조 */
.flip-card { perspective: 900px; }
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(.3,.1,.3,1), opacity 0.4s ease;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-card.discard .flip-inner { opacity: 0; transform: rotateY(180deg) translateY(40px) scale(0.6); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.flip-back {
  font-size: 1.3em;
  background: repeating-linear-gradient(45deg, #6c7a96, #6c7a96 10px, #5a6680 10px, #5a6680 20px);
}
.flip-front { transform: rotateY(180deg); }
.boost-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff5252;
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 10;
}

.flying-card {
  position: fixed;
  z-index: 999;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
  pointer-events: none;
  transition: transform 0.45s ease;
}

.card-img { width: 62%; max-height: 60%; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25)); }
.card-rank { font-size: 1.3em; margin-top: 2px; }
.card-name { font-size: 0.5em; margin-top: 2px; padding: 0 6px; text-align: center; }

#boostRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.boost-label { font-size: 0.85em; color: #666; }
.boost-btn {
  background: #ffb300;
  padding: 6px 14px;
  font-size: 0.95em;
}
.boost-btn:hover { background: #e6a100; }
.boost-btn.selected { background: #ff5252; box-shadow: 0 0 0 3px rgba(255,82,82,0.35) inset; }
.boost-btn.used { background: #ccc; cursor: not-allowed; opacity: 0.6; }

#statusLine {
  margin: 10px 0 18px;
  font-weight: bold;
  color: #333;
  min-height: 1.4em;
}

#hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.hand-card {
  width: 90px;
  height: 124px;
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.15);
  transition: transform 0.15s ease;
}
.hand-card:hover { transform: translateY(-6px); }
.hand-card.disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.hand-card.pop-in { animation: popIn 0.3s ease; }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.hand-card .card-img { width: 58%; max-height: 55%; }
.hand-card .card-rank { font-size: 1.2em; margin-top: 2px; }
.hand-card .card-name { font-size: 0.45em; margin-top: 2px; padding: 0 4px; text-align: center; }

#overTitle { font-size: 1.8em; }
