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

:root {
  --paper: #fff1bd;
  --ink: #16120f;
  --acid: #d6ff32;
  --pink: #ff4fa3;
  --blue: #15a6ff;
  --green: #1fc66a;
  --purple: #7c29ff;
  --red: #ef2c2c;
  --shadow: #16120f;
  --ordinaire: #138ee8;
  --ordinaire-soft: #b9e4ff;
  --semi: #20bf63;
  --semi-soft: #bef7a7;
  --rare: #ff412f;
  --rare-soft: #ffc2a6;
  --legendaire: #802cff;
  --legendaire-soft: #d7b7ff;
  --checked: #d6ff32;
  --font: Impact, Haettenschweiler, "Arial Black", system-ui, sans-serif;
  --body-font: "Trebuchet MS", Arial, sans-serif;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
}

body {
  min-height: 100%;
  font-family: var(--body-font);
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 79, 163, 0.35) 0 9rem, transparent 9.2rem),
    radial-gradient(circle at 87% 8%, rgba(21, 166, 255, 0.36) 0 8rem, transparent 8.2rem),
    linear-gradient(135deg, #fff1bd 0%, #ffd86b 45%, #ff9f37 100%);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.18;
  background-image:
    linear-gradient(90deg, var(--ink) 1px, transparent 1px),
    linear-gradient(var(--ink) 1px, transparent 1px);
  background-size: 17px 19px;
  transform: rotate(-1.5deg) scale(1.05) translateZ(0);
  backface-visibility: hidden;
}

.screen {
  display: none;
  min-height: 100dvh;
  min-height: 100svh;
  position: relative;
}

.screen.active {
  display: flex;
}

.home-container {
  position: relative;
  z-index: 1;
}

.discord-link {
  position: fixed;
  bottom: 14px;
  left: 50%;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #5865f2;
  box-shadow: 4px 4px 0 var(--shadow);
  transform: translateX(-50%) rotate(-2deg);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.discord-link svg {
  width: 30px;
  height: 30px;
  fill: #fff;
}

.discord-link:active {
  transform: translateX(-50%) rotate(-2deg) scale(0.93);
  box-shadow: 2px 2px 0 var(--shadow);
}

.home-container {
  width: min(100%, 520px);
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100svh;
  padding: 32px 18px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.ascii-title {
  font-family: var(--font);
  font-size: clamp(2.6rem, 12vw, 5.5rem);
  line-height: 0.82;
  white-space: nowrap;
  text-align: left;
  color: var(--acid);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink);
  transform: rotate(-3deg);
}

/* Le petit curieux qui épie depuis le dernier "o" de Bingo */
.peek-o {
  position: relative;
}

.peek-o .peeker {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: -1;
  font-size: 0.6em;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, 55%);
  opacity: 0;
  will-change: transform, opacity;
  animation: peekFromO 6.5s ease-in-out infinite;
}

@keyframes peekFromO {
  0%, 6% { transform: translate(-50%, 55%); opacity: 0; }
  15% { transform: translate(-50%, -72%); opacity: 1; }
  21% { transform: translate(-46%, -68%); opacity: 1; }
  27% { transform: translate(-54%, -72%); opacity: 1; }
  34%, 100% { transform: translate(-50%, 55%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .peek-o .peeker { display: none; }
}

.ascii-sub {
  align-self: flex-start;
  max-width: 340px;
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 0.92rem;
  line-height: 1.05;
  white-space: pre-wrap;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--blue);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(1.5deg);
}

.subtitle {
  margin: 8px 0 18px;
  max-width: 330px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

input[type="text"] {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  outline: none;
  background: #fff9dd;
  color: var(--ink);
  font: 900 1rem var(--body-font);
  box-shadow: 5px 5px 0 var(--shadow);
}

input[type="text"]:focus {
  background: #fff;
  box-shadow: 3px 3px 0 var(--shadow), 0 0 0 4px var(--acid);
}

input[type="text"]::placeholder {
  color: rgba(22, 18, 15, 0.58);
}

.btn,
.btn-icon,
.btn-close {
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fff9dd;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0;
  box-shadow: 5px 5px 0 var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.55;
  filter: grayscale(0.45);
}

.btn:active,
.btn-icon:active,
.btn-close:active {
  transform: translate(3px, 3px) rotate(-1deg);
  box-shadow: 2px 2px 0 var(--shadow);
}

.btn-primary {
  background: var(--acid);
}

.btn-secondary {
  background: var(--pink);
  color: #fff;
}

.btn-link {
  margin-top: 10px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border-style: dashed;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font: 900 0.78rem var(--body-font);
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 3px;
  background: var(--ink);
}

.join-row {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 9px;
}

.join-row input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 1.3rem;
}

.error {
  min-height: 1.35em;
  color: #fff;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  background: var(--red);
  border: 0;
}

.error:empty {
  background: transparent;
}

#screen-game {
  flex-direction: column;
}

.game-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border-bottom: 4px solid var(--ink);
  transform: translateZ(0);
}

.room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.room-code-display {
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: var(--acid);
  font: 900 1.05rem var(--font);
  letter-spacing: 0.08em;
  box-shadow: 4px 4px 0 var(--shadow);
}

.btn-icon {
  width: auto;
  min-height: 38px;
  padding: 7px 9px;
  font-size: 0.78rem;
}

.btn-icon span {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  place-items: center;
  margin-left: 4px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
}

.btn-joker {
  position: relative;
  min-height: 38px;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  font-size: 1.9rem;
  line-height: 1;
}

.btn-joker:active {
  transform: scale(0.9);
  box-shadow: none;
}

.btn-joker.has-bonus {
  filter: drop-shadow(0 0 4px var(--purple));
}

.btn-joker:disabled {
  opacity: 0.4;
  filter: grayscale(0.7);
}

.btn-joker #joker-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  font: 900 0.62rem var(--font);
}

.btn-joker.joker-pop {
  animation: jokerPop 0.6s ease;
}

.game-content {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 14px 10px 48px;
}

.mode-banner {
  margin-bottom: 14px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: var(--rare-soft);
  color: var(--ink);
  font: 900 0.85rem var(--font);
  text-transform: uppercase;
  text-align: center;
  box-shadow: 4px 4px 0 var(--shadow);
  transform: rotate(-0.6deg);
}

#btn-continue-hard {
  margin-top: 10px;
}

.grid-section {
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 9px 10px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  transform: rotate(-0.6deg);
}

.section-header h3 {
  font: 900 1rem var(--font);
  line-height: 1;
  text-transform: uppercase;
}

.section-pct,
.progress {
  font: 900 0.78rem var(--body-font);
  text-transform: uppercase;
}

.progress {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.bonus-count {
  display: inline-block;
  min-height: 18px;
  color: var(--purple);
}

.section-header.ordinaire { background: var(--ordinaire-soft); }
.section-header.semi { background: var(--semi-soft); }
.section-header.rare { background: var(--rare-soft); }
.section-header.legendaire {
  background: var(--legendaire-soft);
  color: #26005a;
}

.grid {
  display: grid;
  gap: 8px;
}

.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-1 { grid-template-columns: 1fr; }

.cell {
  position: relative;
  min-height: 76px;
  padding: 8px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fff9dd;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.cell:nth-child(odd) { transform: rotate(-0.8deg); }
.cell:nth-child(even) { transform: rotate(0.8deg); }

.cell:active {
  transform: translate(3px, 3px) rotate(0deg);
  box-shadow: 1px 1px 0 var(--shadow);
}

.cell .emoji {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.cell .label {
  max-width: 100%;
  color: var(--ink);
  font: 900 0.62rem/1.05 var(--body-font);
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.ordinaire-cell { background: linear-gradient(160deg, #ffffff 0%, var(--ordinaire-soft) 100%); }
.semi-cell { background: linear-gradient(160deg, #ffffff 0%, var(--semi-soft) 100%); }
.rare-cell { background: linear-gradient(160deg, #ffffff 0%, var(--rare-soft) 100%); }
.legendaire-cell {
  min-height: 112px;
  background: linear-gradient(135deg, #ffffff 0%, var(--legendaire-soft) 45%, var(--purple) 100%);
}

.legendaire-cell .emoji {
  font-size: 3rem;
}

.legendaire-cell .label {
  color: #fff;
  font-size: 1rem;
  text-shadow: 2px 2px 0 var(--ink);
}

.legendaire-cell.legendary-confirm {
  outline: 4px solid var(--pink);
  box-shadow: 0 0 0 4px var(--acid), 7px 7px 0 var(--ink);
}

.cell.checked {
  background: var(--checked);
  filter: saturate(1.2);
}

.cell.reroll-target {
  outline: 4px dashed var(--purple);
  outline-offset: -7px;
  animation: bonusPulse 0.9s ease-in-out infinite;
}

.cell.freecheck-target {
  outline: 4px dashed var(--green);
  outline-offset: -7px;
  animation: bonusPulse 0.9s ease-in-out infinite;
}

.cell.checked::after {
  content: "BIM";
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 2px 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font: 900 0.6rem var(--font);
  transform: rotate(8deg);
}

.occurrence-badge {
  position: absolute;
  left: 5px;
  top: 5px;
  min-width: 28px;
  padding: 2px 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font: 900 0.62rem var(--font);
  transform: rotate(-8deg);
}

.grid-section.complete .section-header {
  background: var(--acid);
}

.panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(22, 18, 15, 0.62);
}

.panel-backdrop.active {
  display: block;
}

.panel {
  position: fixed;
  top: 0;
  right: -105%;
  z-index: 100;
  width: min(88%, 360px);
  height: 100%;
  padding: 18px;
  overflow-y: auto;
  background: var(--paper);
  border-left: 4px solid var(--ink);
  box-shadow: -8px 0 0 rgba(22, 18, 15, 0.22);
  transition: right 0.24s ease;
}

.panel.open {
  right: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 4px solid var(--ink);
}

.panel-header h3 {
  font: 900 1.25rem var(--font);
  text-transform: uppercase;
}

.btn-close {
  width: 44px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  background: var(--pink);
  color: #fff;
}

.player-card {
  margin-bottom: 9px;
  padding: 10px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fff9dd;
  box-shadow: 3px 3px 0 var(--shadow);
}

.player-name {
  margin-bottom: 8px;
  font: 900 0.95rem var(--font);
  text-transform: uppercase;
}

.player-name.is-me {
  color: var(--purple);
}

.player-progress-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-row {
  display: grid;
  grid-template-columns: 24px 1fr 42px;
  align-items: center;
  gap: 6px;
}

.progress-label,
.progress-text {
  font-size: 0.72rem;
  font-weight: 900;
}

.progress-bar {
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
}

.progress-bar .fill {
  height: 100%;
  transition: width 0.25s ease;
}

.progress-bar.ordinaire .fill { background: var(--ordinaire); }
.progress-bar.semi .fill { background: var(--semi); }
.progress-bar.rare .fill { background: var(--rare); }
.progress-bar.legendaire .fill { background: var(--legendaire); }
.progress-bar.full .fill { background: var(--acid); }

.btn-new-game {
  margin-top: 14px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(22, 18, 15, 0.78);
}

.overlay.active {
  display: flex;
}

.win-content {
  width: min(100%, 360px);
  padding: 24px 18px;
  text-align: center;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--acid);
  box-shadow: 8px 8px 0 var(--pink), 14px 14px 0 var(--ink);
  animation: slam 0.28s ease;
}

.win-content.win-burst {
  animation: slam 0.28s ease, winBurst 0.65s ease;
}

.win-tier-ordinaire { background: rgba(22, 18, 15, 0.7); }
.win-tier-ordinaire .win-content { background: var(--ordinaire-soft); }

.win-tier-semi { background: rgba(22, 18, 15, 0.75); }
.win-tier-semi .win-content {
  background: var(--semi-soft);
  box-shadow: 8px 8px 0 var(--green), 14px 14px 0 var(--ink);
}

.win-tier-rare { background: rgba(22, 18, 15, 0.8); }
.win-tier-rare .win-content {
  background: linear-gradient(135deg, var(--rare-soft), var(--pink));
  box-shadow: 8px 8px 0 var(--red), 14px 14px 0 var(--ink), 0 0 40px var(--red);
}

.win-tier-legendaire {
  background: rgba(80, 0, 180, 0.85);
}
.win-tier-legendaire .win-content {
  background: linear-gradient(135deg, var(--legendaire-soft), var(--acid), var(--pink), var(--blue));
  background-size: 300% 300%;
  animation: slam 0.28s ease, legendBg 0.8s linear infinite;
  box-shadow: 8px 8px 0 var(--purple), 14px 14px 0 var(--ink), 0 0 60px var(--purple), 0 0 120px var(--pink);
  border-color: var(--acid);
}
.win-tier-legendaire .win-drawing {
  font-size: 6rem;
  animation: legendSpin 0.5s ease infinite alternate;
}
.win-tier-legendaire #win-title {
  animation: textGlitch 0.1s steps(2) infinite;
}

.win-drawing.win-burst {
  animation: winBounce 0.65s ease;
}

.win-title.win-burst {
  animation: winTitlePop 0.65s ease;
}

.bonus-choice-content {
  width: min(100%, 380px);
  padding: 22px 16px;
  display: grid;
  gap: 10px;
  text-align: center;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--legendaire-soft);
  box-shadow: 8px 8px 0 var(--acid), 14px 14px 0 var(--ink);
  animation: slam 0.28s ease;
}

.bonus-choice-content h2 {
  font: 900 2rem/0.9 var(--font);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #fff;
}

.bonus-choice-content p {
  font-weight: 900;
  text-transform: uppercase;
}

.win-drawing {
  width: 118px;
  height: 118px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  font-size: 5rem;
  line-height: 1;
}

.win-content h2 {
  margin: 8px 0;
  font: 900 2.3rem/0.9 var(--font);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #fff;
}

.win-content p {
  margin-bottom: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: -80px;
  z-index: 300;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font: 900 0.9rem var(--font);
  text-align: center;
  text-transform: uppercase;
  box-shadow: 5px 5px 0 var(--shadow);
  transform: translateX(-50%) rotate(-1deg);
  transition: bottom 0.25s ease;
}

.toast.show {
  bottom: 22px;
}

.activity-notice {
  position: fixed;
  right: 12px;
  bottom: 66px;
  z-index: 290;
  max-width: min(76vw, 320px);
  padding: 8px 11px;
  border: 2px solid rgba(22, 18, 15, 0.55);
  border-radius: 6px;
  background: rgba(255, 249, 221, 0.9);
  color: rgba(22, 18, 15, 0.88);
  font: 800 0.72rem/1.1 var(--font);
  letter-spacing: 0;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 rgba(22, 18, 15, 0.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.activity-notice.show {
  opacity: 1;
  transform: translateY(0);
}

.bonus-flash {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: none;
  place-items: center;
  padding: 22px;
  pointer-events: none;
  color: var(--acid);
  text-align: center;
  font: 900 clamp(2.8rem, 18vw, 7rem)/0.82 var(--font);
  text-transform: uppercase;
  text-shadow: 5px 5px 0 var(--pink), 10px 10px 0 var(--ink);
  background: rgba(128, 44, 255, 0.2);
}

.bonus-flash.show {
  display: grid;
  animation: bonusSlam 1.45s ease forwards;
}


@keyframes slam {
  from { opacity: 0; transform: scale(0.85) rotate(-3deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes winPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4); }
}

@keyframes winShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-6px, 3px) rotate(-2deg); }
  50% { transform: translate(5px, -4px) rotate(1.5deg); }
  75% { transform: translate(-3px, 5px) rotate(-1deg); }
}

@keyframes winGlow {
  from { filter: brightness(1) saturate(1); }
  to { filter: brightness(1.3) saturate(1.5); }
}

@keyframes screenShake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 3px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-3px, -4px); }
  80% { transform: translate(4px, 2px); }
  100% { transform: translate(0, 0); }
}

@keyframes legendSpin {
  from { transform: rotate(-8deg) scale(1); }
  to { transform: rotate(8deg) scale(1.15); }
}

@keyframes legendBg {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes winBurst {
  0% { transform: scale(0.78) rotate(-6deg); }
  45% { transform: scale(1.08) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes winBounce {
  0% { transform: scale(0.7) rotate(-10deg); filter: brightness(0.9); }
  50% { transform: scale(1.18) rotate(8deg); filter: brightness(1.2); }
  100% { transform: scale(1) rotate(0deg); filter: brightness(1); }
}

@keyframes winTitlePop {
  0% { transform: translateY(10px) scale(0.92); opacity: 0; }
  55% { transform: translateY(0) scale(1.08); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes textGlitch {
  0% { transform: translate(0, 0) skewX(0deg); }
  25% { transform: translate(-3px, 2px) skewX(-5deg); color: var(--pink); }
  50% { transform: translate(4px, -1px) skewX(3deg); color: var(--acid); }
  75% { transform: translate(-2px, -3px) skewX(-2deg); color: var(--blue); }
  100% { transform: translate(0, 0) skewX(0deg); }
}

@keyframes rainbowFlash {
  0% { background: rgba(255, 0, 0, 0.3); }
  16% { background: rgba(255, 165, 0, 0.3); }
  33% { background: rgba(255, 255, 0, 0.3); }
  50% { background: rgba(0, 255, 0, 0.3); }
  66% { background: rgba(0, 0, 255, 0.3); }
  83% { background: rgba(128, 0, 255, 0.3); }
  100% { background: rgba(255, 0, 0, 0.3); }
}

@keyframes pop {
  50% {
    transform: scale(1.08) rotate(-1deg);
  }
}

@keyframes bonusPulse {
  50% {
    filter: saturate(1.5) brightness(1.08);
    transform: rotate(0deg) scale(1.03);
  }
}

@keyframes bonusSlam {
  0% {
    opacity: 0;
    transform: scale(0.45) rotate(-8deg);
  }
  18% {
    opacity: 1;
    transform: scale(1.08) rotate(2deg);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.2) rotate(-2deg);
  }
}

@keyframes jokerPop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.12) rotate(-4deg);
  }
  65% {
    transform: scale(0.98) rotate(2deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes longPressPop {
  50% {
    transform: scale(1.08) rotate(-2deg);
    box-shadow: 1px 1px 0 var(--shadow), 0 0 0 5px var(--purple);
  }
}

.cell.freecheck-hit {
  animation: freeCheckPop 0.42s ease;
  box-shadow: 0 0 0 4px rgba(21, 166, 255, 0.9), 4px 4px 0 var(--shadow);
}

@keyframes freeCheckPop {
  0% {
    transform: scale(1) rotate(0deg);
    filter: saturate(1.1) brightness(1);
  }
  45% {
    transform: scale(1.12) rotate(-2deg);
    filter: saturate(1.35) brightness(1.1);
  }
  100% {
    transform: scale(1) rotate(0deg);
    filter: saturate(1.15) brightness(1);
  }
}

.cell.just-checked {
  animation: pop 0.2s ease;
}

.cell.reroll-hit {
  animation: rerollHit 0.58s ease;
  box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.8), 4px 4px 0 var(--shadow);
}

.cell.reroll-hit::before {
  content: "";
  position: absolute;
  inset: -8px;
  pointer-events: none;
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 58%, rgba(255, 255, 255, 0.96) 0 16%, transparent 17%),
    radial-gradient(circle at 47% 38%, rgba(255, 255, 255, 0.98) 0 20%, transparent 21%),
    radial-gradient(circle at 69% 58%, rgba(255, 255, 255, 0.96) 0 16%, transparent 17%),
    radial-gradient(circle at 50% 72%, rgba(255, 255, 255, 0.92) 0 20%, transparent 21%);
  filter: blur(1px);
  opacity: 0;
  animation: rerollCloud 0.58s ease;
}

.cell.reroll-hit::after {
  content: "✨";
  position: absolute;
  top: -14px;
  right: -2px;
  pointer-events: none;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transform: scale(0.4) rotate(-10deg);
  animation: rerollSpark 0.58s ease;
}

.cell.long-pressing {
  animation: longPressPop 0.26s ease;
}

@keyframes rerollHit {
  0% {
    transform: scale(0.98) rotate(0deg);
    filter: brightness(1);
  }
  30% {
    transform: scale(1.08) rotate(-2deg);
    filter: brightness(1.12) saturate(1.15);
  }
  60% {
    transform: scale(1.04) rotate(1deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

@keyframes rerollCloud {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(8px);
  }
  28% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  70% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: scale(1.12) translateY(-4px);
  }
}

@keyframes rerollSpark {
  0% {
    opacity: 0;
    transform: scale(0.4) rotate(-10deg);
  }
  30% {
    opacity: 1;
    transform: scale(1.1) rotate(8deg);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.2) rotate(18deg);
  }
}

@media (max-width: 370px) {
  .ascii-title {
    font-size: clamp(2.4rem, 14vw, 3.6rem);
  }

  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .room-info {
    justify-content: space-between;
  }

  .grid {
    gap: 5px;
  }

  .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .cell {
    min-height: 62px;
    padding: 6px 4px;
  }

  .cell .emoji {
    font-size: 1.6rem;
  }

  .cell .label {
    font-size: 0.52rem;
  }

  .section-header h3 {
    font-size: 0.85rem;
  }

  .btn {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .win-content h2 {
    font-size: 1.8rem;
  }

  .bonus-choice-content h2 {
    font-size: 1.6rem;
  }
}

@media (min-width: 371px) and (max-width: 480px) {
  .grid {
    gap: 6px;
  }

  .cell {
    min-height: 72px;
  }

  .cell .emoji {
    font-size: 1.8rem;
  }

  .cell .label {
    font-size: 0.58rem;
  }
}

@media (min-width: 481px) and (max-width: 699px) {
  .game-content {
    padding: 14px 14px 48px;
  }

  .cell {
    min-height: 80px;
  }
}

@media (min-width: 700px) {
  .home-container {
    align-items: flex-start;
  }

  .game-content {
    padding-top: 20px;
  }

  .cell {
    min-height: 88px;
  }

  .cell .emoji {
    font-size: 2.2rem;
  }

  .cell .label {
    font-size: 0.72rem;
  }
}

@media (min-width: 1024px) {
  .game-content {
    max-width: 680px;
  }

  .cell {
    min-height: 96px;
    border-radius: 9px;
  }

  .cell .emoji {
    font-size: 2.5rem;
  }

  .cell .label {
    font-size: 0.78rem;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ADMIN */
.admin-body {
  min-height: 100dvh;
}

@media (hover: none) and (pointer: coarse) {
  html {
    overscroll-behavior-y: none;
  }
}

.admin-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 12px 44px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 4px solid var(--ink);
}

.admin-header h1 {
  font: 900 clamp(2.5rem, 10vw, 5.5rem)/0.86 var(--font);
  color: var(--acid);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink);
  text-transform: uppercase;
}

.admin-header p,
.admin-status,
.admin-error {
  font-weight: 900;
  text-transform: uppercase;
}

.admin-back {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  box-shadow: 4px 4px 0 var(--shadow);
  font: 900 0.9rem var(--font);
  text-decoration: none;
  text-transform: uppercase;
}

.admin-login,
.admin-panel {
  padding: 14px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: #fff9dd;
  box-shadow: 6px 6px 0 var(--shadow);
}

.admin-login label {
  display: block;
  margin-bottom: 8px;
  font: 900 1rem var(--font);
  text-transform: uppercase;
}

.admin-login-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
}

.admin-actions {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--purple);
}

.admin-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
}

.admin-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 8px;
  border-bottom: 3px solid var(--ink);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: var(--acid);
  font: 900 0.9rem var(--font);
  text-transform: uppercase;
}

.admin-table tr:nth-child(even) td {
  background: rgba(255, 79, 163, 0.12);
}

.admin-table select,
.admin-table input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fff9dd;
  color: var(--ink);
  box-shadow: none;
  font: 900 0.95rem var(--body-font);
}

.admin-row-delete {
  min-height: 38px;
  padding: 7px 10px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
  font: 900 0.75rem var(--font);
  text-transform: uppercase;
}

.admin-status {
  min-height: 1.3em;
  margin-top: 12px;
  color: var(--purple);
}

.admin-error {
  min-height: 1.3em;
  margin-top: 10px;
  color: var(--red);
}

.info-shell {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 18px 12px 44px;
}

.info-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 4px solid var(--ink);
}

.info-header h1 {
  font: 900 clamp(2.8rem, 13vw, 6rem)/0.86 var(--font);
  color: var(--acid);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink);
  text-transform: uppercase;
}

.info-header p {
  font-weight: 900;
  text-transform: uppercase;
}

.info-rules {
  padding: 16px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: #fff9dd;
  box-shadow: 6px 6px 0 var(--shadow);
}

.info-rules h2 {
  margin: 18px 0 6px;
  font: 900 1.25rem var(--font);
  text-transform: uppercase;
}

.info-rules h2:first-child {
  margin-top: 0;
}

.info-rules p {
  font-weight: 800;
  line-height: 1.35;
}

@media (max-width: 620px) {
  .admin-header {
    flex-direction: column;
  }

  .info-header {
    flex-direction: column;
  }

  .admin-login-row,
  .admin-buttons {
    grid-template-columns: 1fr;
  }
}
