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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

header {
  text-align: center;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

#scoreboard {
  font-size: 1.1rem;
  color: #aaa;
}

#score {
  font-weight: 700;
  font-size: 1.4rem;
  color: #fff;
}

#progress {
  margin-left: 12px;
  font-size: 0.9rem;
}

/* --- Card --- */

#card-area {
  perspective: 600px;
  width: 180px;
  height: 260px;
}

#card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}

#card.facedown {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  border: 3px solid #444;
}

.card-front {
  background: #fff;
  color: #000;
}

.card-front.red { color: #c0392b; }
.card-front.black { color: #222; }

.card-front .rank-top {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 1.3rem;
  line-height: 1;
}

.card-front .rank-bottom {
  position: absolute;
  bottom: 12px;
  right: 14px;
  font-size: 1.3rem;
  line-height: 1;
  transform: rotate(180deg);
}

.card-front .suit-center {
  font-size: 4rem;
}

.card-back {
  background: linear-gradient(135deg, #16213e, #0f3460);
  color: #556;
  font-size: 5rem;
  transform: rotateY(180deg);
  border-color: #0f3460;
}

/* --- Result flash --- */

#result-flash {
  height: 36px;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

#result-flash.show { opacity: 1; }
#result-flash.correct { color: #2ecc71; }
#result-flash.wrong { color: #e74c3c; }
#result-flash.neutral { color: #888; }

/* --- Controls --- */

#controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

#controls button {
  flex: 1;
  padding: 16px 0;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  background: transparent;
}

#controls button:active {
  transform: scale(0.96);
}

#controls button:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
}

#btn-red {
  color: #e74c3c;
  border-color: #e74c3c;
}

#btn-black {
  color: #ddd;
  border-color: #ddd;
}

#btn-pass {
  color: #888;
  border-color: #555;
}

/* --- Game over --- */

#game-over {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#game-over h2 { font-size: 1.6rem; }

#game-over button {
  padding: 12px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  background: #0f3460;
  color: #eee;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.hidden { display: none !important; }

/* Keyboard hint */
#controls::after {
  content: "← A / D →    S = pass";
  display: block;
  position: absolute;
  bottom: -28px;
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  color: #555;
}

#controls {
  position: relative;
  padding-bottom: 28px;
}