/* ============================================================
   ITO Game — Style Sheet
   Estética inspirada no jogo físico ITO (meeple.br)
   Paleta: slate escuro, amarelo dourado, linhas coloridas
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
  --slate-dark:   #1e2b33;
  --slate:        #2d3a42;
  --slate-light:  #37454d;
  --slate-border: #3f5060;

  --gold:         #f0c54b;
  --gold-light:   #f7d87a;
  --gold-dark:    #c9a02a;

  --red:          #e05a4a;
  --orange:       #e8853a;
  --green:        #4abf7e;
  --teal:         #3bbfae;
  --blue:         #4a8fe8;
  --purple:       #8a5ce8;

  --white:        #ffffff;
  --text-muted:   #8ba5b5;
  --text-dim:     #5a7a8a;

  --radius-sm:    8px;
  --radius-md:    16px;
  --radius-lg:    24px;
  --radius-xl:    40px;

  --shadow-sm:    0 2px 8px rgba(0,0,0,.25);
  --shadow-md:    0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:    0 16px 48px rgba(0,0,0,.45);

  --trans-fast:   150ms ease;
  --trans-med:    300ms ease;
  --trans-slow:   600ms cubic-bezier(.34,1.56,.64,1);
}

html {
  height: 100%;
  font-size: 16px;
}

body {
  min-height: 100vh;
  background-color: var(--slate-dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(240,197,75,.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(74,143,232,.05) 0%, transparent 50%);
  color: var(--white);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input {
  font-family: inherit;
  outline: none;
  border: none;
}

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

.fade-in {
  animation: fadeIn var(--trans-med) ease forwards;
}

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

/* ── Linhas decorativas (SVG animado no background) ──────────── */
.bg-lines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-lines svg {
  width: 100%;
  height: 100%;
}

/* ── Layout de página ────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  gap: 32px;
}

/* ── Logo / Header ───────────────────────────────────────────── */
.ito-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ito-logo__wordmark {
  font-size: clamp(64px, 18vw, 120px);
  font-weight: 900;
  letter-spacing: -.04em;
  color: var(--white);
  line-height: 1;
  text-shadow: 0 4px 24px rgba(240,197,75,.2);
}

.ito-logo__line {
  width: min(240px, 60vw);
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green), var(--blue), var(--purple));
  border-radius: 99px;
  margin: 4px 0;
}

.ito-logo__sub {
  font-size: clamp(13px, 3vw, 16px);
  font-weight: 400;
  color: var(--gold);
  text-align: center;
  letter-spacing: .01em;
}

/* ── Card container (glass) ──────────────────────────────────── */
.glass-card {
  background: rgba(55,69,77,.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
}

/* ── Inputs ──────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.inp {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(30,43,51,.8);
  border: 1.5px solid var(--slate-border);
  color: var(--white);
  font-size: 15px;
  font-weight: 500;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}

.inp:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,197,75,.15);
}

.inp::placeholder { color: var(--text-dim); font-weight: 400; }

/* ── Botões ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  transition: transform var(--trans-fast), opacity var(--trans-fast), box-shadow var(--trans-fast);
  white-space: nowrap;
}

.btn:hover  { transform: translateY(-1px); opacity: .9; }
.btn:active { transform: translateY(0);    opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--slate-dark);
  box-shadow: 0 4px 16px rgba(240,197,75,.3);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(240,197,75,.45); }

.btn-ghost {
  background: rgba(255,255,255,.06);
  color: var(--white);
  border: 1.5px solid var(--slate-border);
}

.btn-ghost:hover { background: rgba(255,255,255,.1); }

.btn-success {
  background: linear-gradient(135deg, var(--green), #38a06a);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(74,191,126,.25);
}

.btn-success:hover { box-shadow: 0 6px 20px rgba(74,191,126,.4); }

.btn-success.confirmed {
  animation: pulse-green 2s ease infinite;
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #b84035);
  color: var(--white);
}

.btn-full { width: 100%; }
.btn-sm   { padding: 8px 16px; font-size: 13px; }

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 4px 16px rgba(74,191,126,.25); }
  50%       { box-shadow: 0 4px 24px rgba(74,191,126,.6); }
}

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(240,197,75,.12);
  color: var(--gold);
  border: 1px solid rgba(240,197,75,.2);
}

/* ── Sala de espera ──────────────────────────────────────────── */
.sala-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.sala-header__title {
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 900;
  letter-spacing: -.04em;
  color: var(--white);
}

.sala-header__id {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.sala-header__id span {
  font-weight: 700;
  color: var(--gold);
  font-family: 'Courier New', monospace;
  letter-spacing: .05em;
}

.sala-header__line {
  width: min(180px, 50vw);
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green));
  border-radius: 99px;
  margin: 6px 0;
}

/* ── Lista de jogadores ──────────────────────────────────────── */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  max-height: 220px;
  overflow-y: auto;
}

.player-list::-webkit-scrollbar { width: 4px; }
.player-list::-webkit-scrollbar-track { background: transparent; }
.player-list::-webkit-scrollbar-thumb { background: var(--slate-border); border-radius: 99px; }

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(30,43,51,.6);
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-border);
  font-size: 14px;
  font-weight: 500;
  animation: fadeIn var(--trans-med) ease forwards;
}

.player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.player-item:nth-child(1) .player-avatar { background: rgba(224,90,74,.25);  color: var(--red); }
.player-item:nth-child(2) .player-avatar { background: rgba(240,197,75,.25); color: var(--gold); }
.player-item:nth-child(3) .player-avatar { background: rgba(74,191,126,.25); color: var(--green); }
.player-item:nth-child(4) .player-avatar { background: rgba(74,143,232,.25); color: var(--blue); }
.player-item:nth-child(5) .player-avatar { background: rgba(138,92,232,.25); color: var(--purple); }
.player-item:nth-child(6) .player-avatar { background: rgba(59,191,174,.25); color: var(--teal); }
.player-item:nth-child(n+7) .player-avatar { background: rgba(255,255,255,.1); color: var(--text-muted); }

.player-nome { flex: 1; }

.player-confirm-icon {
  font-size: 16px;
  transition: opacity var(--trans-fast);
}

/* ── Votação de tema ─────────────────────────────────────────── */
.vote-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.vote-option {
  position: relative;
  padding: 14px 16px;
  background: rgba(30,43,51,.7);
  border: 2px solid var(--slate-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  transition: border-color var(--trans-fast), background var(--trans-fast);
  overflow: hidden;
}

.vote-option__bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: rgba(240,197,75,.1);
  border-radius: var(--radius-md);
  transition: width var(--trans-med);
  pointer-events: none;
}

.vote-option:hover {
  border-color: var(--slate-light);
  background: rgba(55,69,77,.9);
}

.vote-option.selected {
  border-color: var(--gold);
  background: rgba(240,197,75,.08);
}

.vote-option__text { position: relative; z-index: 1; }
.vote-option__count {
  position: relative;
  z-index: 1;
  float: right;
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
}

.vote-status {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Flip Card (número secreto) ──────────────────────────────── */
.flip-wrap {
  perspective: 1000px;
  width: min(180px, 45vw);
  height: min(300px, 60vw);
  cursor: pointer;
  margin: 0 auto;
}

.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.4,0,.2,1);
}

.flip-card.flipped { transform: rotateY(180deg); }

.flip-front,
.flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
}

.flip-front {
  background: linear-gradient(160deg, var(--slate) 0%, #1a2830 100%);
  border: 1.5px solid var(--slate-border);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  padding: 20px;
}

.flip-front__icon { font-size: 32px; margin-bottom: 4px; }

.flip-back {
  transform: rotateY(180deg);
  border: 1.5px solid rgba(240,197,75,.3);
}

.flip-back__number {
  font-size: clamp(48px, 16vw, 80px);
  font-weight: 900;
  letter-spacing: -.04em;
  text-shadow: 0 4px 16px rgba(0,0,0,.3);
}

.flip-back__hint {
  font-size: 12px;
  font-weight: 500;
  opacity: .6;
}

/* ── Área de ordenação ───────────────────────────────────────── */
.order-section {
  width: 100%;
  max-width: 480px;
}

.order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.order-header__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.confirm-counter {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

.order-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

/* Card de ordem de jogador */
.order-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(55,69,77,.7);
  border: 1.5px solid var(--slate-border);
  border-radius: var(--radius-md);
  cursor: grab;
  user-select: none;
  transition: transform var(--trans-fast), box-shadow var(--trans-fast),
              border-color var(--trans-fast), background var(--trans-fast);
  touch-action: none;
}

.order-card:active { cursor: grabbing; }

.order-card.dragging {
  opacity: .5;
  transform: scale(.98);
  cursor: grabbing;
}

.order-card.drag-over {
  border-color: var(--gold);
  background: rgba(240,197,75,.08);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.order-card.confirmed-card {
  border-color: rgba(74,191,126,.4);
  background: rgba(74,191,126,.06);
}

.order-card__drag {
  font-size: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.order-card__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.order-card__name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.order-card__you {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.order-card__check {
  font-size: 18px;
  transition: transform var(--trans-slow), opacity var(--trans-med);
}

.order-card__check.hidden-check { opacity: 0; transform: scale(0); }

/* Rótulos da escala */
.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  padding: 6px 4px 0;
  font-weight: 500;
}

/* ── Tema selecionado (durante o jogo) ───────────────────────── */
.tema-banner {
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  background: rgba(240,197,75,.08);
  border: 1px solid rgba(240,197,75,.2);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 13px;
  color: var(--gold);
  font-weight: 500;
}

.tema-banner strong { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .7; margin-bottom: 4px; }

/* ── Tela de resultado ───────────────────────────────────────── */
.result-section {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.result-title {
  font-size: clamp(28px, 8vw, 48px);
  font-weight: 900;
  margin-bottom: 8px;
}

.result-title.win  { color: var(--green); }
.result-title.loss { color: var(--red); }

.result-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(30,43,51,.8);
  border: 1.5px solid var(--slate-border);
  animation: slideInResult .4s ease forwards;
  opacity: 0;
}

.result-card:nth-child(1) { animation-delay: .1s; }
.result-card:nth-child(2) { animation-delay: .25s; }
.result-card:nth-child(3) { animation-delay: .4s; }
.result-card:nth-child(4) { animation-delay: .55s; }
.result-card:nth-child(5) { animation-delay: .7s; }
.result-card:nth-child(6) { animation-delay: .85s; }

@keyframes slideInResult {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.result-pos {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  width: 20px;
}

.result-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.result-name { flex: 1; font-size: 14px; font-weight: 600; text-align: left; }
.result-num  {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.02em;
}

/* ── Confetti ────────────────────────────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  animation: confettiFall linear forwards;
  z-index: 9999;
}

@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg);  opacity: 0; }
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn var(--trans-med) ease;
}

.modal-box {
  background: var(--slate);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.modal-box h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ── Snackbar / Toast ────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--slate-light);
  border: 1px solid var(--slate-border);
  border-radius: var(--radius-xl);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  transition: transform var(--trans-slow), opacity var(--trans-med);
  opacity: 0;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Nome do apelido salvo ────────────────────────────────────── */
.saved-nome-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  text-align: center;
}

.saved-nome-hint button {
  background: none;
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
}

/* ── Responsivo mobile ───────────────────────────────────────── */
@media (max-height: 700px) {
  .page { gap: 16px; padding: 16px; }
  .flip-wrap { width: 140px; height: 220px; }
  .ito-logo__wordmark { font-size: 48px; }
}

@media (min-width: 768px) {
  .glass-card  { padding: 36px 32px; }
  .order-card  { padding: 14px 18px; }
}