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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none
}

/* ── THEMES ── */
[data-theme="dark"] {
  --bg: #06060f;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f0eeff;
  --text2: rgba(240, 238, 255, 0.55);
  --accent1: #8b5cf6;
  --accent2: #06b6d4;
  --grad: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --glow1: rgba(139, 92, 246, 0.4);
  --glow2: rgba(6, 182, 212, 0.4);
  --orb1: rgba(139, 92, 246, 0.15);
  --orb2: rgba(6, 182, 212, 0.12);
  --orb3: rgba(236, 72, 153, 0.10);
  --input-bg: rgba(255, 255, 255, 0.07);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --btn-bg: linear-gradient(135deg, #8b5cf6, #7c3aed, #6d28d9);
  --btn-shadow: 0 4px 25px rgba(139, 92, 246, 0.5);
  --disp-bg: rgba(255, 255, 255, 0.04);
  --disp-border: rgba(139, 92, 246, 0.3);
  --hist-bg: rgba(255, 255, 255, 0.05);
  --ad-bg: rgba(255, 255, 255, 0.03);
  --ad-border: rgba(255, 255, 255, 0.06);
  --modal-bg: rgba(10, 10, 20, 0.92);
  --modal-card: rgba(20, 20, 40, 0.95);
}

[data-theme="light"] {
  --bg: #f5f3ff;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-hover: rgba(255, 255, 255, 0.90);
  --border: rgba(139, 92, 246, 0.12);
  --text: #1e1b4b;
  --text2: rgba(30, 27, 75, 0.50);
  --accent1: #7c3aed;
  --accent2: #0891b2;
  --grad: linear-gradient(135deg, #7c3aed, #0891b2);
  --glow1: rgba(124, 58, 237, 0.2);
  --glow2: rgba(8, 145, 178, 0.2);
  --orb1: rgba(139, 92, 246, 0.12);
  --orb2: rgba(6, 182, 212, 0.10);
  --orb3: rgba(236, 72, 153, 0.08);
  --input-bg: rgba(255, 255, 255, 0.8);
  --shadow: 0 8px 32px rgba(139, 92, 246, 0.10);
  --btn-bg: linear-gradient(135deg, #7c3aed, #6d28d9, #5b21b6);
  --btn-shadow: 0 4px 25px rgba(124, 58, 237, 0.35);
  --disp-bg: rgba(255, 255, 255, 0.6);
  --disp-border: rgba(124, 58, 237, 0.2);
  --hist-bg: rgba(255, 255, 255, 0.5);
  --ad-bg: rgba(255, 255, 255, 0.4);
  --ad-border: rgba(124, 58, 237, 0.10);
  --modal-bg: rgba(245, 243, 255, 0.92);
  --modal-card: rgba(255, 255, 255, 0.95);
}

/* ── APP LAYOUT ── */
#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
  transition: background .5s
}

#particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100
}

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

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: float 20s ease-in-out infinite
}

.orb-1 {
  width: 340px;
  height: 340px;
  background: var(--orb1);
  top: -10%;
  left: -5%
}

.orb-2 {
  width: 280px;
  height: 280px;
  background: var(--orb2);
  bottom: -8%;
  right: -5%;
  animation-delay: -7s
}

.orb-3 {
  width: 200px;
  height: 200px;
  background: var(--orb3);
  top: 40%;
  left: 60%;
  animation-delay: -14s
}

/* ── TOP CONTROLS ── */
.top-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  display: flex;
  gap: 8px
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform .3s, background .3s, border-color .3s;
  color: var(--text)
}

.icon-btn:hover {
  transform: scale(1.1);
  background: var(--surface-hover);
  border-color: var(--accent1)
}

[data-theme="dark"] .theme-icon-sun {
  display: none
}

[data-theme="dark"] .theme-icon-moon {
  display: inline
}

[data-theme="light"] .theme-icon-sun {
  display: inline
}

[data-theme="light"] .theme-icon-moon {
  display: none
}

/* ── SCREENS ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s, transform .45s;
  transform: scale(.97)
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  z-index: 10
}

/* ── HOME ── */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 5vh, 48px);
  padding: 20px;
  z-index: 2
}

.logo-area {
  text-align: center;
  position: relative
}

.logo-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--grad);
  border-radius: 50%;
  filter: blur(70px);
  opacity: .35;
  animation: pulse-glow 4s ease-in-out infinite
}

.app-title {
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 900;
  color: var(--text);
  letter-spacing: -1px
}

.title-emoji {
  display: inline-block;
  animation: dice-bounce 3s ease-in-out infinite;
  margin-right: 4px
}

.highlight {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text
}

.app-subtitle {
  font-size: clamp(.85rem, 2.2vw, 1.1rem);
  color: var(--text2);
  margin-top: 6px;
  font-weight: 300;
  letter-spacing: 1px
}

.mode-cards {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(12px, 3vw, 24px);
  width: 100%;
  max-width: 800px;
  justify-content: center
}

.mode-card {
  position: relative;
  flex: 1 1 200px;
  max-width: 260px;
  padding: clamp(20px, 4vh, 36px) clamp(14px, 2vw, 24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: transform .35s cubic-bezier(.17, .67, .35, 1.3), border-color .3s, box-shadow .3s;
  font-family: inherit;
  color: var(--text)
}

.mode-card-glow {
  position: absolute;
  inset: 0;
  background: var(--grad);
  opacity: 0;
  transition: opacity .4s
}

.mode-card:hover .mode-card-glow {
  opacity: .06
}

.mode-card:hover {
  transform: translateY(-6px) scale(1.03);
  border-color: var(--accent1);
  box-shadow: 0 12px 40px var(--glow1)
}

.mode-card:active {
  transform: translateY(-2px) scale(.98)
}

.mode-icon {
  font-size: clamp(2rem, 5vw, 3.2rem);
  display: block;
  margin-bottom: 8px;
  position: relative;
  z-index: 1
}

.mode-card h2 {
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  margin-bottom: 4px;
  position: relative;
  z-index: 1
}

.mode-card p {
  font-size: clamp(.7rem, 1.5vw, .82rem);
  color: var(--text2);
  line-height: 1.4;
  position: relative;
  z-index: 1
}

/* ── MODAL ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px
}

.modal.hidden {
  display: none
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-bg);
  backdrop-filter: blur(12px)
}

.modal-content {
  position: relative;
  background: var(--modal-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 32px);
  max-width: 380px;
  width: 100%;
  text-align: center;
  backdrop-filter: blur(20px);
  animation: pop-in .4s cubic-bezier(.17, .67, .35, 1.5)
}

.modal-content h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px
}

.modal-content>p {
  font-size: .9rem;
  color: var(--text2);
  margin-bottom: 16px
}

.modal-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px
}

.modal-btn {
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .25s
}

.modal-btn:hover {
  border-color: var(--accent1);
  background: var(--surface-hover);
  transform: scale(1.04)
}

.modal-btn-alt {
  grid-column: 1/-1
}

.custom-balls-wrap {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center
}

.custom-balls-wrap.hidden {
  display: none
}

.custom-balls-wrap input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  outline: none
}

.custom-balls-wrap input:focus {
  border-color: var(--accent1)
}

.modal-btn-confirm {
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  background: var(--btn-bg);
  color: #fff;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .2s
}

.modal-btn-confirm:hover {
  transform: scale(1.05)
}

/* ── GAME HEADER ── */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, background .2s;
  font-family: inherit
}

.btn-icon:hover {
  transform: scale(1.1);
  background: var(--surface-hover)
}

#game-title {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text
}

/* ── SETTINGS ── */
.settings-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 20px);
  padding: 6px 16px;
  flex-shrink: 0
}

.settings-panel.hidden {
  display: none
}

.setting {
  display: flex;
  align-items: center;
  gap: 6px
}

.setting label {
  font-size: clamp(.7rem, 1.5vw, .82rem);
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px
}

.setting input[type="number"] {
  width: clamp(52px, 10vw, 72px);
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color .3s;
  -moz-appearance: textfield
}

.setting input[type="number"]::-webkit-inner-spin-button,
.setting input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none
}

.setting input[type="number"]:focus {
  border-color: var(--accent1)
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  display: inline-block
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--input-bg);
  border-radius: 24px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .3s, border-color .3s
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text2);
  border-radius: 50%;
  transition: transform .3s, background .3s
}

.switch input:checked+.slider {
  background: var(--accent1);
  border-color: var(--accent1)
}

.switch input:checked+.slider::before {
  transform: translateX(18px);
  background: #fff
}

/* ── BINGO RECENT ── */
.bingo-recent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 16px;
  flex-shrink: 0
}

.bingo-recent.hidden {
  display: none
}

.recent-balls {
  display: flex;
  gap: 6px;
  align-items: center
}

.recent-ball {
  width: clamp(32px, 6vw, 44px);
  height: clamp(32px, 6vw, 44px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(.7rem, 1.5vw, .95rem);
  color: #fff;
  animation: pop-in .4s cubic-bezier(.17, .67, .35, 1.5);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3)
}

.bingo-counter {
  font-size: clamp(.65rem, 1.3vw, .8rem);
  color: var(--text2);
  font-weight: 600;
  white-space: nowrap
}

/* ── DISPLAY AREA ── */
.display-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px
}

.globe-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center
}

/* NUMBER DISPLAY — BIGGER */
.number-display {
  position: relative;
  width: clamp(170px, 40vw, 300px);
  height: clamp(170px, 40vw, 300px);
  max-width: 42vh;
  max-height: 42vh;
  border-radius: 50%;
  background: var(--disp-bg);
  border: 2px solid var(--disp-border);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(16px);
  transition: border-color .3s, box-shadow .3s;
  z-index: 2
}

.number-display.spinning {
  animation: shake .08s linear infinite
}

.number-display.revealed {
  border-color: var(--accent1);
  box-shadow: 0 0 40px var(--glow1), 0 0 80px var(--glow2);
  animation: glow-pulse 1.5s ease-out
}

.display-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--grad);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 2px;
  opacity: 0;
  transition: opacity .5s
}

.number-display.revealed .display-ring {
  opacity: 1
}

.drawn-number {
  font-size: clamp(3.5rem, 14vw, 7rem);
  font-weight: 900;
  color: var(--text);
  transition: transform .3s;
  line-height: 1
}

.number-display.revealed .drawn-number {
  animation: number-bounce .6s cubic-bezier(.17, .67, .35, 1.5)
}

/* ── BINGO GLOBE VISUAL ── */
.globe-visual {
  position: absolute;
  inset: -24px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  border: 2px solid rgba(255, 255, 255, 0.08)
}

.globe-visual.hidden {
  display: none
}

.globe-ball-anim {
  position: absolute;
  width: clamp(12px, 2.5vw, 20px);
  height: clamp(12px, 2.5vw, 20px);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  margin: -7px 0 0 -7px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  animation: orbit-ball var(--dur, 3s) linear infinite;
  animation-delay: calc(var(--i)*-0.25s)
}

.globe-ball-anim:nth-child(1) {
  background: #ef4444;
  --rad: 65px;
  --ang: 0deg
}

.globe-ball-anim:nth-child(2) {
  background: #f59e0b;
  --rad: 75px;
  --ang: 30deg
}

.globe-ball-anim:nth-child(3) {
  background: #10b981;
  --rad: 58px;
  --ang: 60deg
}

.globe-ball-anim:nth-child(4) {
  background: #3b82f6;
  --rad: 80px;
  --ang: 90deg
}

.globe-ball-anim:nth-child(5) {
  background: #8b5cf6;
  --rad: 55px;
  --ang: 120deg
}

.globe-ball-anim:nth-child(6) {
  background: #ec4899;
  --rad: 70px;
  --ang: 150deg
}

.globe-ball-anim:nth-child(7) {
  background: #14b8a6;
  --rad: 85px;
  --ang: 180deg
}

.globe-ball-anim:nth-child(8) {
  background: #f97316;
  --rad: 60px;
  --ang: 210deg
}

.globe-ball-anim:nth-child(9) {
  background: #6366f1;
  --rad: 78px;
  --ang: 240deg
}

.globe-ball-anim:nth-child(10) {
  background: #eab308;
  --rad: 62px;
  --ang: 270deg
}

.globe-ball-anim:nth-child(11) {
  background: #e11d48;
  --rad: 72px;
  --ang: 300deg
}

.globe-ball-anim:nth-child(12) {
  background: #0ea5e9;
  --rad: 68px;
  --ang: 330deg
}

.globe-visual.spinning .globe-ball-anim {
  --dur: .35s !important
}

.globe-visual.revealed .globe-ball-anim {
  --dur: 8s
}

.globe-shine {
  position: absolute;
  top: 8%;
  left: 15%;
  width: 30%;
  height: 20%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, .15), transparent);
  border-radius: 50%;
  transform: rotate(-30deg)
}

@keyframes orbit-ball {
  0% {
    transform: rotate(var(--ang)) translateX(var(--rad)) rotate(calc(-1*var(--ang)))
  }

  100% {
    transform: rotate(calc(var(--ang) + 360deg)) translateX(var(--rad)) rotate(calc(-1*(var(--ang) + 360deg)))
  }
}

/* ── DRAW SECTION ── */
.draw-section {
  flex-shrink: 0;
  text-align: center;
  padding: 0 16px
}

.btn-draw {
  position: relative;
  margin: 0 auto;
  padding: clamp(12px, 2vh, 16px) clamp(36px, 8vw, 64px);
  border: none;
  border-radius: 16px;
  background: var(--btn-bg);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(.9rem, 2vw, 1.1rem);
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--btn-shadow);
  transition: transform .25s, box-shadow .25s
}

.btn-draw:hover {
  transform: translateY(-2px) scale(1.04)
}

.btn-draw:active {
  transform: translateY(1px) scale(.97)
}

.btn-draw:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none
}

.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
  animation: shine 3s infinite
}

/* ── SHAKE HINT ── */
.shake-hint {
  margin-top: 8px;
  font-size: clamp(.7rem, 1.5vw, .85rem);
  color: var(--accent1);
  font-weight: 600;
  animation: shake-wiggle 2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px
}

.shake-hint.hidden {
  display: none
}

.shake-phone {
  display: inline-block;
  animation: phone-shake 1.5s ease-in-out infinite
}

@keyframes phone-shake {

  0%,
  100% {
    transform: rotate(0)
  }

  15% {
    transform: rotate(12deg)
  }

  30% {
    transform: rotate(-10deg)
  }

  45% {
    transform: rotate(8deg)
  }

  60% {
    transform: rotate(-6deg)
  }

  75% {
    transform: rotate(3deg)
  }
}

@keyframes shake-wiggle {

  0%,
  100% {
    opacity: .7
  }

  50% {
    opacity: 1
  }
}

/* ── HISTORY ── */
.history-section {
  padding: 8px 16px 4px;
  flex-shrink: 0;
  min-height: clamp(36px, 6vh, 52px)
}

.history-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none
}

.history-list::-webkit-scrollbar {
  display: none
}

.history-item {
  flex-shrink: 0;
  min-width: clamp(32px, 5vw, 40px);
  height: clamp(32px, 5vw, 40px);
  border-radius: 12px;
  background: var(--hist-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(.7rem, 1.4vw, .85rem);
  color: var(--text);
  animation: pop-in .35s cubic-bezier(.17, .67, .35, 1.5)
}

.history-item.bingo-ball {
  border-radius: 50%;
  color: #fff;
  border: none;
  font-weight: 800
}

/* ── AD ── */
.ad-placeholder {
  margin: 4px 16px 8px;
  padding: clamp(10px, 2vh, 16px);
  border: 1px dashed var(--ad-border);
  border-radius: 12px;
  background: var(--ad-bg);
  text-align: center;
  flex-shrink: 0
}

.ad-placeholder span {
  font-size: clamp(.6rem, 1.2vw, .75rem);
  color: var(--text2);
  letter-spacing: .5px;
  text-transform: uppercase
}

/* ── ANIMATIONS ── */
@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1)
  }

  33% {
    transform: translate(30px, -20px) scale(1.05)
  }

  66% {
    transform: translate(-20px, 15px) scale(.95)
  }
}

@keyframes pulse-glow {

  0%,
  100% {
    opacity: .3;
    transform: translate(-50%, -50%) scale(1)
  }

  50% {
    opacity: .5;
    transform: translate(-50%, -50%) scale(1.15)
  }
}

@keyframes dice-bounce {

  0%,
  100% {
    transform: translateY(0) rotate(0)
  }

  25% {
    transform: translateY(-6px) rotate(8deg)
  }

  75% {
    transform: translateY(-3px) rotate(-5deg)
  }
}

@keyframes shake {
  0% {
    transform: translateX(-1px)
  }

  50% {
    transform: translateX(1px)
  }

  100% {
    transform: translateX(-1px)
  }
}

@keyframes glow-pulse {
  0% {
    box-shadow: 0 0 0 var(--glow1), 0 0 0 var(--glow2)
  }

  50% {
    box-shadow: 0 0 60px var(--glow1), 0 0 120px var(--glow2)
  }

  100% {
    box-shadow: 0 0 30px var(--glow1), 0 0 60px var(--glow2)
  }
}

@keyframes number-bounce {
  0% {
    transform: scale(.4);
    opacity: 0
  }

  60% {
    transform: scale(1.15);
    opacity: 1
  }

  100% {
    transform: scale(1)
  }
}

@keyframes pop-in {
  0% {
    transform: scale(0);
    opacity: 0
  }

  70% {
    transform: scale(1.15)
  }

  100% {
    transform: scale(1);
    opacity: 1
  }
}

@keyframes shine {
  0% {
    left: -100%
  }

  30% {
    left: 100%
  }

  100% {
    left: 100%
  }
}

@keyframes screen-shake {

  0%,
  100% {
    transform: translateX(0)
  }

  10% {
    transform: translateX(-3px) rotate(-.3deg)
  }

  30% {
    transform: translateX(3px) rotate(.3deg)
  }

  50% {
    transform: translateX(-2px)
  }

  70% {
    transform: translateX(2px)
  }

  90% {
    transform: translateX(-1px)
  }
}

.screen-shake {
  animation: screen-shake .4s ease-out
}

/* ── DICE 3D ── */
.dice-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 4vw, 32px);
  width: 100%;
  height: 100%;
  perspective: 1200px;
  padding: 20px
}

.dice-container.hidden {
  display: none
}

.dice-scene {
  width: clamp(80px, 25vw, 140px);
  height: clamp(80px, 25vw, 140px);
  perspective: 800px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .3s
}

.dice-cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(.17, .67, .15, 1.2)
}

.dice-cube.spinning {
  animation: dice-roll .35s linear infinite
}

.dice-face {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 2px solid var(--accent1);
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10%;
  box-shadow: inset 0 0 20px var(--glow1), 0 4px 15px rgba(0, 0, 0, .4);
  backdrop-filter: blur(8px)
}

.pip {
  background: var(--text);
  border-radius: 50%;
  width: clamp(8px, 2.5vw, 16px);
  height: clamp(8px, 2.5vw, 16px);
  margin: auto;
  box-shadow: 0 0 8px var(--glow2)
}

/* Rotations for each face */
.dice-face.front {
  transform: rotateY(0deg) translateZ(calc(clamp(80px, 25vw, 140px)/2))
}

.dice-face.right {
  transform: rotateY(90deg) translateZ(calc(clamp(80px, 25vw, 140px)/2))
}

.dice-face.back {
  transform: rotateY(180deg) translateZ(calc(clamp(80px, 25vw, 140px)/2))
}

.dice-face.left {
  transform: rotateY(-90deg) translateZ(calc(clamp(80px, 25vw, 140px)/2))
}

.dice-face.top {
  transform: rotateX(90deg) translateZ(calc(clamp(80px, 25vw, 140px)/2))
}

.dice-face.bottom {
  transform: rotateX(-90deg) translateZ(calc(clamp(80px, 25vw, 140px)/2))
}

/* Show classes (applied to .dice-cube) */
.dice-cube.show-1 {
  transform: rotateX(0deg) rotateY(0deg)
}

.dice-cube.show-2 {
  transform: rotateX(0deg) rotateY(-90deg)
}

.dice-cube.show-3 {
  transform: rotateX(0deg) rotateY(-180deg)
}

.dice-cube.show-4 {
  transform: rotateX(0deg) rotateY(90deg)
}

.dice-cube.show-5 {
  transform: rotateX(-90deg) rotateY(0deg)
}

.dice-cube.show-6 {
  transform: rotateX(90deg) rotateY(0deg)
}

/* Face 1 */
.face-1 .pip {
  grid-area: 2/2
}

/* Face 2 */
.face-2 .pip:nth-child(1) {
  grid-area: 1/3
}

.face-2 .pip:nth-child(2) {
  grid-area: 3/1
}

/* Face 3 */
.face-3 .pip:nth-child(1) {
  grid-area: 1/3
}

.face-3 .pip:nth-child(2) {
  grid-area: 2/2
}

.face-3 .pip:nth-child(3) {
  grid-area: 3/1
}

/* Face 4 */
.face-4 .pip:nth-child(1) {
  grid-area: 1/1
}

.face-4 .pip:nth-child(2) {
  grid-area: 1/3
}

.face-4 .pip:nth-child(3) {
  grid-area: 3/1
}

.face-4 .pip:nth-child(4) {
  grid-area: 3/3
}

/* Face 5 */
.face-5 .pip:nth-child(1) {
  grid-area: 1/1
}

.face-5 .pip:nth-child(2) {
  grid-area: 1/3
}

.face-5 .pip:nth-child(3) {
  grid-area: 2/2
}

.face-5 .pip:nth-child(4) {
  grid-area: 3/1
}

.face-5 .pip:nth-child(5) {
  grid-area: 3/3
}

/* Face 6 */
.face-6 .pip:nth-child(1) {
  grid-area: 1/1
}

.face-6 .pip:nth-child(2) {
  grid-area: 1/3
}

.face-6 .pip:nth-child(3) {
  grid-area: 2/1
}

.face-6 .pip:nth-child(4) {
  grid-area: 2/3
}

.face-6 .pip:nth-child(5) {
  grid-area: 3/1
}

.face-6 .pip:nth-child(6) {
  grid-area: 3/3
}

@keyframes dice-roll {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg)
  }

  100% {
    transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg)
  }
}

/* ── DICE STATS ── */
.dice-stats-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%
}

.dice-recent-rolls {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none
}

.dice-recent-rolls::-webkit-scrollbar {
  display: none
}

.mini-dice {
  width: clamp(28px, 4vw, 36px);
  height: clamp(28px, 4vw, 36px);
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  animation: pop-in .35s cubic-bezier(.17, .67, .35, 1.5)
}

.mini-dice.mini-1 .pip {
  grid-area: 2/2
}

.mini-dice.mini-2 .pip:nth-child(1) {
  grid-area: 1/3
}

.mini-dice.mini-2 .pip:nth-child(2) {
  grid-area: 3/1
}

.mini-dice.mini-3 .pip:nth-child(1) {
  grid-area: 1/3
}

.mini-dice.mini-3 .pip:nth-child(2) {
  grid-area: 2/2
}

.mini-dice.mini-3 .pip:nth-child(3) {
  grid-area: 3/1
}

.mini-dice.mini-4 .pip:nth-child(1) {
  grid-area: 1/1
}

.mini-dice.mini-4 .pip:nth-child(2) {
  grid-area: 1/3
}

.mini-dice.mini-4 .pip:nth-child(3) {
  grid-area: 3/1
}

.mini-dice.mini-4 .pip:nth-child(4) {
  grid-area: 3/3
}

.mini-dice.mini-5 .pip:nth-child(1) {
  grid-area: 1/1
}

.mini-dice.mini-5 .pip:nth-child(2) {
  grid-area: 1/3
}

.mini-dice.mini-5 .pip:nth-child(3) {
  grid-area: 2/2
}

.mini-dice.mini-5 .pip:nth-child(4) {
  grid-area: 3/1
}

.mini-dice.mini-5 .pip:nth-child(5) {
  grid-area: 3/3
}

.mini-dice.mini-6 .pip:nth-child(1) {
  grid-area: 1/1
}

.mini-dice.mini-6 .pip:nth-child(2) {
  grid-area: 1/3
}

.mini-dice.mini-6 .pip:nth-child(3) {
  grid-area: 2/1
}

.mini-dice.mini-6 .pip:nth-child(4) {
  grid-area: 2/3
}

.mini-dice.mini-6 .pip:nth-child(5) {
  grid-area: 3/1
}

.mini-dice.mini-6 .pip:nth-child(6) {
  grid-area: 3/3
}

.mini-dice .pip {
  width: clamp(4px, 1vw, 6px);
  height: clamp(4px, 1vw, 6px);
  box-shadow: none;
  background: var(--text);
  margin: auto;
  border-radius: 50%
}

.dice-sum-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 16px;
  background: var(--btn-bg);
  border-radius: 20px;
  box-shadow: var(--btn-shadow);
  animation: pop-in .4s ease-out
}

.dice-sum-display.hidden {
  display: none
}

.sum-label {
  font-size: .7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, .8);
  letter-spacing: 1px
}

.sum-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff
}

.btn-dice-reset {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .9rem;
  color: #fff;
  margin-left: 4px;
  transition: transform .2s, background .2s
}

.btn-dice-reset:hover {
  transform: scale(1.1) rotate(45deg);
  background: rgba(255, 255, 255, 0.25)
}

.multi-roll-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  gap: 4px;
  animation: pop-in .35s ease-out;
  min-width: max-content
}

.multi-roll-sum {
  font-size: .75rem;
  font-weight: 800;
  color: var(--accent1);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 8px;
  align-self: stretch;
  text-align: center
}

.multi-roll-dice {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 140px
}

.multi-roll-dice .mini-dice {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  padding: 1px
}

.multi-roll-dice .pip {
  width: 3px;
  height: 3px
}

/* ── BINGO BOARD ── */
.bingo-board-section {
  padding: 8px 16px;
  flex-shrink: 0;
  max-height: clamp(120px, 25vh, 200px);
  overflow-y: auto;
  scrollbar-width: none
}

.bingo-board-section::-webkit-scrollbar {
  display: none
}

.bingo-board {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(4px, 1vw, 8px);
  justify-content: center;
  max-width: 800px;
  margin: 0 auto
}

.board-ball {
  width: clamp(26px, 4vw, 36px);
  height: clamp(26px, 4vw, 36px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(.65rem, 1.4vw, .9rem);
  color: var(--text2);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all .3s
}

.board-ball.active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  animation: pop-in .3s ease-out
}

/* ── DICE TYPE GRID ── */
.dice-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.dice-type-btn { background: var(--input-bg); border: 1px solid var(--border); border-radius: 12px; padding: 8px; cursor: pointer; color: var(--text2); transition: all .3s; display: flex; align-items: center; justify-content: center; }
.dice-type-btn svg { width: clamp(36px, 8vw, 48px); height: clamp(36px, 8vw, 48px); transition: transform .3s; }
.dice-type-btn:hover { background: var(--surface-hover); color: var(--text); transform: translateY(-2px); }
.dice-type-btn.active { background: var(--surface); border-color: var(--accent1); color: var(--accent1); box-shadow: inset 0 0 12px var(--glow1); }
.dice-type-btn.active svg { transform: scale(1.1); filter: drop-shadow(0 2px 6px var(--glow1)); }

/* ── POLY SVG DICE ── */
.poly-svg-container { width: clamp(80px, 25vw, 140px); height: clamp(80px, 25vw, 140px); display: flex; align-items: center; justify-content: center; position: relative; }
.poly-svg { width: 100%; height: 100%; color: var(--accent1); filter: drop-shadow(0 4px 15px rgba(0, 0, 0, 0.5)); transition: transform .3s, filter .3s; }
.poly-svg.spinning { animation: poly-shake-spin .35s ease-in-out infinite; }
.poly-number { position: absolute; font-size: clamp(1.8rem, 6vw, 3.2rem); font-weight: 900; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8); opacity: 0; transform: scale(0.5); transition: opacity .3s, transform .3s; z-index: 10; }
.poly-svg-container.revealed .poly-number { opacity: 1; transform: scale(1); animation: number-bounce .6s cubic-bezier(.17, .67, .35, 1.5); }
.poly-svg-container.revealed .poly-svg { filter: drop-shadow(0 0 20px var(--glow1)) drop-shadow(0 0 40px var(--glow2)); color: #fff; }
.poly-svg-container.spinning .poly-number { opacity: 0; }

@keyframes poly-shake-spin {
    0% { transform: scale(1) rotate(0deg) translate(0, 0); }
    25% { transform: scale(0.9) rotate(45deg) translate(-5px, 5px); }
    50% { transform: scale(1.1) rotate(180deg) translate(5px, -5px); }
    75% { transform: scale(0.8) rotate(270deg) translate(-5px, -5px); }
    100% { transform: scale(1) rotate(360deg) translate(0, 0); }
}

/* ── RESPONSIVE ── */
@media(max-height:600px) {
  .display-area {
    padding: 0
  }

  .number-display {
    width: 120px;
    height: 120px;
    max-width: 26vh;
    max-height: 26vh
  }

  .drawn-number {
    font-size: 2.5rem
  }

  .settings-panel {
    padding: 2px 12px
  }

  .history-section {
    padding: 4px 12px;
    min-height: 32px
  }

  .ad-placeholder {
    margin: 2px 12px 4px;
    padding: 6px
  }

  .game-header {
    padding: 6px 12px
  }

  .bingo-recent {
    padding: 2px 12px
  }
}

@media(max-height:500px) and (orientation:landscape) {
  .home-content {
    flex-direction: row;
    gap: 24px
  }

  .logo-area {
    text-align: left
  }

  .mode-cards {
    flex-direction: column;
    max-width: 200px
  }

  .mode-card {
    padding: 12px
  }

  .number-display {
    width: 100px;
    height: 100px
  }

  .drawn-number {
    font-size: 2rem
  }

  .game-header {
    padding: 4px 12px
  }

  .settings-panel {
    padding: 0 12px
  }

  .btn-draw {
    padding: 8px 28px;
    font-size: .8rem
  }

  .history-section {
    min-height: 28px;
    padding: 2px 12px
  }

  .ad-placeholder {
    margin: 2px 12px;
    padding: 4px
  }
}

@media(min-width:768px) and (min-height:700px) {
  .number-display {
    width: 260px;
    height: 260px
  }

  .drawn-number {
    font-size: 5.5rem
  }

  .mode-card {
    padding: 36px 28px;
    border-radius: 28px
  }
}

@media(min-width:1200px) {
  .number-display {
    width: 300px;
    height: 300px
  }

  .drawn-number {
    font-size: 6.5rem
  }

  .history-section {
    max-width: 700px;
    margin: 0 auto
  }
}

.hidden {
  display: none !important
}