/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pink:    #ff6eb4;
  --blue:    #5bc8f5;
  --yellow:  #ffe066;
  --white:   #fff;
  --bg:      #fff0f8;
  --card-bg: #ffffff;
  --shadow:  0 4px 24px rgba(0,0,0,0.10);
  --radius:  18px;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  padding: 24px 16px;
  animation: fadeIn 0.35s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Lobby ────────────────────────────────────────────────── */
.title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--pink);
  text-align: center;
  line-height: 1.2;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(255,110,180,0.18);
}
.subtitle {
  color: #aaa;
  margin-bottom: 32px;
  font-size: 1rem;
}

.lobby-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #f0d0e8;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  background: #fdf5fb;
}
input[type="text"]:focus { border-color: var(--pink); }

.lobby-buttons { display: flex; flex-direction: column; gap: 12px; }

.divider {
  text-align: center;
  color: #ccc;
  font-size: 0.85rem;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: #eee;
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; letter-spacing: 3px; font-weight: 700; text-transform: uppercase; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255,110,180,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(255,110,180,0.45); }

.btn-secondary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 14px rgba(91,200,245,0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--pink);
  border: 2px solid var(--pink);
  padding: 8px 18px;
  font-size: 0.9rem;
}

.btn-big {
  background: var(--pink);
  color: #fff;
  font-size: 1.3rem;
  padding: 16px 40px;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(255,110,180,0.4);
  margin-top: 8px;
}

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

/* ── Waiting Screen ───────────────────────────────────────── */
#screen-waiting h2 { color: var(--pink); font-size: 1.8rem; margin-bottom: 28px; }

.room-code-display {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.room-code-display p { color: #999; font-size: 0.95rem; }

.big-code {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 10px;
  color: var(--pink);
  font-family: monospace;
}

.waiting-hint { color: #bbb; font-size: 0.85rem; margin-top: 20px; }

/* ── Scoreboard ───────────────────────────────────────────── */
.scoreboard {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #fff;
  border-radius: 50px;
  padding: 12px 28px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.player-score { display: flex; align-items: center; gap: 10px; }
.player-name { font-weight: 700; font-size: 1rem; color: #555; }
.score {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--pink);
  min-width: 28px;
  text-align: center;
}
.vs { font-weight: 900; color: #ddd; font-size: 1rem; }

.game-title { color: #888; font-size: 1rem; margin-bottom: 20px; font-weight: 500; }

/* ── Box ──────────────────────────────────────────────────── */
#box-container {
  position: relative;
  width: 180px;
  height: 200px;
  margin: 0 auto 24px;
  perspective: 600px;
}

.box { position: relative; width: 180px; height: 200px; }

.box-body {
  position: absolute;
  bottom: 0;
  width: 180px;
  height: 140px;
  background: linear-gradient(135deg, #ffe0f0 0%, #ffc0e0 100%);
  border-radius: 0 0 18px 18px;
  border: 3px solid #ffaad4;
  overflow: hidden;
}
.box-stripe {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 14px,
    rgba(255,110,180,0.15) 14px,
    rgba(255,110,180,0.15) 28px
  );
}

.box-lid {
  position: absolute;
  top: 0;
  width: 180px;
  height: 72px;
  transform-origin: top center;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}
.box-lid-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ffb3d9 0%, #ff80c0 100%);
  border-radius: 18px 18px 0 0;
  border: 3px solid #ff66b2;
  position: relative;
}
.box-lid-inner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 12px;
  background: #ff66b2;
  border-radius: 6px;
}

/* Lid opens upward */
.box.open .box-lid {
  transform: rotateX(-120deg);
}

.box-reveal {
  position: absolute;
  bottom: 30px;
  width: 100%;
  text-align: center;
  z-index: 1;
  transition: opacity 0.4s 0.5s;
}
.box-reveal.hidden { opacity: 0; pointer-events: none; }
.box-reveal:not(.hidden) { opacity: 1; }

.reveal-emoji { font-size: 3.2rem; animation: popIn 0.4s 0.55s both; }

@keyframes popIn {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Guess Cards ──────────────────────────────────────────── */
.guess-area { text-align: center; }
.guess-prompt { color: #888; margin-bottom: 14px; font-size: 0.95rem; }

.cards {
  display: flex;
  gap: 18px;
  justify-content: center;
}

.card {
  background: #fff;
  border: 3px solid #f5d0e8;
  border-radius: var(--radius);
  padding: 22px 28px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  box-shadow: var(--shadow);
}
.card:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.04);
  border-color: var(--pink);
  box-shadow: 0 8px 28px rgba(255,110,180,0.22);
}
.card:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.card.selected { border-color: var(--pink); background: #fff0f8; }
.card.correct  { border-color: #4caf50; background: #f0fff4; }
.card.wrong    { border-color: #f44336; background: #fff5f5; }

.card-emoji  { font-size: 2.4rem; }
.card-label  { font-weight: 700; color: #666; font-size: 0.9rem; }

/* ── Hints ────────────────────────────────────────────────── */
.hint {
  color: #bbb;
  font-size: 0.9rem;
  margin-top: 8px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Result Overlay ───────────────────────────────────────── */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}
.result-overlay.hidden { display: none; }

.result-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 8px 48px rgba(0,0,0,0.18);
  animation: bounceIn 0.45s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 340px;
  width: 90%;
}

@keyframes bounceIn {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.result-emoji   { font-size: 4rem; }
.result-message { font-size: 1.6rem; font-weight: 900; color: var(--pink); }
.result-detail  { font-size: 0.95rem; color: #999; }

/* win shimmer */
.result-card.win .result-message { color: #4caf50; }
.result-card.lose .result-message { color: #f44336; }
.result-card.draw .result-message { color: #ff9800; }

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

@media (max-width: 420px) {
  .title { font-size: 1.8rem; }
  .cards { gap: 10px; }
  .card  { min-width: 100px; padding: 18px 16px; }
  .lobby-card { padding: 28px 20px; }
}
