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

:root {
  --bg: #120d08;
  --bg-deep: #1a0f09;
  --panel: rgba(35, 21, 15, 0.82);
  --line: rgba(255, 240, 219, 0.12);
  --text: #fff6e8;
  --muted: rgba(255, 246, 232, 0.68);
  --muted-soft: rgba(255, 246, 232, 0.44);
  --pink: #ff4d8d;
  --orange: #ff8a1f;
  --cyan: #5ce1e6;
  --gold: #ffd166;
  --green: #31dc90;
  --red: #ff5d5d;
  --shadow-hard: 5px 5px 0 #000;
  --shadow-soft: 0 24px 64px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

html,
body {
  min-height: 100%;
  font-family: "Sora", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 77, 141, 0.18), transparent 34%),
    radial-gradient(circle at 90% 20%, rgba(92, 225, 230, 0.14), transparent 28%),
    linear-gradient(180deg, #130b06 0%, #1a100a 52%, #0f0905 100%);
  color: var(--text);
  overflow-x: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  animation: fade-up 0.28s ease both;
}

.screen.active {
  display: flex;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro-screen {
  position: relative;
  justify-content: flex-start;
  padding: 28px 16px calc(34px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
}

.intro-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.46;
  animation: blob-float 9s ease-in-out infinite alternate;
}

.b1 {
  width: 280px;
  height: 280px;
  top: -90px;
  left: -80px;
  background: rgba(255, 77, 141, 0.75);
}

.b2 {
  width: 220px;
  height: 220px;
  top: 24%;
  right: -56px;
  background: rgba(92, 225, 230, 0.62);
  animation-delay: -3s;
}

.b3 {
  width: 260px;
  height: 260px;
  bottom: -110px;
  left: 18%;
  background: rgba(255, 138, 31, 0.58);
  animation-delay: -5s;
}

@keyframes blob-float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(18px, 26px, 0) scale(1.08); }
}

.intro-content {
  position: relative;
  z-index: 1;
  width: min(100%, 1100px);
  margin: 0 auto;
  padding-block: max(8px, 2vh);
}

.intro-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(290px, 420px);
  gap: 22px;
  align-items: stretch;
}

.intro-copy {
  padding: clamp(10px, 3vw, 22px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.28);
  background: rgba(255, 248, 236, 0.08);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  backdrop-filter: blur(14px);
}

.intro-title {
  margin-top: 18px;
  display: grid;
  gap: 6px;
  line-height: 0.96;
}

.it-loteria {
  font-family: "Bebas Neue", "Impact", sans-serif;
  font-size: clamp(4.2rem, 13vw, 8.8rem);
  letter-spacing: 0.04em;
  color: #fff1d3;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), 0 0 28px rgba(255, 138, 31, 0.22);
}

.it-sub {
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
}

.intro-lead {
  max-width: 540px;
  margin-top: 18px;
  color: var(--muted);
  font-size: clamp(0.98rem, 2.2vw, 1.12rem);
  line-height: 1.65;
}

.intro-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.highlight-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.08), rgba(255, 248, 236, 0.04));
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.highlight-kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.highlight-text {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
}

.entry-card,
.name-card,
.pin-card {
  position: relative;
  border-radius: var(--radius-xl);
  padding: 22px;
  border: 1px solid rgba(255, 240, 219, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04)), var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.entry-card::before,
.name-card::before,
.pin-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.26), rgba(255, 77, 141, 0.24), rgba(92, 225, 230, 0.22));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.entry-card-header {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.entry-card-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.entry-card-text,
.pin-desc {
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.intro-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-pill,
.game-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 236, 0.06);
  color: var(--muted-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.game-status {
  margin-top: 16px;
  width: fit-content;
}

.game-status.live {
  color: var(--pink);
  border-color: rgba(255, 77, 141, 0.34);
  background: rgba(255, 77, 141, 0.1);
}

.pin-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.25), rgba(255, 138, 31, 0.2));
  font-size: 1.7rem;
  margin-bottom: 14px;
}

.pin-inputs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 14px;
}

.pin-digit,
.name-input {
  width: 100%;
  border: 1.5px solid rgba(255, 240, 219, 0.14);
  background: rgba(255, 248, 236, 0.08);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.pin-digit {
  height: 66px;
  border-radius: 18px;
  text-align: center;
  font-size: 1.65rem;
  font-weight: 800;
}

.pin-digit:focus,
.name-input:focus,
.chat-input:focus {
  border-color: rgba(92, 225, 230, 0.7);
  box-shadow: 0 0 0 4px rgba(92, 225, 230, 0.12);
  transform: translateY(-1px);
}

.pin-error {
  color: #ffb0b0;
  min-height: 22px;
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.name-card {
  display: grid;
  gap: 14px;
}

.name-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.name-input {
  min-height: 58px;
  border-radius: 16px;
  padding: 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
}

.name-input::placeholder,
.chat-input::placeholder {
  color: rgba(255, 246, 232, 0.36);
}

.btn-primary,
.btn-loteria,
.chat-send {
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.18s ease;
}

.btn-primary {
  width: 100%;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: #1b0f08;
  font-size: 0.96rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: var(--shadow-hard), 0 18px 34px rgba(255, 77, 141, 0.24);
}

.btn-primary:hover:not(:disabled),
.btn-loteria:hover,
.chat-send:hover {
  transform: translate(-2px, -2px);
}

.btn-primary:active:not(:disabled),
.btn-loteria:active,
.chat-send:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn-primary:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-arrow {
  font-size: 1.15rem;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 24;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(17, 10, 7, 0.82);
  border-bottom: 1px solid rgba(255, 240, 219, 0.08);
  backdrop-filter: blur(18px);
}

.back-btn,
.tts-btn {
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 240, 219, 0.12);
  background: rgba(255, 248, 236, 0.06);
  color: var(--text);
  cursor: pointer;
}

.back-btn {
  font-size: 1.2rem;
}

.top-bar-center {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: center;
}

.top-bar-title {
  font-family: "Bebas Neue", "Impact", sans-serif;
  color: var(--gold);
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  line-height: 0.95;
}

.top-bar-sub {
  color: var(--muted-soft);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-right {
  min-width: 42px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}

#screen-picker,
#screen-board {
  background: radial-gradient(circle at top right, rgba(255, 138, 31, 0.12), transparent 20%), linear-gradient(180deg, #120b06 0%, #171009 100%);
}

.picker-intro-text {
  padding: 16px 16px 8px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  font-size: 0.92rem;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 10px 12px 14px;
}

.picker-loading {
  grid-column: 1 / -1;
  padding: 44px 14px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 240, 219, 0.14);
  text-align: center;
  color: var(--muted);
}

.pc {
  overflow: hidden;
  border-radius: 16px;
  border: 1.5px solid rgba(255, 240, 219, 0.12);
  background: rgba(255, 248, 236, 0.06);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.pc:hover:not(.taken) {
  transform: translateY(-3px);
  border-color: rgba(255, 209, 102, 0.36);
}

.pc.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.26), 0 18px 32px rgba(0, 0, 0, 0.24);
}

.pc.taken {
  opacity: 0.48;
  filter: grayscale(0.5);
  cursor: not-allowed;
}

.pc.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.pc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 9px 7px;
  background: linear-gradient(135deg, rgba(255, 138, 31, 0.16), rgba(255, 77, 141, 0.16));
}

.pc-head.taken-head {
  background: linear-gradient(135deg, rgba(255, 93, 93, 0.24), rgba(122, 26, 26, 0.28));
}

.pc-label,
.pc-taken-tag {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pc-label {
  color: var(--gold);
}

.pc-num {
  font-size: 1rem;
  font-weight: 800;
}

.pc-taken-tag {
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 93, 93, 0.44);
  color: var(--red);
}

.pc-mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 6px;
}

.pc-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 248, 236, 0.05);
  border: 1px solid color-mix(in srgb, var(--mc) 32%, transparent);
  font-size: clamp(0.9rem, 4vw, 1.1rem);
}

.pc-foot {
  padding: 6px 8px 10px;
  color: var(--muted-soft);
  font-size: 0.68rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.picker-bottom {
  position: sticky;
  bottom: 0;
  padding: 8px 12px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(18, 11, 6, 0), rgba(18, 11, 6, 0.95) 38%);
}

.btn-confirm:disabled {
  background: rgba(255, 248, 236, 0.1);
  color: rgba(255, 246, 232, 0.4);
}

.current-card-bar {
  padding: 10px 12px 6px;
}

.ccb-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-radius: 18px;
  border: 1px solid rgba(255, 240, 219, 0.1);
  background: rgba(255, 248, 236, 0.06);
  padding: 12px 14px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ccb-inner.flash {
  animation: pulse 0.54s ease;
}

@keyframes pulse {
  50% { transform: scale(1.015); }
}

.ccb-emoji {
  font-size: 2rem;
}

.ccb-info {
  min-width: 0;
}

.ccb-name {
  display: block;
  font-size: 1rem;
  font-weight: 800;
}

.ccb-desc {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.ccb-num {
  color: var(--muted-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.carton-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px 12px;
}

.carton-frame {
  width: min(100%, 620px);
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, #26150f 0%, #1a0f0a 100%);
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 7px #1a1009, 0 24px 70px rgba(0, 0, 0, 0.55);
}

.carton-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255, 138, 31, 0.24), rgba(255, 77, 141, 0.14));
  border-bottom: 1px solid rgba(255, 209, 102, 0.24);
}

.carton-badge-left,
.carton-player-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.carton-badge-left {
  color: var(--gold);
}

.carton-header-mid {
  min-width: 0;
  text-align: center;
}

.carton-brand {
  display: block;
  font-family: "Bebas Neue", "Impact", sans-serif;
  font-size: clamp(1.1rem, 4vw, 1.7rem);
  letter-spacing: 0.1em;
  color: #fff3d9;
}

.carton-edition {
  display: block;
  color: var(--muted-soft);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
}

.carton-player-label {
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--cyan);
  text-align: right;
}

.carton-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  background: rgba(255, 248, 236, 0.04);
}

.cell {
  position: relative;
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 6px 4px 5px;
  border-radius: 12px;
  border: 1px solid rgba(255, 209, 102, 0.18);
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.08), rgba(255, 248, 236, 0.04));
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 24%, color-mix(in srgb, var(--cc) 14%, transparent), transparent 65%);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.cell:hover {
  transform: scale(1.03);
  border-color: color-mix(in srgb, var(--cc) 60%, white 10%);
}

.cell:hover::before {
  opacity: 1;
}

.cell-num,
.cell-name,
.cell-emoji {
  position: relative;
  z-index: 1;
}

.cell-num {
  font-size: 0.58rem;
  font-weight: 700;
  color: rgba(255, 209, 102, 0.78);
}

.cell-emoji {
  font-size: clamp(1rem, 4.7vw, 1.55rem);
  line-height: 1;
}

.cell-name {
  font-size: clamp(0.4rem, 1.45vw, 0.55rem);
  line-height: 1.12;
  text-align: center;
  color: var(--text);
}

.cell.stamped {
  border-color: rgba(255, 209, 102, 0.52);
  background: linear-gradient(180deg, rgba(255, 77, 141, 0.22), rgba(255, 138, 31, 0.12));
}

.cell.stamped::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.6rem, 7vw, 2.7rem);
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.75);
  animation: stamp-pop 0.26s cubic-bezier(0.2, 1.2, 0.4, 1) both;
  z-index: 2;
}

.cell.stamped .cell-emoji,
.cell.stamped .cell-name {
  opacity: 0.35;
}

@keyframes stamp-pop {
  from { opacity: 0; transform: scale(0.5) rotate(-14deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.cell.highlighted {
  border-color: var(--cyan) !important;
  box-shadow: 0 0 18px rgba(92, 225, 230, 0.36);
}

.carton-footer {
  padding: 8px 10px;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--muted-soft);
  background: rgba(0, 0, 0, 0.2);
}

.board-actions {
  padding: 6px 12px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
}

.win-indicator {
  min-height: 20px;
  text-align: center;
  font-size: 0.94rem;
  font-weight: 800;
}

.action-row {
  display: flex;
  gap: 10px;
}

.btn-loteria {
  flex: 1;
  min-height: 58px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #49ef9f, #b6ff6f);
  color: #15100b;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: var(--shadow-hard), 0 18px 34px rgba(49, 220, 144, 0.24);
}

.board-hint {
  text-align: center;
  color: var(--muted-soft);
  font-size: 0.82rem;
}

.chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 46;
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: #1a0f08;
  font-size: 1.5rem;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
  cursor: pointer;
}

.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -3px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 0.74rem;
  font-weight: 800;
}

.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(16, 10, 7, 0.95);
  backdrop-filter: blur(20px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 1px solid rgba(255, 240, 219, 0.1);
}

.chat-title {
  font-size: 1rem;
  font-weight: 800;
}

.chat-close {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 240, 219, 0.12);
  background: rgba(255, 248, 236, 0.05);
  color: var(--text);
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty {
  color: var(--muted);
  text-align: center;
  margin: auto 0;
}

.chat-msg {
  max-width: min(86%, 420px);
  padding: 12px 14px;
  border-radius: 18px;
  display: grid;
  gap: 6px;
}

.chat-player {
  align-self: flex-end;
  background: rgba(255, 77, 141, 0.16);
  border: 1px solid rgba(255, 77, 141, 0.24);
}

.chat-cantor {
  align-self: flex-start;
  background: rgba(92, 225, 230, 0.14);
  border: 1px solid rgba(92, 225, 230, 0.24);
}

.chat-sender {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
}

.chat-text {
  line-height: 1.5;
  word-break: break-word;
}

.chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 240, 219, 0.1);
}

.chat-input {
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(255, 240, 219, 0.12);
  background: rgba(255, 248, 236, 0.06);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.chat-send {
  min-width: 52px;
  min-height: 52px;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  color: #1b1109;
  font-size: 1.1rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: min(100%, 380px);
  border-radius: 24px;
  border: 1px solid rgba(255, 209, 102, 0.22);
  background: linear-gradient(180deg, rgba(41, 23, 17, 0.98), rgba(25, 15, 11, 0.98));
  padding: 34px 22px 24px;
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

#modalConfetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  animation: confetti-fall ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

.modal-emoji {
  font-size: 3.2rem;
}

.modal-title {
  margin-top: 10px;
  font-family: "Bebas Neue", "Impact", sans-serif;
  font-size: 2.4rem;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.modal-sub {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 920px) {
  .intro-shell {
    grid-template-columns: 1fr;
  }

  .intro-copy {
    order: 1;
    text-align: center;
    align-items: center;
  }

  .intro-lead {
    margin-left: auto;
    margin-right: auto;
  }

  .entry-card,
  .name-card,
  .pin-card {
    order: 2;
  }
}

@media (max-width: 700px) {
  .intro-screen {
    padding-top: calc(20px + env(safe-area-inset-top));
  }

  .intro-highlights {
    grid-template-columns: 1fr;
  }

  .intro-copy {
    padding: 6px 0 0;
  }

  #screen-pin .intro-shell,
  #screen-intro .intro-shell {
    gap: 16px;
  }

  #screen-pin .intro-lead,
  #screen-intro .intro-lead {
    line-height: 1.5;
  }

  .chat-msg {
    max-width: 92%;
  }
}

@media (max-width: 480px) {
  .intro-screen {
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }

  .entry-card,
  .name-card,
  .pin-card {
    padding: 18px;
    border-radius: 22px;
  }

  .pin-inputs {
    gap: 8px;
  }

  .pin-digit {
    height: 56px;
    border-radius: 16px;
    font-size: 1.3rem;
  }

  .entry-card-header {
    gap: 6px;
    margin-bottom: 14px;
  }

  .entry-card-title {
    font-size: 1.3rem;
  }

  .pin-desc,
  .entry-card-text,
  .intro-lead,
  .highlight-text {
    font-size: 0.9rem;
  }

  #screen-pin .intro-copy {
    gap: 0;
  }

  #screen-pin .intro-highlights {
    gap: 10px;
    margin-top: 18px;
  }

  #screen-pin .highlight-card {
    padding: 13px 14px;
  }

  #screen-pin .pin-card {
    padding: 16px;
  }

  #screen-pin .pin-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 10px;
    font-size: 1.45rem;
  }

  #screen-pin .btn-primary,
  #screen-intro .btn-primary {
    min-height: 52px;
  }

  .picker-intro-text {
    padding-left: 12px;
    padding-right: 12px;
  }

  .picker-grid {
    gap: 10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .top-bar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .top-bar-title {
    font-size: 1.18rem;
  }

  .ccb-inner {
    gap: 10px;
    padding: 11px 12px;
  }

  .ccb-emoji {
    font-size: 1.75rem;
  }

  .carton-header {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "left right"
      "mid mid";
  }

  .carton-badge-left {
    grid-area: left;
  }

  .carton-header-mid {
    grid-area: mid;
  }

  .carton-player-label {
    grid-area: right;
    justify-self: end;
  }

  .carton-grid {
    gap: 3px;
    padding: 6px;
  }

  .cell {
    padding: 5px 3px 4px;
    border-radius: 10px;
  }

  .cell-emoji {
    font-size: clamp(0.9rem, 5.4vw, 1.2rem);
  }

  .cell-name {
    font-size: clamp(0.38rem, 1.7vw, 0.5rem);
  }

  .btn-primary,
  .btn-loteria {
    min-height: 54px;
    font-size: 0.88rem;
  }
}

@media (min-width: 701px) {
  .picker-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .picker-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .chat-overlay {
    inset: auto 20px 20px auto;
    width: min(420px, calc(100vw - 40px));
    height: min(72dvh, 720px);
    border: 1px solid rgba(255, 240, 219, 0.12);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
  }
}
