/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --red:      #E3051B;
  --red-dark: #9c0212;
  --bg:       #ffffff;
  --text:     #1a0005;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow: hidden;
}

/* ============================================================
   SCREEN SYSTEM
   ============================================================ */
.screen {
  display: none;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  width: 100%;
  flex-direction: column;
  align-items: center;
  animation: screenIn 0.25s ease;
}
.screen.active { display: flex; }

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

/* ============================================================
   HOME SCREEN
   ============================================================ */
#screen-home {
  background: #fff;
  color: var(--red);
}

.home-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  height: 100dvh;
  padding: clamp(20px, 7dvh, 64px) 40px clamp(16px, 4.5dvh, 40px);
  padding-inline: clamp(24px, 8vw, 40px);
  width: 100%;
}

/* Hero takes whatever height is left; the title scales to fit it */
.home-hero {
  flex: 1 1 0;
  min-height: 0;
  container-type: size;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.app-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* lines total 1.1233 x width in height, plus three 2px gaps */
  width: min(100cqw, calc((100cqh - 6px) / 1.1233));
}

.title-line {
  position: relative;
  display: block;
  width: 100%;
}
.title-line img {
  position: absolute;
  display: block;
  max-width: none;
}

.home-tagline {
  display: flex;
  align-items: flex-start;
  flex: 0 0 auto;
  padding: clamp(10px, 3dvh, 24px) 0 clamp(14px, 4dvh, 40px);
}

.app-tagline {
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: clamp(0.95rem, 2.6dvh, 1.25rem);
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.5;
  text-align: center;
  width: 100%;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 4.5dvh, 40px);
  width: 100%;
}

.gang-actions {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.4dvh, 20px);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 100px;
  font-family: 'Inter', sans-serif; font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  padding: 1rem 2rem;
  font-size: clamp(1.1rem, 5.4vw, 1.4rem);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  text-transform: uppercase;
}
.btn:active { transform: translate(3px, 3px) !important; }

.btn-primary {
  background: #fff;
  color: var(--red);
  box-shadow: 4px 4px 0 var(--red-dark);
}
.btn-primary:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--red-dark); }
.btn-primary:active { box-shadow: 1px 1px 0 var(--red-dark); }

.btn-outline-white {
  background: transparent;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
}
.btn-outline-white:hover { background: rgba(255,255,255,0.1); }

.btn-red {
  background: var(--red);
  color: #fff;
  box-shadow: 4px 4px 0 var(--red-dark);
}
.btn-red:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--red-dark); }
.btn-red:active { box-shadow: 1px 1px 0 var(--red-dark); }

.btn-solo { height: clamp(52px, 8.5dvh, 72px); }

.btn-join {
  height: 42px;
  padding: 0 1.75rem;
  font-size: clamp(1.1rem, 5.4vw, 1.4rem);
  flex-shrink: 0;
}

.btn-outline-red {
  background: #fff;
  color: var(--red);
  border: 4px solid var(--red);
  box-shadow: 4px 4px 0 var(--red-dark);
  height: 42px;
  padding-block: 0;
}
.btn-outline-red:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--red-dark); }
.btn-outline-red:active { transform: translate(3px,3px) !important; box-shadow: 1px 1px 0 var(--red-dark); }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--red);
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--red);
}

.join-row {
  display: flex;
  gap: 0.6rem;
}

.code-input {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 4px solid var(--red);
  border-radius: 100px;
  color: var(--red);
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: clamp(1.1rem, 5.4vw, 1.5rem);
  letter-spacing: 0.15em;
  text-align: center;
  height: 42px;
  padding: 0 0.5rem;
  text-transform: uppercase;
  transition: box-shadow 0.2s;
}
.code-input::placeholder { color: rgba(227,5,27,0.4); letter-spacing: 0.05em; text-transform: uppercase; }
.code-input:focus { outline: none; box-shadow: 4px 4px 0 var(--red-dark); }

/* ============================================================
   NAME MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  animation: screenIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: #fff;
  border: 4px solid var(--red);
  box-shadow: 8px 8px 0 var(--red-dark);
  border-radius: 28px;
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: 100%;
  max-width: 360px;
}

.modal-title {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 2rem;
  text-align: center;
  color: var(--red);
  text-transform: uppercase;
}

.name-input {
  width: 100%;
  background: #fff;
  border: 3px solid var(--red);
  border-radius: 100px;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 0.85rem 1.25rem;
  text-align: center;
  transition: box-shadow 0.2s;
}
.name-input::placeholder { color: #999; }
.name-input:focus { outline: none; box-shadow: 4px 4px 0 var(--red); }

/* ============================================================
   WAITING ROOM
   ============================================================ */
#screen-waiting {
  background: #fff;
  padding: clamp(1rem, 5dvh, 3rem) 1.75rem clamp(1rem, 4dvh, 3rem);
  justify-content: space-between;
  gap: clamp(0.75rem, 3dvh, 2rem);
}

.waiting-content {
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 3dvh, 2rem);
  width: 100%;
  max-width: 400px;
  flex: 1;
  min-height: 0;
}

/* Player list takes the spare height and scrolls inside itself if a big group joins */
.player-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.room-code-card {
  text-align: center;
  background: var(--red);
  border-radius: 8px;
  padding: clamp(1rem, 3.5dvh, 2rem);
}

.room-code-label {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 0.4rem;
}

.room-code-display {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: clamp(3rem, min(22vw, 11dvh), 6rem);
  color: #fff;
  letter-spacing: 0.18em;
  line-height: 1;
}

.room-code-hint {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1rem;
  color: #fff;
  margin-top: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.player-list-heading {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1.3rem;
  color: var(--red);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 6px 0;
}

.player-list li {
  background: #fff;
  border: 3px solid var(--red);
  box-shadow: 3px 3px 0 var(--red-dark);
  border-radius: 100px;
  padding: clamp(0.35rem, 1.2dvh, 0.65rem) 1.1rem;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1.15rem;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-transform: uppercase;
}
.player-list li::before      { content: '—'; }
.player-list li.done::before { content: '✓'; }

.waiting-footer { width: 100%; text-align: center; }
.waiting-hint {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1.1rem;
  color: var(--red);
  text-transform: uppercase;
}
.host-min-hint {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 0.95rem;
  color: var(--red);
  margin-top: 0.75rem;
  text-transform: uppercase;
}

/* Host/Guest visibility */
body.is-guest .host-only { display: none !important; }
body.is-host  .guest-only { display: none !important; }

/* ============================================================
   VOTING SCREEN
   ============================================================ */
#screen-voting {
  background: #fff;
  justify-content: flex-start;
  padding: 0;
}

.voting-header {
  width: 100%;
  padding: 1.1rem 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #fce4e6;
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--red);
  border-radius: 100px;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.voting-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 40px;
}

.round-label {
  display: flex;
  flex-direction: column;
  padding-top: 3.5px;
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 12px;
  letter-spacing: 1.28px;
  text-transform: uppercase;
  color: var(--red);
}
.round-count { font-size: 10px; }

.voting-prompt {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 14px;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: right;
}

/* ============================================================
   VOTING ARENA — two stacked typographic cards
   ============================================================ */
.voting-arena {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  padding: 0.5rem 1.1rem 1.1rem;
  width: 100%;
}

/* ---- Base card ---- */
.option-card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  position: relative;
  overflow: hidden;
}
.option-card:active { transform: translate(3px, 3px); }

/* ---- Red card (top) ---- */
.option-card--red {
  background: var(--red);
  box-shadow: 5px 5px 0 var(--red-dark);
}
.option-card--red:active { box-shadow: 2px 2px 0 var(--red-dark); }
.option-card--red .option-name { color: #fff; }
.option-card--red .option-quip { color: #fff; }

/* ---- White card (bottom) ---- */
.option-card--white {
  background: #fff;
  border: 4px solid var(--red);
  box-shadow: 5px 5px 0 var(--red-dark);
}
.option-card--white:active { box-shadow: 2px 2px 0 var(--red-dark); }
.option-card--white .option-name { color: var(--red); }
.option-card--white .option-quip { color: var(--red); }

/* ---- Card text ---- */
.option-name {
  font-family: 'Inter', sans-serif; font-weight: 900;
  /* Fallback only: fitCardText() in app.js sets the real size to fill the card */
  font-size: clamp(3.5rem, 14vw, 6.5rem);
  line-height: 0.9;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  word-break: normal;
  overflow-wrap: normal;
  width: 100%;
}

.option-quip {
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.6rem;
  line-height: 1.3;
}

/* ---- Win / lose animations ---- */
.option-card.winner { animation: card-win 0.52s ease-out forwards; }
@keyframes card-win {
  0%   { transform: scale(1); }
  28%  { transform: scale(0.96) translate(2px, 2px); }
  62%  { transform: scale(1.04) translate(-1px, -1px); }
  100% { transform: scale(1); }
}

.option-card.loser { animation: card-lose 0.4s ease-in forwards; }
@keyframes card-lose {
  0%   { transform: scale(1);    opacity: 1; }
  100% { transform: scale(0.88); opacity: 0; }
}

/* ---- VS divider ---- */
.vs-divider {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  padding: 0.55rem 0.25rem;
}
.vs-divider::before,
.vs-divider::after {
  content: '';
  flex: 1;
  height: 3px;
  background: var(--red);
  border-radius: 2px;
}
.vs-text {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 0.95rem;
  color: var(--red);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ============================================================
   RESULTS SCREENS
   ============================================================ */
#screen-solo-results,
#screen-group-results {
  background: var(--red);
  padding: clamp(1rem, 4dvh, 2.5rem) 1.75rem clamp(1rem, 4dvh, 3rem);
  justify-content: center;
}

.results-content {
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 2.5dvh, 1.5rem);
  width: 100%;
  max-width: 440px;
  min-height: 0;
}

.results-title {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: clamp(1.9rem, min(14vw, 8dvh), 5rem);
  color: #fff;
  text-transform: uppercase;
  line-height: 0.9;
  letter-spacing: -0.03em;
}

.results-sub {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1rem;
  color: #fff;
  margin-top: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.results-podium {
  display: flex;
  flex-direction: column;
  gap: clamp(0.4rem, 1.2dvh, 0.7rem);
}

.result-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border-radius: 8px;
  padding: clamp(0.4rem, 1.4dvh, 1rem) 1.25rem;
  box-shadow: 4px 4px 0 var(--red-dark);
  animation: slideUp 0.35s ease both;
}
.result-row:nth-child(1) { animation-delay: 0.08s; }
.result-row:nth-child(2) { animation-delay: 0.18s; }
.result-row:nth-child(3) { animation-delay: 0.28s; }

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

.result-badge {
  width: 16px;
  height: clamp(30px, 6dvh, 52px);
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.25);
}

.result-info { flex: 1; min-width: 0; }

.result-rank-inline {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.15rem;
}

.result-cuisine {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: clamp(1.15rem, 3.2dvh, 1.5rem);
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
}

.result-detail {
  font-size: 0.9rem;
  font-weight: 700;
  color: #333;
  margin-top: 0.2rem;
  letter-spacing: 0.02em;
}

.group-footer { width: 100%; }

/* ============================================================
   GROUP WAITING SCREEN
   ============================================================ */
#screen-group-waiting {
  background: #fff;
  justify-content: center;
  align-items: center;
}

.group-wait-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem 1.75rem;
  text-align: center;
}

.wait-spinner {
  width: 56px;
  height: 56px;
  border: 5px solid #fce4e6;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.group-wait-title {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 2.4rem;
  color: var(--red);
  text-transform: uppercase;
}

.group-wait-sub {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1.1rem;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================
   DESKTOP — centred mobile column
   ============================================================ */
@media (min-width: 600px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(0,0,0,0.12);
    min-height: 100vh;
    min-height: 100dvh;
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-height: 680px) {
  .voting-header { padding: 0.75rem 1.25rem 0.5rem; }
}

@media (min-width: 700px) {
  .voting-arena { padding: 0.75rem 2rem 2rem; }
  .option-card  { padding: 2rem 2.25rem; }
}

/* ============================================================
   SHAKE UTILITY
   ============================================================ */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}
