:root {
  --total-grid-size: 620px;
  --grid-gap: 4px;
}

* {
  box-sizing: border-box;
}

body {
  background: #242424;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 16px;
  overflow-x: hidden;
  position: relative;
}

/* Profile Icon Styling */
.profile-icon {
  position: fixed;
  top: 20px;
  right: 20px;
  cursor: pointer;
  z-index: 1000;
  user-select: none;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: rgb(49, 49, 49);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-icon:hover .profile-avatar {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(255, 179, 0, 0.4);
}

.profile-tooltip {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: #333;
  color: #ffb300;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-family: Verdana, sans-serif;
  border: 1px solid #ffb300;
}

.profile-icon:hover .profile-tooltip {
  opacity: 1;
}

/* Premium Badge Styling */
.premium-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  box-shadow: 0 2px 4px rgba(118, 75, 162, 0.4);
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
  cursor: help;
}

.premium-badge::before {
  content: "💎";
  margin-right: 3px;
  font-size: 11px;
}

/* Elite Badge Styling */
.elite-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff9d00 0%, #ff5e00 100%);
  color: white;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  box-shadow: 0 2px 4px rgba(255, 157, 0, 0.4);
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
  cursor: help;
}

.elite-badge::before {
  content: "✨";
  margin-right: 3px;
  font-size: 11px;
}

.btn-upgrade-premium {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #ffb300 0%, #ff8c00 100%);
  color: #1a1a1a;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 179, 0, 0.3);
  margin-top: 10px;
  transition: all 0.2s ease;
}

.btn-upgrade-premium:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(255, 179, 0, 0.4);
  background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
}

.btn-upgrade-premium.hidden {
  display: none;
}

#balance-root {
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  background: #474747;
  border-radius: 16px;
  padding: 20px;
  max-width: 100%;
  color: #ffb300;
  width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-container {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}

.intro-overlay {
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background: #000;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  transition: opacity 1s ease;
  pointer-events: all;
}

.intro-logo {
  font-family: 'Verdana', system-ui;
  font-weight: 800;
  color: #ffffff;
  font-size: 80px;
  opacity: 0;
  text-shadow: 0 4px 12px rgba(255,255,255,0.2);
}

.intro-logo.animate {
  animation: logoIntro 2s ease-in-out forwards;
}

@keyframes logoIntro {
  0% { opacity: 0; transform: scale(0.8); filter: blur(10px); }
  40% { opacity: 1; transform: scale(1); filter: blur(0); }
  60% { opacity: 1; transform: scale(1); filter: blur(0); }
  100% { opacity: 0; transform: scale(1.1); filter: blur(5px); }
}

.grid.intro-hidden, .mini-wrap.intro-hidden, .hall-of-fame-bar.intro-hidden {
  visibility: hidden;
}

.intro-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(var(--n, 4), 1fr);
  grid-template-rows: repeat(var(--n, 4), 1fr);
  width: var(--total-grid-size);
  height: var(--total-grid-size);
  flex-shrink: 0;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.cell {
  width: 100%;
  height: 100%;
  background: #1a1a1a;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  position: relative;
  border: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.cell.appear {
  animation: cellAppear 1.2s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

@keyframes cellAppear {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.cell:hover {
  z-index: 2;
}

.cell.filled {
  background: #e0e0e0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* White Diamond Theme (Formerly Marble) */
body[data-theme="marble"] .cell.filled {
  background: #fdfdfd;
  background-image: 
    radial-gradient(at 0% 0%, rgba(200,200,200,0.2) 0, transparent 50%), 
    radial-gradient(at 50% 0%, rgba(180,180,180,0.3) 0, transparent 50%), 
    radial-gradient(at 100% 0%, rgba(200,200,200,0.2) 0, transparent 50%),
    linear-gradient(125deg, transparent 0%, rgba(180,180,180,0.1) 10%, transparent 12%, rgba(160,160,160,0.15) 35%, transparent 37%, rgba(190,190,190,0.1) 75%, transparent 77%),
    linear-gradient(65deg, transparent 0%, rgba(180,180,180,0.1) 15%, transparent 17%, rgba(160,160,160,0.2) 45%, transparent 47%, rgba(190,190,190,0.1) 85%, transparent 87%);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05), 0 2px 5px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

body[data-theme="marble"] .cell.filled::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('https://www.transparenttextures.com/patterns/white-diamond.png'); /* Subtle texture */
  opacity: 0.1;
  pointer-events: none;
}

/* Premium Marble Theme (Formerly Marble 2) */
body[data-theme="marble2"] .cell.filled {
  background-color: #f7f7f7;
  /* Multi-layered vein extraction for realistic Calacatta marble */
  background-image: 
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='v'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='5' seed='50' result='n'/%3E%3CfeComponentTransfer in='n'%3E%3CfeFuncA type='table' tableValues='1 0 1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 0.8 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23v)' opacity='0.3'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='v2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.02' numOctaves='4' seed='100' result='n'/%3E%3CfeComponentTransfer in='n'%3E%3CfeFuncR type='table' tableValues='1 0 1'/%3E%3CfeFuncG type='table' tableValues='1 0 1'/%3E%3CfeFuncB type='table' tableValues='1 0 1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 0.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23v2)' opacity='0.2'/%3E%3C/svg%3E");
  background-size: 600px 600px, 400px 400px;
  background-repeat: repeat;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

/* Premium Marble Theme (Formerly Marble 2) */
body[data-theme="marble2"] .cell.filled {
  background-color: #f7f7f7;
  /* Multi-layered vein extraction for realistic Calacatta marble */
  background-image: 
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='v'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='5' seed='50' result='n'/%3E%3CfeComponentTransfer in='n'%3E%3CfeFuncA type='table' tableValues='1 0 1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 0.8 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23v)' opacity='0.3'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='v2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.02' numOctaves='4' seed='100' result='n'/%3E%3CfeComponentTransfer in='n'%3E%3CfeFuncR type='table' tableValues='1 0 1'/%3E%3CfeFuncG type='table' tableValues='1 0 1'/%3E%3CfeFuncB type='table' tableValues='1 0 1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 0.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23v2)' opacity='0.2'/%3E%3C/svg%3E");
  background-size: 600px 600px, 400px 400px;
  background-repeat: repeat;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

body[data-theme="marble2"] .cell.filled::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* Secondary layer for fine hairline detail */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='fine' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.09' numOctaves='2' seed='15'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23fine)'/%3E%3C/svg%3E");
  opacity: 0.3;
  pointer-events: none;
}

/* Watercolors Theme */
body[data-theme="watercolors"] {
  --w1:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.008 0.04' numOctaves='2' seed='1'/><feDisplacementMap in='SourceGraphic' scale='40'/></filter><rect width='100%' height='100%' fill='%23fafafa'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(120,120,120,0.35)'/></svg>");
  --w2:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.007 0.035' numOctaves='2' seed='2'/><feDisplacementMap scale='38'/></filter><rect width='100%' height='100%' fill='%23fbfbfb'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(100,100,100,0.32)'/></svg>");
  --w3:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.009 0.045' numOctaves='2' seed='3'/><feDisplacementMap scale='42'/></filter><rect width='100%' height='100%' fill='%23f8f8f8'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(110,110,110,0.3)'/></svg>");
  --w4:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.008 0.038' numOctaves='2' seed='4'/><feDisplacementMap scale='36'/></filter><rect width='100%' height='100%' fill='%23fcfcfc'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(90,90,90,0.28)'/></svg>");
  --w5:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.01 0.05' numOctaves='2' seed='5'/><feDisplacementMap scale='44'/></filter><rect width='100%' height='100%' fill='%23f9f9f9'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(130,130,130,0.33)'/></svg>");
  --w6:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.007 0.03' numOctaves='2' seed='6'/><feDisplacementMap scale='34'/></filter><rect width='100%' height='100%' fill='%23fafafa'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(105,105,105,0.3)'/></svg>");
  --w7:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.008 0.04' numOctaves='2' seed='7'/><feDisplacementMap scale='40'/></filter><rect width='100%' height='100%' fill='%23fbfbfb'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(160,140,60,0.18)'/></svg>");
  --w8:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.009 0.045' numOctaves='2' seed='8'/><feDisplacementMap scale='42'/></filter><rect width='100%' height='100%' fill='%23f7f7f7'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(170,150,70,0.16)'/></svg>");
  --w9:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.007 0.032' numOctaves='2' seed='9'/><feDisplacementMap scale='36'/></filter><rect width='100%' height='100%' fill='%23fafafa'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(180,160,80,0.15)'/></svg>");
  --w10: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.01 0.05' numOctaves='2' seed='10'/><feDisplacementMap scale='44'/></filter><rect width='100%' height='100%' fill='%23f8f8f8'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(155,135,60,0.17)'/></svg>");
  --w11: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.008 0.04' numOctaves='2' seed='11'/><feDisplacementMap scale='40'/></filter><rect width='100%' height='100%' fill='%23fcfcfc'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(140,120,50,0.16)'/></svg>");
  --w12: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='f'><feTurbulence type='turbulence' baseFrequency='0.009 0.045' numOctaves='2' seed='12'/><feDisplacementMap scale='42'/></filter><rect width='100%' height='100%' fill='%23f9f9f9'/><rect width='100%' height='100%' filter='url(%23f)' fill='rgba(165,145,70,0.15)'/></svg>");
}

body[data-theme="watercolors"] .cell.filled {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: inset 0 0 15px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}

body[data-theme="watercolors"] .cell.filled::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  pointer-events: none;
  opacity: 0.9;
}

body[data-theme="watercolors"] .cell.filled:nth-child(12n+1)::after  { background-image: var(--w1); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+2)::after  { background-image: var(--w2); transform: scaleX(-1); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+3)::after  { background-image: var(--w3); transform: rotate(90deg); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+4)::after  { background-image: var(--w4); transform: rotate(180deg); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+5)::after  { background-image: var(--w5); transform: scaleY(-1); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+6)::after  { background-image: var(--w6); transform: rotate(270deg); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+7)::after  { background-image: var(--w7); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+8)::after  { background-image: var(--w8); transform: scaleX(-1); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+9)::after  { background-image: var(--w9); transform: rotate(90deg); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+10)::after { background-image: var(--w10); transform: rotate(180deg); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+11)::after { background-image: var(--w11); transform: scaleY(-1); }
body[data-theme="watercolors"] .cell.filled:nth-child(12n+12)::after { background-image: var(--w12); transform: rotate(270deg); }

.cell.selected {
  background: #4a90e2 !important;
  box-shadow: 0 0 15px rgba(74, 144, 226, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.2);
  border: 2px solid #6badf7 !important;
  animation: selectedPulse 0.4s ease-out;
  z-index: 20 !important;
  position: relative;
}

/* Ensure selection color is visible even on themed cells */
.cell.selected::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 144, 226, 0.45) !important;
  z-index: 21 !important;
  border-radius: inherit;
  pointer-events: none;
}

.cell.destination {
  background: #ffb300 !important;
  box-shadow: 0 0 15px rgba(255, 179, 0, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.2);
  border: 2px solid #ffc933 !important;
  animation: destinationPulse 0.4s ease-out;
  z-index: 20 !important;
  position: relative;
}

.cell.destination::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 179, 0, 0.35) !important;
  z-index: 21 !important;
  border-radius: inherit;
  pointer-events: none;
}

@keyframes selectedPulse {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(74, 144, 226, 0.8), inset 0 0 8px rgba(0, 0, 0, 0.1); }
  100% { transform: scale(1); box-shadow: 0 0 12px rgba(74, 144, 226, 0.6), inset 0 0 8px rgba(0, 0, 0, 0.1); }
}

@keyframes destinationPulse {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 179, 0, 0.8), inset 0 0 8px rgba(0, 0, 0, 0.1); }
  100% { transform: scale(1); box-shadow: 0 0 12px rgba(255, 179, 0, 0.6), inset 0 0 8px rgba(0, 0, 0, 0.1); }
}

.cell.executing {
  animation: executeSlide 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes executeSlide {
  0% {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.8), inset 0 0 8px rgba(0, 0, 0, 0.1);
  }
  50% {
    transform: scale(0.95);
    box-shadow: 0 0 30px rgba(76, 175, 80, 1);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(76, 175, 80, 0);
  }
}

.cell.executing-source {
  animation: executeSmoothSlide 0.5s cubic-bezier(0.35, 0, 0.25, 1) forwards;
  z-index: 30 !important;
  position: relative;
}

.cell.executing-source::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(74, 144, 226, 0.5) !important;
  z-index: 31 !important;
  border-radius: inherit;
  pointer-events: none;
  animation: executeOverlayFlash 0.5s ease-out forwards;
}

@keyframes executeOverlayFlash {
  0% { background: rgba(74, 144, 226, 0.6); }
  50% { background: rgba(138, 180, 240, 0.7); }
  100% { background: rgba(76, 175, 80, 0.8); }
}

@keyframes executeSmoothSlide {
  0% {
    transform: translate(0, 0) scale(1);
    background: #4a90e2;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.8);
    border-color: #6badf7;
  }
  50% {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(1);
    background: #8ab4f0;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.6);
    border-color: #a8c8f7;
  }
  100% {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(1);
    background: #ffffff;
    box-shadow: 0 0 12px rgba(200, 200, 200, 0.4);
    border-color: #cccccc;
  }
}

.mini-wrap {
  color: #222;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  align-self: stretch;
}

.mini {
  display: grid;
  gap: 1px;
  border: 1px solid rgba(255,255,255,0.04);
  padding: 4px;
  background: #2b2b2b;
  grid-template-columns: repeat(var(--n, 4), 1fr);
  grid-template-rows: repeat(var(--n, 4), 1fr);
  width: calc(var(--total-grid-size) / 3);
  height: calc(var(--total-grid-size) / 3);
}

.mini-cell {
  width: 100%;
  height: 100%;
  border: 0.5px solid rgba(0,0,0,0.06);
  background: #1a1a1a;
}

#timer {
  margin-top: 16px;
  color: #ffffff;
  font-family: 'Verdana', sans-serif;
  font-weight: bold;
  font-size: 22px;
  text-align: center;
  user-select: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.mini-cell.filled {
  background: #e0e0e0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.logo {
  font-family: 'Verdana', system-ui;
  font-weight: 800;
  color: #ffffff;
  font-size: 36px;
  padding: 16px 0;
  line-height: 1;
  user-select: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.difficulty-selector {
  display: flex;
  gap: 8px;
  margin: 20px 0 12px 0;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  box-sizing: border-box;
}

.diff-btn {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffb300;
  background: rgba(255, 179, 0, 0.1);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  padding: 0;
}

.diff-btn.active {
  background: #ffb300;
  transform: scale(1.3);
  box-shadow: 0 0 12px rgba(255, 179, 0, 0.4);
}

.diff-edge-label {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: bold;
  color: #ffb300;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: 'Verdana', sans-serif;
}

.difficulty-label {
  margin-top: 8px;
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
  color: #222;
  font-family: 'Verdana', sans-serif;
  background: linear-gradient(90deg, #ffd54f 0%, #ffb300 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  width: 100%;
}

.size-select {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #bbb;
}

/* Responsive scaling */
@media (max-width: 1000px) or (max-height: 800px) {
  :root { --total-grid-size: 524px; }
}

@media (max-width: 800px) or (max-height: 700px) {
  :root { --total-grid-size: 428px; }
}

@media (max-width: 600px) {
  .game-container {
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  .mini-wrap {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 8px 16px;
    align-items: start;
    justify-items: center;
    width: 100%;
    max-width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
  }

  /* Left Column */
  .mini {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .logo {
    grid-column: 1;
    grid-row: 3;
    padding: 8px 0 !important;
    font-size: 22px !important;
    margin: 0 !important;
  }

  .footer {
    grid-column: 1;
    grid-row: 4;
    padding-top: 0 !important;
    margin-top: 0 !important;
    font-size: 8px !important;
    opacity: 0.6;
    width: 100%;
    text-align: center;
  }

  /* Right Column */
  .difficulty-selector {
    grid-column: 2;
    grid-row: 1;
    margin: 12px 0 8px 0 !important;
    padding: 0 8px !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
  }

  .diff-edge-label {
    font-size: 8px !important;
    top: -16px !important;
  }

  .difficulty-label {
    grid-column: 2;
    grid-row: 2;
    margin: 0 !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
    width: 100% !important;
  }

  .controls-row {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0 !important;
    justify-self: center;
  }

  #timer {
    grid-column: 2;
    grid-row: 4;
    margin-top: -6px !important;
    font-size: 18px !important;
  }

  :root {
    /* Scale grid to fit mobile screens - reduced to leave more room */
    --total-grid-size: min(85vw, 50vh);
  }
  
  #balance-root {
    padding: 12px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-container {
    flex-direction: row;
    align-items: center;
  }

  :root {
    --total-grid-size: min(80vh, 50vw);
  }
  
  #balance-root {
    padding: 12px;
  }
}

/* Animations and other states */
.cell.forced {
  animation: forced-fill 0.5s;
}

.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-family: 'Verdana', sans-serif;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.2;
  letter-spacing: 0.5px;
  pointer-events: none;
  user-select: none;
  width: 100%;
}

.completion-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease forwards;
}

.cinematic-text-wrap {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #fff;
  transition: opacity 0.6s ease;
}

.cinematic-title {
  font-family: 'Verdana', sans-serif;
  font-weight: bold;
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0;
  animation: fadeIn 1s ease forwards;
}

.cinematic-phonetic {
  font-family: sans-serif;
  font-size: 18px;
  margin-bottom: 8px;
  opacity: 0;
  animation: fadeIn 1s ease 0.5s forwards;
}

.cinematic-definition {
  font-family: 'Verdana', sans-serif;
  font-style: italic;
  font-size: 20px;
  max-width: 500px;
  line-height: 1.4;
  margin-bottom: 12px;
  opacity: 0;
  animation: fadeIn 1s ease 0.5s forwards;
}

.cinematic-latin {
  font-family: 'Verdana', sans-serif;
  font-style: italic;
  font-size: 18px;
  opacity: 0;
  color: rgba(255, 255, 255, 0.7);
  animation: fadeIn 1s ease 0.5s forwards;
  line-height: 1.4;
}

.cinematic-text-wrap.fade-out {
  opacity: 0;
}

.completion-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 1s ease;
  background: #242424;
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid #333;
}

.completion-content.visible {
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.completion-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 30px;
  width: 300px;
  height: 300px;
  animation: scaleUp 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.completion-cell {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: #1a1a1a;
  border: 1px solid #333;
}

.completion-cell.filled {
  background: #e0e0e0;
  border: none;
}

@keyframes scaleUp {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.completion-logo {
  font-family: 'Verdana', system-ui;
  font-weight: 800;
  color: #ffffff;
  font-size: 48px;
  margin-bottom: 20px;
  animation: slideUp 1s ease 0.5s backwards;
}

.completion-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: 'Verdana', sans-serif;
  font-size: 18px;
  font-weight: bold;
  animation: slideUp 1s ease 0.8s backwards;
  margin-bottom: 40px;
}

.completion-buttons {
  display: flex;
  gap: 12px;
  animation: slideUp 1s ease 1.1s backwards;
  flex-wrap: wrap;
  justify-content: center;
}

.pill-button {
  padding: 8px 24px;
  border-radius: 20px;
  font-family: 'Verdana', sans-serif;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, opacity 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pill-button:active {
  transform: scale(0.95);
}

.pill-button.share {
  background: #1e88e5;
  color: #fff;
}

.pill-button.continue {
  background: #fff;
  color: #000;
}

.pill-button.exit {
  background: #444;
  color: #fff;
}

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

@keyframes forced-fill {
  0% { box-shadow: 0 0 0 0 #4a90e2; }
  60% { box-shadow: 0 0 16px 8px #4a90e2; }
  100% { box-shadow: 0 2px 8px rgba(74,144,226,0.15); }
}
.locked {
  opacity: 0.7;
  pointer-events: none;
}
.illegal {
  outline: 2px solid #e24a4a;
}

.share-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.share-modal-content {
  background: #222;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: #fff;
  font-family: 'Verdana', sans-serif;
}

.share-modal-content h2 {
  margin: 0;
  font-size: 20px;
}

.share-img-container {
  width: 70%;
  border: 1px solid #444;
  border-radius: 8px;
  background: #111;
  margin: 5px 0;
}

.social-links {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 10px;
}

.social-link {
  padding: 8px 20px;
  border-radius: 20px;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
}

.copy-btn-inline {
  background: #444;
}

.copy-link-btn-inline {
  background: #fff;
  color: #4a90e2;
}

.x-btn-inline {
  background: #fff;
  color: #4a90e2;
}

.download-btn-inline {
  background: #4a90e2;
}

.exit-inline {
  background: #e24a4a;
}

/* Profile Page Styling */
.profile-container {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.profile-header {
  background: linear-gradient(135deg, #333 0%, #242424 100%);
  border-radius: 12px;
  padding: 40px;
  margin-bottom: 40px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  position: relative;
}

.profile-header-content {
  display: flex;
  align-items: flex-start;
  gap: 30px;
}

.profile-avatar-large {
  font-size: 64px;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
}

.profile-avatar-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
}

.upload-avatar-btn {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffb300;
  border: 2px solid #242424;
  color: #242424;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  padding: 0;
}

.upload-avatar-btn:hover {
  transform: scale(1.1);
}

.social-login-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.logout-btn {
  margin-top: 10px;
  padding: 8px 16px;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.profile-info {
  flex: 1;
}

.profile-settings {
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 200px;
  font-family: 'Verdana', sans-serif;
}

.profile-settings h3 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.5px;
}

.settings-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-item label {
  font-size: 13px;
  color: #ccc;
  font-weight: 500;
}

.settings-select {
  padding: 8px 12px;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-select:hover {
  background: #333333;
  border-color: rgba(255, 255, 255, 0.3);
}

.settings-select:focus {
  outline: none;
  background: #333333;
  border-color: rgba(255, 255, 255, 0.4);
}

.settings-select option {
  background: #2a2a2a;
  color: #fff;
}

.profile-name-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.profile-name {
  margin: 0;
  font-size: 32px;
  color: #fff;
  font-family: 'Verdana', sans-serif;
}

.edit-name-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  padding: 4px 8px;
}

.edit-name-btn:hover {
  opacity: 1;
}

.profile-anon-id {
  margin: 0;
  color: #ffb300;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

/* Name Edit Modal */
.name-edit-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.name-edit-modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: -1;
}

.modal-content {
  background: #333;
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
  margin: 0;
  color: #fff;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #fff;
}

.name-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #242424;
  color: #fff;
  font-size: 14px;
  margin-bottom: 20px;
  font-family: inherit;
}

.name-input:focus {
  outline: none;
  border-color: #ffb300;
  box-shadow: 0 0 8px rgba(255, 179, 0, 0.3);
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Games Section */
.games-section {
  margin-top: 40px;
}

.games-section h2 {
  color: #fff;
  font-family: 'Verdana', sans-serif;
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 24px;
}

/* Filters Container */
.filters-container {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px;
  background: #2a2a2a;
  border-radius: 8px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  color: #ccc;
  font-size: 14px;
  white-space: nowrap;
  font-family: 'Verdana', sans-serif;
}

.filter-select {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-family: 'Verdana', sans-serif;
}

.filter-select:hover {
  border-color: #ffb300;
}

.filter-select:focus {
  outline: none;
  border-color: #ffb300;
  box-shadow: 0 0 8px rgba(255, 179, 0, 0.3);
}

/* Games Table */
.games-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  margin-bottom: 24px;
}

.games-table {
  width: 100%;
  border-collapse: collapse;
  background: #2a2a2a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-family: 'Verdana', sans-serif;
}

.games-table thead {
  background: #1a1a1a;
}

.games-table th {
  color: #ffb300;
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Verdana', sans-serif;
}

.games-table td {
  color: #ccc;
  padding: 14px 16px;
  border-top: 1px solid #333;
  font-size: 14px;
}

.games-table tbody tr:hover {
  background: #333;
}

.games-table .loading {
  text-align: center;
  color: #888;
  font-style: italic;
}

.games-table .error {
  text-align: center;
  color: #e24a4a;
}

.btn-small {
  display: inline-block;
  padding: 6px 12px;
  background: #4a90e2;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s ease;
}

.btn-small:hover {
  background: #357abd;
}

.puzzle-link {
  color: #4a90e2;
  text-decoration: none;
  font-weight: 500;
}

.puzzle-link:hover {
  text-decoration: underline;
  color: #357abd;
}

/* Buttons */
.btn-primary {
  background: #ffb300;
  color: #000;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease;
  font-family: 'Verdana', sans-serif;
}

.btn-primary:hover {
  background: #ffc933;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #555;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease;
  font-family: 'Verdana', sans-serif;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  height: 38px;
}

.btn-secondary:hover:not(:disabled) {
  background: #666;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.admin-btn {
  background: #3498db;
  text-decoration: none;
}

.admin-btn:hover:not(:disabled) {
  background: #2980b9;
}

.btn-back-to-game {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  background: #555;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease;
  font-family: 'Verdana', sans-serif;
  text-decoration: none;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.btn-back-to-game:hover {
  background: #666;
}

.btn-back-to-game:active {
  transform: scale(0.98);
}

/* Pause button and overlay */
.pause-btn {
  background: #3498db;
  color: #fff;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 11px;
  margin-left: 6px;
  transition: background 0.2s ease;
  font-family: 'Verdana', sans-serif;
  height: 24px;
  display: flex;
  align-items: center;
  line-height: 1;
}

.pause-btn:hover {
  background: #2980b9;
}

.pause-btn:active {
  transform: scale(0.98);
}

.pause-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.pause-overlay.hidden {
  display: none;
}

.pause-banner {
  width: 30%;
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  border-radius: 12px;
  padding: 60px 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  min-width: 250px;
  font-family: 'Verdana', sans-serif;
}

@media (max-width: 768px) {
  .pause-banner {
    width: 80%;
    max-width: 400px;
    padding: 40px 20px;
  }
}

.pause-text {
  font-size: clamp(32px, 10vw, 48px);
  font-weight: 800;
  color: #fff;
  margin-bottom: 30px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
  font-family: 'Verdana', sans-serif;
}

.pause-play-btn {
  background: #27ae60;
  color: #fff;
  border: none;
  padding: 20px 32px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: 'Verdana', sans-serif;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pause-play-btn .btn-icon {
  font-size: 24px;
}

.pause-play-btn:hover {
  background: #229954;
}

.pause-play-btn:active {
  transform: scale(0.98);
}

.pause-save-btn {
  background: #3498db;
  color: #fff;
  border: none;
  padding: 20px 32px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Verdana', sans-serif;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pause-save-btn .btn-icon {
  font-size: 24px;
}

.pause-save-btn:hover {
  background: #2980b9;
}

.pause-save-btn:active {
  transform: scale(0.98);
}

.pause-continue-btn {
  background: #3498db;
  color: #fff;
  border: none;
  padding: 20px 32px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Verdana', sans-serif;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pause-continue-btn .btn-icon {
  font-size: 24px;
}

.pause-continue-btn:hover {
  background: #2980b9;
}

.pause-continue-btn:active {
  transform: scale(0.98);
}

.pause-btn-group {
  display: flex;
  gap: 15px;
  margin-top: 10px;
  justify-content: center;
}

.pause-logo {
  height: 50px;
  margin-bottom: 20px;
}

/* Pagination */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.page-info {
  color: #ccc;
  font-size: 14px;
  min-width: 200px;
  text-align: center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #2a2a2a;
  border-radius: 8px;
}

.empty-state.hidden {
  display: none;
}

.empty-state p {
  color: #888;
  font-size: 16px;
  margin: 0;
}

/* Replay Page Styling */
.replay-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

/* Reduce grid size in replay mode to fit browser height */
.replay-container {
  --total-grid-size: 400px;
}

@media (max-height: 900px) {
  .replay-container {
    --total-grid-size: 350px;
  }
}

@media (max-height: 800px) {
  .replay-container {
    --total-grid-size: 300px;
  }
}

@media (max-height: 700px) {
  .replay-container {
    --total-grid-size: 280px;
  }
}

.replay-header {
  background: linear-gradient(135deg, #333 0%, #242424 100%);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.replay-header h1 {
  color: #fff;
  margin: 0;
  font-family: 'Verdana', sans-serif;
  font-size: 28px;
}

.owner-info {
  margin-top: 8px;
  margin-bottom: 20px;
  font-size: 16px;
  color: #bbb;
  font-family: 'Verdana', sans-serif;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.premium-indicator {
  white-space: nowrap;
}

.owner-info.hidden {
  display: none;
}

.owner-name-value {
  color: #fff;
  font-weight: bold;
}

.game-info {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.info-item {
  display: flex;
  gap: 10px;
  align-items: center;
}

.info-label {
  color: #aaa;
  font-size: 14px;
  font-family: 'Verdana', sans-serif;
  font-weight: 600;
}

.info-value {
  color: #ffb300;
  font-size: 16px;
  font-family: 'Verdana', sans-serif;
  font-weight: bold;
}

.replay-main {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.replay-grid-container {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.replay-controls {
  background: #2a2a2a;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.progress-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.move-counter {
  color: #ccc;
  font-size: 14px;
  font-family: 'Verdana', sans-serif;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #444;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb300 0%, #ffc933 100%);
  width: 0%;
  transition: width 0.1s ease;
}

.button-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.control-btn {
  background: #333;
  color: #fff;
  border: 1px solid #555;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Verdana', sans-serif;
  transition: all 0.2s ease;
  min-width: 120px;
}

.control-btn:hover:not(:disabled) {
  background: #444;
  border-color: #ffb300;
}

.control-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.control-btn.play {
  background: #4a90e2;
  border-color: #4a90e2;
}

.control-btn.play:hover {
  background: #357abd;
  border-color: #357abd;
}

.control-btn.pause {
  background: #e24a4a;
  border-color: #e24a4a;
}

.control-btn.pause:hover {
  background: #c93a3a;
  border-color: #c93a3a;
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.speed-control {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.speed-control label {
  color: #ccc;
  font-size: 14px;
  font-family: 'Verdana', sans-serif;
}

.speed-control input[type="range"] {
  width: 150px;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
  -webkit-appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffb300;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 179, 0, 0.3);
}

.speed-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffb300;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(255, 179, 0, 0.3);
}

#speed-label {
  color: #ffb300;
  font-size: 14px;
  font-weight: bold;
  min-width: 30px;
  font-family: 'Verdana', sans-serif;
}

.error-state {
  background: #2a2a2a;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.error-state.hidden {
  display: none;
}

.error-state p {
  color: #e24a4a;
  font-size: 18px;
  margin: 0 0 20px 0;
  font-family: 'Verdana', sans-serif;
}


.replay-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

.replay-actions button {
  flex: 1;
}

#share-game-btn {
  background: #34a853; /* Success green */
  color: white;
  padding: 10px 24px;
  font-size: 14px;
  border-radius: 8px;
  width: auto;
  min-width: 160px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-weight: 700;
  font-family: 'Verdana', sans-serif;
  flex-shrink: 0;
  margin-left: 20px;
  margin-right: 50px; /* Give space for the profile icon */
  z-index: 100; /* High z-index but below profile icon */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

#share-game-btn:hover {
  background: #2d8f47;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
}

.header-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header-main-row h1 {
  margin: 0;
}

/* Adjust the bottom container slightly if needed */
.replay-actions {
  display: flex;
  justify-content: center;
}

.replay-actions .btn-secondary {
  max-width: 300px;
}

.js-hidden {
  display: none !important;
}

/* Profile Mobile Optimizations */
@media (max-width: 768px) {
  .profile-container {
    padding: 10px;
  }

  .profile-header {
    padding: 24px 16px;
    margin-bottom: 24px;
  }

  .profile-header-content {
    flex-direction: column;
    text-align: center;
    gap: 24px;
    align-items: center;
  }

  .profile-avatar-wrapper {
    margin: 0 auto;
  }

  .profile-name-section {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    align-items: center;
  }

  .profile-info {
    width: 100%;
  }

  .profile-settings {
    width: 100%;
    min-width: unset;
    background: rgba(255, 255, 255, 0.08);
    margin-top: 16px;
  }

  .social-login-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  .social-login-section > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100%;
    align-items: stretch;
  }

  .social-login-section .btn-primary,
  .social-login-section .btn-secondary {
    width: 100%;
  }

  .logout-btn {
    width: 100%;
    margin-top: 8px;
  }

  .admin-btn {
    width: 100%;
  }

  /* Elegant Mobile Table: Card-based layout */
  .games-table-wrapper {
    overflow-x: visible;
  }

  .games-table {
    display: block;
    background: transparent;
    box-shadow: none;
    border: none;
  }

  .games-table thead {
    display: none; /* Hide traditional headers */
  }

  .games-table tbody {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .games-table tr {
    display: block;
    background: #2a2a2a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  .games-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-top: none;
    border-bottom: 1px solid #333;
    font-size: 14px;
    text-align: right;
  }

  .games-table td:last-child {
    border-bottom: none;
    padding-top: 16px;
    justify-content: center;
  }

  .games-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #ffb300;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-align: left;
    margin-right: 16px;
  }

  .games-table td[data-label="Actions"]::before {
    display: none; /* Don't show "Actions" label */
  }

  .games-table td[data-label="Actions"] {
    width: 100%;
  }

  .games-table td[data-label="Actions"] .btn-small {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 14px;
  }

  .filters-container {
    flex-direction: column;
    gap: 16px;
  }

  .filter-group {
    width: 100%;
    justify-content: flex-start;
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
  }

  .filter-select {
    width: 100%;
  }

  #clear-filters-btn {
    width: 100%;
    margin-top: 8px;
  }

  .pagination-controls {
    flex-direction: column;
    gap: 16px;
  }

  .page-info {
    order: -1;
    min-width: unset;
  }

  #prev-page-btn, #next-page-btn {
    width: 100%;
  }
}

/* Replay Completion Glow Effect */
@keyframes completionGlow {
  0% { 
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); 
    border-color: #333;
  }
  50% { 
    box-shadow: 0 0 35px rgba(255, 179, 0, 0.9), inset 0 0 20px rgba(255, 179, 0, 0.5); 
    border-color: #ffb300;
  }
  100% { 
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); 
    border-color: #333;
  }
}

.cell.completion-glow {
  animation: completionGlow 4s ease-in-out;
  z-index: 20;
}

/* Win Sequence Styles */
.blackout-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: 0;
  z-index: 5000;
  pointer-events: none;
  transition: opacity 1s ease-in-out;
}

.blackout-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Hall of Fame Bar */
.hall-of-fame-bar {
  font-family: 'Verdana', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  text-align: center;
  margin-top: 20px;
  width: 100%;
  min-height: 16px;
  opacity: 0;
  transition: opacity 3s ease-in-out;
}

.hall-of-fame-bar.visible {
  opacity: 1;
}

@media (max-width: 600px) {
  .hall-of-fame-bar {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.stat-highlight {
  color: #ffb300;
  font-weight: 700;
}

.elite-holder {
  color: #00e5ff;
  text-shadow: 0 0 5px rgba(0, 229, 255, 0.4);
  font-weight: 700;
}

/* Initial Loading Indicator */
.initial-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  min-width: 320px;
  min-height: 320px;
  transition: opacity 0.5s ease;
}

.initial-loading.hidden {
  display: none;
}

.loading-logo {
  height: 60px;
  margin-bottom: 30px;
  filter: drop-shadow(0 0 10px rgba(255, 179, 0, 0.3));
  animation: logoPulse 2s ease-in-out infinite;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 179, 0, 0.1);
  border-top: 3px solid #ffb300;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Landing Card Styles */
.landing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  min-width: 400px;
  min-height: 400px;
  text-align: center;
  transition: opacity 0.8s ease-in-out;
  background: #333;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border: 1px solid rgba(255, 179, 0, 0.2);
}

.landing-card.hidden {
  display: none;
}

.landing-content {
  animation: fadeIn 1.5s ease;
}

.landing-logo {
  height: 80px;
  margin-bottom: 40px;
  filter: drop-shadow(0 0 15px rgba(255, 179, 0, 0.4));
}

.landing-msg {
  font-family: 'Verdana', sans-serif;
  color: #ffffff;
  font-size: 18px;
  line-height: 1.2;
  margin-bottom: 50px;
  letter-spacing: 0.5px;
  max-width: 320px;
}

.landing-msg b {
  color: #ffb300;
  display: block;
  font-size: 22px;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.start-btn {
  background: transparent;
  border: 2px solid #ffb300;
  color: #ffb300;
  padding: 16px 40px;
  font-family: 'Verdana', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  border-radius: 50px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.start-btn:hover {
  background: #ffb300;
  color: #242424;
  box-shadow: 0 0 30px rgba(255, 179, 0, 0.4);
  transform: translateY(-2px);
}

.start-btn:active {
  transform: translateY(0);
}

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

@media (max-width: 500px) {
  .landing-card {
    min-width: 100%;
    padding: 40px 20px;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .profile-header {
    padding: 16px 12px;
    margin-bottom: 16px;
  }

  .profile-avatar-large {
    font-size: 48px;
    width: 80px;
    height: 80px;
  }

  .profile-avatar-wrapper {
    width: 80px;
    height: 80px;
  }

  .profile-name {
    font-size: 24px;
    margin: 0;
  }

  .profile-anon-id {
    font-size: 12px;
    margin: 4px 0 0 0;
  }

  .btn-primary {
    padding: 10px 16px;
    font-size: 13px;
  }

  .profile-settings {
    padding: 12px;
  }

  .profile-settings h3 {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .settings-item {
    gap: 4px;
  }

  .settings-select {
    font-size: 12px;
    padding: 6px 10px;
  }
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(255, 179, 0, 0.3)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 20px rgba(255, 179, 0, 0.6)); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
