*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,body{
  height: 100%;
  /* Enable smooth scrolling on mobile */
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.container{
  min-height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg-solid);
  background-image: linear-gradient(180deg, var(--bg-grad-start) 0%, var(--bg-grad-mid) 40%, var(--bg-grad-end) 100%);
  margin-right: 320px;
}

@media (max-width: 768px) {
  .container {
    margin-right: 0;
  }
}

@media (max-width: 720px) {
  .container {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3.5rem 1rem 2rem 1rem;
    background-attachment: fixed;
  }
}

#particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2; /* behind UI elements */
  pointer-events: none;
  display: block;
  mix-blend-mode: screen;
  will-change: transform;
}

@media (max-width: 720px) {
  #particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }
}

[data-theme="light"] #particles,
[data-theme="pink"] #particles {
  mix-blend-mode: normal !important;
}


@media (prefers-reduced-motion: reduce) {
  #particles { display: none; }
}

.container > div:nth-of-type(-n+5){
  position: absolute;
  border-radius: 3rem;
  will-change: transform, filter;
  z-index: 0;
}

@media (max-width: 720px) {
  .container > div:nth-of-type(-n+5) {
    will-change: auto;
    border-radius: 2rem;
    position: fixed;
  }

  .container > div:nth-of-type(2) {
    width: 60%;
    height: 70%;
  }
  .container > div:nth-of-type(3) {
    width: 45%;
    height: 45%;
  }
  .container > div:nth-of-type(4) {
    width: 70%;
    height: 55%;
  }
  .container > div:nth-of-type(5) {
    width: 50%;
    height: 45%;
  }
}

/* dynamic drifting for background shapes */
@keyframes drift-slow {
  0%   { transform: translate3d(0,   0, 0) scale(1) rotate(0deg); }
  25%  { transform: translate3d(32px,-24px,0) scale(1.06) rotate(1.5deg); }
  50%  { transform: translate3d(68px, 10px,0) scale(1.12) rotate(3deg); }
  75%  { transform: translate3d(-18px,26px,0) scale(1.07) rotate(1.2deg); }
  100% { transform: translate3d(0,   0, 0) scale(1) rotate(0deg); }
}
@keyframes drift-medium {
  0%   { transform: translate3d(0,   0, 0) scale(1) rotate(0deg); }
  20%  { transform: translate3d(-24px, 18px,0) scale(1.05) rotate(-1deg); }
  40%  { transform: translate3d(36px, -28px,0) scale(1.1) rotate(2deg); }
  60%  { transform: translate3d(58px,  6px,0) scale(1.08) rotate(3deg); }
  80%  { transform: translate3d(-16px, 22px,0) scale(1.06) rotate(0.8deg); }
  100% { transform: translate3d(0,   0, 0) scale(1) rotate(0deg); }
}
@keyframes drift-fast {
  0%   { transform: translate3d(0,   0, 0) scale(1) rotate(0deg); }
  33%  { transform: translate3d(42px, -32px,0) scale(1.08) rotate(2deg); }
  66%  { transform: translate3d(-30px, 28px,0) scale(1.14) rotate(-1.5deg); }
  100% { transform: translate3d(0,   0, 0) scale(1) rotate(0deg); }
}
@keyframes drift-arc {
  0%   { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
  25%  { transform: translate3d(28px, 18px,0) scale(1.06) rotate(1deg); }
  50%  { transform: translate3d(60px,-22px,0) scale(1.12) rotate(2.2deg); }
  75%  { transform: translate3d(-22px,16px,0) scale(1.08) rotate(1.4deg); }
  100% { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
}
.container > div:nth-of-type(1){
  width: 140%;
  height: 110%;
  background: transparent;
  left: -5%;
  top: -5%;
}
.container > div:nth-of-type(2){
  width: 70%;
  height: 80%;
  background: var(--shape-dark);
  top: -12%;
  right: -12%;

}
.container > div:nth-of-type(3){
  width: 50%;
  height: 50%;
  background: var(--shape-dark);
  bottom: -10%;
  left: -5%;}
.container > div:nth-of-type(4){
  width: 80%;
  height: 65%;
  background: var(--shape-light);
  bottom: -15%;
  right: -20%;
}
.container > div:nth-of-type(5){
  width: 60%;
  height: 50%;
  background: var(--shape-dark);
  bottom: 0;
  right: 50%;
}

@media (prefers-reduced-motion: reduce) {
  #particles { display: none; }
  .container > div:nth-of-type(-n+5) { animation: none; }
}
.container::after{
  position: absolute;
  content: '';
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  backdrop-filter: blur(200px);
  z-index: 1;
  pointer-events: none;
}

.glow-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.glow-spot {
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  animation: glow-fade 4.5s ease-in-out forwards;
}

@keyframes glow-fade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  20% { opacity: 0.45; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 0.35; transform: translate(-50%, -50%) scale(1.02); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes float {
  0%   { transform: translate(-50%, 0); }
  50%  { transform: translate(-50%, -12px); }
  100% { transform: translate(-50%, 0); }
}
.title{
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translate(-50%, 0);
  text-align: center;
  animation: float 3.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 4;
}

body{
  font-family: 'Baloo 2', 'Fredoka One', cursive;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  /* Prevent double-tap zoom on mobile */
  touch-action: manipulation;
  /* Prevent text selection during touch interactions */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Re-enable text selection for content that should be selectable */
.box p,
.title,
.settings-panel,
.game-instructions {
  -webkit-user-select: text;
  user-select: text;
}

/* Dyslexia-friendly font - OpenDyslexic alternative using Comic Sans/Arial fallback */
body.dyslexia-font {
  font-family: 'Comic Sans MS', 'Arial', 'Verdana', sans-serif;
  letter-spacing: 0.05em;
  word-spacing: 0.1em;
  line-height: 1.6;
}

body.dyslexia-font .title h1,
body.dyslexia-font .title h2,
body.dyslexia-font .box h3,
body.dyslexia-font .box p,
body.dyslexia-font .btn,
body.dyslexia-font .settings-panel,
body.dyslexia-font .hamburger {
  font-family: 'Comic Sans MS', 'Arial', 'Verdana', sans-serif;
}

:root {
  --animation-speed: 1;
}

.title {
  animation-duration: calc(3.5s / var(--animation-speed));
}

.glow-spot {
  animation-duration: calc(4.5s / var(--animation-speed));
}

/* prevent pull-to-refresh on mobile */
body {
  overscroll-behavior-y: contain;
}

* {
  -webkit-overflow-scrolling: touch;
}

/* Mobile touch targets - ensure minimum 44x44px for accessibility */
@media (max-width: 720px) {
  button,
  a.btn,
  input[type="submit"],
  input[type="button"],
  .hamburger,
  .login-button,
  .theme-swatch {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Improve tap feedback */
  button:active,
  a.btn:active {
    opacity: 0.8;
  }
}
.title h1{
  color: var(--title-color);
  font-family: 'Baloo 2', cursive;
  font-weight: 800;
  font-size: 3.6rem;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}
.title h2{
  color: var(--title-color);
  font-family: 'Baloo 2', cursive;
  font-weight: 700;
  font-size: 1.5rem;
  font-style: italic;
  opacity: 0.9;
}

@media (max-width: 720px) {
  .title h1 {
    font-size: 2.4rem;
    margin-bottom: 0.5rem;
  }
  .title h2 {
    font-size: 1.1rem;
  }
  .title {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    animation: none;
    margin-bottom: 2rem;
    margin-top: 1rem;
  }
}
.boxes{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: stretch;
  justify-content: center;
  width: min(1250px, 95vw);
  z-index: 3;
}
.box{
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex: 1 1 calc(33.333% - 0.9rem);
  min-width: 250px;
  max-width: calc(33.333% - 0.9rem);
  background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
  border-radius: 1rem;
  padding: 1.5rem;
  gap: 0.75rem;
  text-align: center;
  color: var(--text-color);
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(10,7,30,0.5);
  transition: transform .18s ease, box-shadow .18s ease, scale .18s ease;
}

.box:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 40px rgba(10,7,30,0.7);
  scale: 1.02;
}

.box h3{
  margin-bottom: .5rem;
  font-size: 1.25rem;
  text-align: center;
}
.box p{
  margin-bottom: 1rem;
  font-size: .95rem;
  font-weight: 500;
  opacity: .95;
  text-align: center;
  flex-grow: 1;
}

.box p a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  position: relative;
  transition: opacity 0.2s ease;
}

.box p a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1.5px;
  background: var(--accent);
}

.box p a:hover,
.box p a:focus-visible {
  opacity: 0.75;
}

.box p a:active {
  opacity: 0.6;
}

.box .btn{
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-color);
  padding: 0.6rem 0;
  width: 160px;
  max-width: 80%;
  text-align: center;
  border-radius: 0.6rem;
  cursor: pointer;
  font-weight: 700;
  display: block;
  margin: 0.5rem auto 0;
  text-decoration: none;
  margin-top: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.box .btn:active {
  transform: scale(0.97);
}

@media (max-width: 720px) {
  .box .btn {
    padding: 0.75rem 0;
    font-size: 1rem;
  }
}

.boxes > .box:nth-child(1) .btn,
.boxes > .box:nth-child(2) .btn,
.boxes > .box:nth-child(3) .btn{
  margin-left: auto;
  margin-right: auto;
}
.box:hover,
.box:focus-within,
.box:focus-visible {
  transform: translateY(-8px);
  box-shadow: 0 22px 50px rgba(10,7,30,0.65);
}

@media (max-width: 720px) {
  .box:hover,
  .box:focus-within,
  .box:focus-visible {
    transform: none;
    box-shadow: 0 14px 30px rgba(10,7,30,0.5);
  }
}
@media (max-width: 900px){
  .boxes{
    gap: 0.9rem;
    width: min(900px, 94vw);
  }
  .box{
    flex: 1 1 calc(50% - 0.45rem);
    min-width: 220px;
    max-width: calc(50% - 0.45rem);
  }
}
@media (max-width: 720px){
  .boxes{
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    gap: 0.75rem;
  }
  .box{
    flex: 0 0 auto;
    max-width: 100%;
    min-width: 0;
    text-align: center;
  }
  .box .btn{ margin: 0.5rem auto 0; display: block; width: 75%; max-width: 260px; }
}
.return .btn{
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 0.6rem 0.9rem;
    background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
    color: #fff;
    border-radius: 0.6rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 10px 30px rgba(10,7,30,0.5);
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}

.return .btn:hover,
.return .btn:focus-visible{
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(10,7,30,0.6);
}

@media (max-width: 720px){
    .return .btn{
        top: 3.5rem;
        left: 0.6rem;
        min-width: 100px;
        padding: 0.5rem 0.75rem;
        z-index: 1001;
    }
  }

/* back button styling */
.back {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 5;
}

.back .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
  color: var(--text-color);
  border-radius: 0.6rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 20px rgba(10,7,30,0.4);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.back .btn:hover,
.back .btn:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(10,7,30,0.5);
}

@media (max-width: 720px) {
  .back {
    top: 1rem;
    left: 1rem;
  }
  
  .back .btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
  }
}

/* social media icons */
.social-links {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.25rem;
  z-index: 3;
}

@media (max-width: 720px) {
  .social-links {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
  }
}

.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
  color: var(--text-color);
  border-radius: 50%;
  border: 1px solid var(--btn-border);
  box-shadow: 0 8px 20px rgba(10,7,30,0.4);
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, color .18s ease, background .18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.social-icon:hover,
.social-icon:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(10,7,30,0.6);
}

.social-icon:active {
  transform: translateY(-2px) scale(0.95);
}

.social-icon svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 720px) {
  .social-icon {
    width: 44px;
    height: 44px;
  }
  
  .social-icon svg {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 720px) {
  .social-links {
    gap: 1rem;
  }
  
  .social-icon {
    width: 44px;
    height: 44px;
  }
  
  .social-icon svg {
    width: 22px;
    height: 22px;
  }
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
  color: var(--text-color);
  border-radius: 0.6rem;
  border: 1px solid var(--btn-border);
  box-shadow: 0 10px 30px rgba(10,7,30,0.5);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 44px;
}

@media (max-width: 720px) {
  .contact-btn {
    padding: 0.85rem 1.8rem;
    font-size: 1rem;
    min-height: 48px;
  }
}

.contact-btn:hover,
.contact-btn:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(10,7,30,0.6);
}

.contact-btn:active {
  transform: translateY(-2px) scale(0.98);
}

.contact-wrapper {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
}

@media (max-width: 720px) {
  .contact-wrapper {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    text-align: center;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
  }
}

/* settings UI - top right corner */
.settings {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: row;
  gap: 0.8rem;
  align-items: center;
  isolation: isolate;
  mix-blend-mode: normal;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(0,0,0,0.4));
  border-radius: 0.8rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
}

@media (max-width: 720px) {
  .settings {
    top: max(0.5rem, env(safe-area-inset-top));
    right: max(0.5rem, env(safe-area-inset-right));
    flex-direction: row;
    align-items: center;
    padding: 0.5rem;
    gap: 0.5rem;
    background: transparent;
    box-shadow: none;
    border: none;
  }
}
.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.8rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  color: #ffffff;
  font-weight: 700;
  border-radius: 0.6rem;
  transition: background .14s ease, color .14s ease, transform .14s ease, box-shadow .14s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 6px 18px rgba(3,6,20,0.35);
  min-width: 44px;
  min-height: 44px;
  font-size: 1rem;
}

/* Login button on taskbar */
.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 0.6rem;
  transition: background .14s ease, color .14s ease, transform .14s ease, box-shadow .14s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 6px 18px rgba(3,6,20,0.35);
  min-height: 44px;
}

@media (max-width: 720px) {
  .login-button { padding: 0.6rem; font-size: 1rem; }
}

.login-button.logout-button {
  background: var(--btn-bg);
  color: var(--text-color);
  transform: translateY(-1px);
}

/* no pseudo-icon — icon removed per user request */
.login-button::before,
.login-button::after {
  content: none !important;
  display: none !important;
  background: none !important;
  width: auto !important;
  height: auto !important;
}

.login-button:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(3,6,20,0.45); }

@media (max-width: 720px) {
  .hamburger {
    padding: 0.65rem 1rem;
    width: 100%;
    font-size: 1rem;
  }
}
.hamburger.open {
  background: var(--btn-bg);
  color: var(--text-color);
  transform: translateY(-1px);
}
.hamburger span { display: none; }
.hamburger.open span:nth-child(1){ transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2){ opacity: 0; }
.hamburger.open span:nth-child(3){ transform: translateY(-6px) rotate(-45deg); }

.settings-panel {
  min-width: 280px;
  background: linear-gradient(135deg, rgba(0,0,0,0.5), rgba(0,0,0,0.4));
  border-radius: 0.8rem;
  padding: 1.2rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.7);
  display: none !important;
  visibility: hidden !important;
  position: absolute;
  left: -9999px;
  top: -9999px;
  gap: .5rem;
  flex-direction: column;
  align-items: stretch;
  color: var(--settings-text-color);
  z-index: 1001; 
  mix-blend-mode: normal;
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
  width: 0;
  height: 0;
  opacity: 0;
}
.settings-panel.open { 
  display: flex !important;
  visibility: visible !important;
  position: fixed;
  left: auto;
  top: 3rem;
  right: 1rem;
  width: auto;
  height: auto;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 720px) {
  .settings-panel {
    position: fixed;
    right: 0;
    top: 3.5rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    border-radius: 0.6rem 0.6rem 0 0;
    z-index: 999;
  }
}

.settings-panel h4 {
  margin: 0.75rem 0 0.75rem 0;
  font-weight: 700;
  color: var(--settings-text-color);
}

.settings-panel h4:first-child {
  margin-top: 0;
}

.settings-panel .controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-panel label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.35rem;
}

.settings-panel input[type="range"] {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  width: 100%;
  height: 28px;
  padding: 8px 0;
  vertical-align: middle;
  background: transparent;
}

/* Prevent zoom on mobile form inputs */
@media (max-width: 720px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  textarea,
  select {
    font-size: 16px;
  }
}

.settings-panel input[type="range"] {
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}


.settings-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent, #7aa2ff);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.3);
  margin-top: -7px;
}

.settings-panel input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent, #7aa2ff);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.3);
}

.settings-panel input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}

.settings-panel input[type="range"]::-moz-range-track {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}

/* Custom toggle switch for checkboxes */
.settings-panel input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.settings-panel input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.settings-panel input[type="checkbox"]:checked {
  background: var(--accent, #7aa2ff);
}

.settings-panel input[type="checkbox"]:checked::before {
  transform: translateX(20px);
  background: #fff;
}

.settings-panel input[type="checkbox"]:hover {
  background: rgba(255,255,255,0.25);
}

.settings-panel input[type="checkbox"]:checked:hover {
  filter: brightness(1.1);
  background: var(--accent, #7aa2ff);
}

.settings-panel input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

@media (max-width: 720px) {
  .settings-panel input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -8px;
  }
  .settings-panel input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
  .settings-panel input[type="range"]::-webkit-slider-runnable-track {
    height: 10px;
  }
  .settings-panel input[type="range"]::-moz-range-track {
    height: 10px;
  }
  .settings-panel input[type="checkbox"] {
    width: 50px;
    height: 28px;
  }
  .settings-panel input[type="checkbox"]::before {
    width: 22px;
    height: 22px;
  }
  .settings-panel input[type="checkbox"]:checked::before {
    transform: translateX(22px);
  }
  .settings-panel label {
    font-size: 0.95rem;
  }
}
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  justify-content: flex-start;
  border-radius: 0.5rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.04);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease;
}

.theme-swatch:active {
  transform: scale(0.97);
  background: rgba(255,255,255,0.05);
}

@media (max-width: 720px) {
  .theme-swatch {
    padding: 0.7rem 0.8rem;
    font-size: 0.95rem;
  }
}

.settings-panel .swatches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  align-items: center;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.theme-swatch .swatch-preview {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  flex: 0 0 1rem;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.06);
}

.theme-swatch[aria-pressed="true"] {
  outline: 2px solid var(--accent, #7aa2ff);
  background: rgba(0,0,0,0.02);
}

@media (max-width: 720px) {
  .settings-panel .swatches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
}

@media (min-width: 500px) and (max-width: 720px) {
  .settings-panel .swatches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .settings-panel .swatches {
    grid-template-columns: 1fr;
  }
}

.theme-swatch[data-theme="dark"] .swatch-preview { background: linear-gradient(135deg, #0b0b10, #151522); }
.theme-swatch[data-theme="light"] .swatch-preview { background: linear-gradient(135deg, #f4f7fb, #e9eef6); }
.theme-swatch[data-theme="ocean"] .swatch-preview { background: linear-gradient(135deg, #003e66, #006b9a); }
.theme-swatch[data-theme="sunset"] .swatch-preview { background: linear-gradient(135deg, #ffecd2, #ff7b54); }
.theme-swatch[data-theme="forest"] .swatch-preview { background: linear-gradient(135deg, #0b3b2b, #1d6b4f); }
.theme-swatch[data-theme="aurora"] .swatch-preview { background: linear-gradient(135deg, #0a2b2f, #2d0b3b); }
.theme-swatch[data-theme="retro"] .swatch-preview { background: linear-gradient(135deg, #f6e7c1, #e8b26a); }
.theme-swatch[data-theme="solar"] .swatch-preview { background: linear-gradient(135deg, #fff6b3, #ffb056); }
.theme-swatch[data-theme="midnight"] .swatch-preview { background: linear-gradient(135deg, #02021b, #17173d); }
.theme-swatch[data-theme="lava"] .swatch-preview { background: linear-gradient(135deg, #6b0000, #ff8066); }
.theme-swatch[data-theme="pink"] .swatch-preview { background: linear-gradient(135deg, #ffd6e8, #ffb0d6); }
.theme-swatch[data-theme="galaxy"] .swatch-preview { background: linear-gradient(135deg, #0b0821, #4b0d7a); }

:root {
  --settings-text-color: #0b1222; /* default (light theme) */
  --font-scale: 1;
  --bg-solid: #0a0a12;
  --bg-grad-start: #0a0a12;
  --bg-grad-mid: #121227;
  --bg-grad-end: #0a0a12;
  --shape-dark: #000000;
  --shape-light: #ffffff;
  --title-color: #ffffff;
  --box-bg-start: #070707;
  --box-bg-end: #dddddd;
  --text-color: #ffffff;
  --btn-bg: rgba(255,255,255,0.08);
  --btn-border: rgba(255,255,255,0.12);
  --accent: #7aa2ff;
}

/* Dark theme (explicit) */
[data-theme="dark"] {
  --settings-text-color: #ffffff;
  --bg-solid: #0a0a12;
  --bg-grad-start: #0a0a12;
  --bg-grad-mid: #121227;
  --bg-grad-end: #0a0a12;
  --shape-dark: #0c0c18;
  --shape-light: #1a1a26;
  --title-color: #ffffff;
  --box-bg-start: #070707;
  --box-bg-end: #1d1d1d;
  --text-color: #ffffff;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #7aa2ff;
}

/* Light theme */
[data-theme="light"] {
  --settings-text-color: #0b1222;
  --bg-solid: #f6f8fc;
  --bg-grad-start: #f6f8fc;
  --bg-grad-mid: #eef2f8;
  --bg-grad-end: #e6ecf6;
  --shape-dark: #ffffff;
  --shape-light: #ffffff;
  --title-color: #0b1222;
  --box-bg-start: #e4e4e4;
  --box-bg-end: #d4d4d4;
  --text-color: #0b1222;
  --btn-bg: rgba(0,0,0,0.06);
  --btn-border: rgba(0,0,0,0.08);
  --accent: #4a79ff;
}


/* Ocean theme */
[data-theme="ocean"] {
  --settings-text-color: #ffffff;
  --bg-solid: #012a44;
  --bg-grad-start: #012a44;
  --bg-grad-mid: #024b6f;
  --bg-grad-end: #012a44;
  --shape-dark: #063652;
  --shape-light: #88daf8;
  --title-color: #aeefff;
  --box-bg-start: #024b6f;
  --box-bg-end: #006b9a;
  --text-color: #e8f9ff;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #2ec4ff;
}

/* Sunset theme (light-ish, use dark menu text) */
[data-theme="sunset"] {
  --settings-text-color: #0b1222;
  --bg-solid: #ffe0c2;
  --bg-grad-start: #ffe9d6;  
  --bg-grad-mid: #ffb98c;    
  --bg-grad-end: #ff7a4a;  
  --shape-dark: #ffcba3;
  --shape-light: #fff0e6;
  --title-color: #3b2f2f;
  --box-bg-start: #ffb98c;
  --box-bg-end: #ff7a4a;
  --text-color: #2b1f1f;
  --btn-bg: rgba(0,0,0,0.06);
  --btn-border: rgba(0,0,0,0.08);
  --accent: #ff5926;
}

/* Forest theme */
[data-theme="forest"] {
  --settings-text-color: #ffffff;
  --bg-solid: #08231a;
  --bg-grad-start: #08231a;
  --bg-grad-mid: #0c3a2b;
  --bg-grad-end: #08231a;
  --shape-dark: #0a2b22;
  --shape-light: #a6f5cf;
  --title-color: #dfffe9;
  --box-bg-start: #0c3a2b;
  --box-bg-end: #1d6b4f;
  --text-color: #eafff4;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #6be6b5;
}

/* Aurora theme */
[data-theme="aurora"] {
  --settings-text-color: #ffffff;
  --bg-solid: #071a24;
  --bg-grad-start: #071a24;  
  --bg-grad-mid: #0f3646;   
  --bg-grad-end: #2a0e3a;     
  --shape-dark: rgba(40, 255, 190, 0.28);
  --shape-light: rgba(150, 255, 230, 0.22);
  --title-color: #dff7ff;
  --box-bg-start: #10384a;
  --box-bg-end: #2a0e3a;
  --text-color: #e9fffb;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #72f7d2;
}


/* Retro theme (warm neutrals, light menu text color dark) */
[data-theme="retro"] {
  --settings-text-color: #0b1222;
  --bg-solid: #f4e2ba;
  --bg-grad-start: #fff4d4;  
  --bg-grad-mid: #f0c47c;    
  --bg-grad-end: #d88f3f;   
  --shape-dark: #f0cfa0;
  --shape-light: #fff6ec;
  --title-color: #4a3020;
  --box-bg-start: #f0c47c;
  --box-bg-end: #d88f3f;
  --text-color: #3d2718;
  --btn-bg: rgba(0,0,0,0.06);
  --btn-border: rgba(0,0,0,0.08);
  --accent: #ff9f1c;
}

/* Solar theme (bright, use dark menu text) */
[data-theme="solar"] {
  --settings-text-color: #0b1222;
  --bg-solid: #fff3aa;
  --bg-grad-start: #fffad3; 
  --bg-grad-mid: #ffd16f;   
  --bg-grad-end: #ff9a2f; 
  --shape-dark: #ffe7a8;
  --shape-light: #fff7df;
  --title-color: #3b2b00;
  --box-bg-start: #ffd16f;
  --box-bg-end: #ff9a2f;
  --text-color: #3b2b00;
  --btn-bg: rgba(0,0,0,0.06);
  --btn-border: rgba(0,0,0,0.08);
  --accent: #ffb400;
}

/* Midnight theme (very dark) */
[data-theme="midnight"] {
  --settings-text-color: #ffffff;
  --bg-solid: #050522;
  --bg-grad-start: #050522;
  --bg-grad-mid: #0d0d2f;
  --bg-grad-end: #050522;
  --shape-dark: #070731;
  --shape-light: #1a1a3a;
  --title-color: #dfe7ff;
  --box-bg-start: #0d0d2f;
  --box-bg-end: #17173d;
  --text-color: #e9f0ff;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #7aa2ff;
}

/* Lava theme (fiery) */
[data-theme="lava"] {
  --settings-text-color: #ffffff;
  --bg-solid: #2a0000;
  --bg-grad-start: #2a0000;
  --bg-grad-mid: #5a0000;
  --bg-grad-end: #2a0000;
  --shape-dark: #3a0000;
  --shape-light: #ffbbaa;
  --title-color: #fff0f0;
  --box-bg-start: #5a0000;
  --box-bg-end: #ff8066;
  --text-color: #fff3f1;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #ff615a;
}

/* Pink theme (light/pastel) */
[data-theme="pink"] {
  --settings-text-color: #0b1222;
  --bg-solid: #ffe9f3;
  --bg-grad-start: #ffe9f3;
  --bg-grad-mid: #ffc2e3;
  --bg-grad-end: #ff9ed3;
  --shape-dark: #ffb4dc;
  --shape-light: #fff5fb;
  --title-color: #2b0c1a;
  --box-bg-start: #ffc7e8;
  --box-bg-end: #ff9ed3;
  --text-color: #2b0c1a;
  --btn-bg: rgba(0,0,0,0.07);
  --btn-border: rgba(0,0,0,0.1);
  --accent: #ff49b5;
}

/* Galaxy theme (deep purple/blue, white text) */
[data-theme="galaxy"] {
  --settings-text-color: #ffffff;
  --bg-solid: #06021a;
  --bg-grad-start: #06021a;
  --bg-grad-mid: #2c0d3b;
  --bg-grad-end: #0b0821;
  --shape-dark: #0a0620;
  --shape-light: #4d3263;
  --title-color: #f9eaff;
  --box-bg-start: #2c0d3b;
  --box-bg-end: #4b0d7a;
  --text-color: #f0eaff;
  --btn-bg: rgba(255,255,255,0.06);
  --btn-border: rgba(255,255,255,0.08);
  --accent: #a77aff;
}


:root, html, body {
  transition: background 240ms ease, color 240ms ease;
}

.title h1 { font-size: calc(3.6rem * var(--font-scale, 1)); }
.title h2 { font-size: calc(1.35rem * var(--font-scale, 1)); }
.box h3     { font-size: calc(1.1rem * var(--font-scale, 1)); }
.box p      { font-size: calc(0.9rem * var(--font-scale, 1)); }
.box .btn   { font-size: calc(1rem * var(--font-scale, 1)); }

.settings,
.hamburger,
.settings-panel,
.theme-swatch {
  font-family: 'Baloo 2', 'Fredoka One', cursive;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Game Box Styles */
.snake-game-box .play-btn,
.pong-game-box .play-btn,
.memory-game-box .play-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-color);
  padding: 0.6rem 1rem;
  width: auto;
  min-width: 140px;
  max-width: 90%;
  text-align: center;
  border-radius: 0.6rem;
  cursor: pointer;
  font-weight: 700;
  display: inline-block;
  margin: 0.25rem 0.25rem;
  text-decoration: none;
  font-family: 'Baloo 2', cursive;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.snake-game-box .play-btn:hover,
.snake-game-box .play-btn:focus-visible,
.pong-game-box .play-btn:hover,
.pong-game-box .play-btn:focus-visible,
.memory-game-box .play-btn:hover,
.memory-game-box .play-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.snake-game-box .play-btn:active,
.pong-game-box .play-btn:active,
.memory-game-box .play-btn:active {
  transform: scale(0.97);
}

.snake-game-box,
.pong-game-box,
.memory-game-box {
  gap: 0.5rem;
}

.snake-game-box p,
.pong-game-box p,
.memory-game-box p {
  margin-bottom: 0.5rem;
}

/* Game Modal Styles */
.game-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.game-modal-content {
  background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
  padding: 2rem;
  border-radius: 1rem;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--btn-border);
}

.game-modal-content h2 {
  color: var(--text-color);
  margin-bottom: 0.5rem;
  font-size: 2rem;
  font-family: 'Baloo 2', cursive;
}

.game-instructions {
  color: var(--text-color);
  opacity: 0.85;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.close-modal {
  position: absolute;
  right: 1rem;
  top: 1rem;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-color);
  font-size: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
  padding: 0;
}

.close-modal:hover {
  background: var(--accent);
  transform: rotate(90deg);
}

#snake-canvas {
  border: 3px solid var(--btn-border);
  border-radius: 0.5rem;
  display: block;
  margin: 0 auto;
  background: var(--bg-grad-end);
  box-shadow: 0 0 20px var(--accent);
}

@media (max-width: 720px) {
  .game-modal-content {
    padding: 1rem;
    width: 95%;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  #snake-canvas,
  #pong-canvas {
    max-width: 100%;
    width: 100%;
    height: auto;
    touch-action: none;
    /* Prevent image selection on long press */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  
  .game-modal-content h2 {
    font-size: 1.5rem;
  }
  
  .game-instructions {
    font-size: 0.85rem;
    line-height: 1.4;
  }
  
  .close-modal {
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
    /* Ensure touch target is large enough */
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Improve button touch targets */
  .snake-game-box .play-btn,
  .pong-game-box .play-btn,
  .memory-game-box .play-btn {
    padding: 0.85rem 1.25rem;
    min-width: 160px;
    font-size: 1rem;
    /* Prevent double-tap zoom */
    touch-action: manipulation;
  }
}

/* Memory Game Styles */
.memory-modal-content {
  max-width: 650px;
  width: 90%;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.memory-card {
  aspect-ratio: 1;
  cursor: pointer;
  perspective: 1000px;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-front,
.memory-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  border-radius: 0.5rem;
  border: 2px solid var(--btn-border);
}

.memory-card-front {
  background: var(--btn-bg);
  color: var(--text-color);
  font-weight: bold;
}

.memory-card-back {
  background: var(--accent);
  transform: rotateY(180deg);
}

.memory-card.matched .memory-card-back {
  opacity: 0.6;
}

.memory-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: var(--text-color);
  font-weight: bold;
}

.memory-reset {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-color);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.memory-reset:hover {
  background: var(--accent);
}

.memory-win {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--box-bg-start);
  padding: 2rem;
  border-radius: 1rem;
  text-align: center;
  border: 2px solid var(--accent);
  z-index: 10;
}

.memory-win h3 {
  color: var(--text-color);
  font-size: 2rem;
  margin-bottom: 1rem;
}

.memory-win p {
  color: var(--text-color);
  margin-bottom: 1rem;
}

.memory-win button {
  background: var(--accent);
  border: none;
  color: var(--text-color);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
}

@media (max-width: 720px) {
  .memory-grid {
    gap: 0.5rem;
  }
  
  .memory-card-front,
  .memory-card-back {
    font-size: 2rem;
  }
  
  .memory-card {
    /* Improve touch target */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  .memory-reset {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  .memory-win {
    width: 90%;
    max-width: 90vw;
    padding: 1.5rem;
  }
  
  .memory-win h3 {
    font-size: 1.5rem;
  }
  
  .memory-win button {
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Playground Note */
.playground-note {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  text-align: center;
}

.playground-note p {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.9rem;
  font-weight: 500;
  font-style: italic;
}

@media (max-width: 720px) {
  .playground-note {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    width: 90%;
    margin-top: 1.5rem;
  }
  
  .playground-note p {
    font-size: 0.8rem;
  }
}

/* Additional mobile responsiveness for small screens */
@media (max-width: 480px) {
  html, body {
    font-size: 14px;
  }

  .container {
    padding: 2rem 0.5rem 1rem 0.5rem;
  }

  .return,
  .settings {
    right: 0.5rem;
    top: 0.5rem;
  }

  .hamburger,
  .login-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    min-height: 44px;
  }

  .settings-panel {
    max-width: 90vw !important;
    padding: 1rem !important;
  }

  .settings-panel h4 {
    font-size: 0.95rem;
  }

  .settings-panel label {
    font-size: 0.9rem;
  }

  .swatches {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem !important;
  }

  .swatches button {
    padding: 0.6rem !important;
    font-size: 0.8rem;
  }

  input[type="range"] {
    height: 24px !important;
  }

  input[type="checkbox"] {
    width: 40px !important;
    height: 22px !important;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px;
    padding: 0.7rem;
  }

  input[type="text"],
  input[type="password"],
  input[type="email"],
  select {
    min-height: 44px;
    padding: 0.7rem;
    font-size: 16px;
  }

  /* Remove hover effects on touch */
  button:hover {
    transform: none;
  }

  /* Enhance active states for touch feedback */
  button:active {
    opacity: 0.8;
    transform: scale(0.98);
  }

  /* Prevent delay on iOS buttons */
  button,
  a,
  input,
  select,
  textarea {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }

  /* Improve scrolling performance */
  .settings-panel,
  #lib-sidebar-output,
  .py-code-block {
    -webkit-overflow-scrolling: touch;
  }
}

/* Viewport-height fallback for mobile browsers */
@supports (height: 100dvh) {
  html, body {
    height: 100dvh;
  }

  .container {
    min-height: 100dvh;
  }
}

/* Fix for landscape orientation on mobile */
@media (max-height: 600px) and (orientation: landscape) {
  .container {
    min-height: auto;
  }

  .py-editor-card,
  #library-sidebar {
    margin-top: 3rem;
  }

  .settings-panel {
    max-height: 80vh;
  }
}

/* Login Modal Styles */
.login-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.login-modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: -1;
}

.login-box {
  background: linear-gradient(135deg, var(--box-bg-start) 0%, var(--box-bg-end) 100%);
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(10, 7, 30, 0.6);
  padding: 2rem;
  width: 90%;
  max-width: 400px;
  animation: slideUp 0.3s ease;
  position: relative;
  z-index: 1001;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-header h2 {
  color: var(--title-color);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.login-header p {
  color: var(--text-color);
  opacity: 0.9;
  font-size: 0.95rem;
}

.close-login {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.7;
  z-index: 1002;
}

.close-login:hover,
.close-login:focus-visible {
  transform: scale(1.3);
  opacity: 1;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: var(--text-color);
  font-weight: 600;
  font-size: 0.95rem;
}

.form-group input {
  padding: 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.form-group input::placeholder {
  color: var(--text-color);
  opacity: 0.6;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.15);
}

.login-submit {
  padding: 0.8rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent) 100%);
  color: white;
  border: none;
  border-radius: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-top: 0.5rem;
}

.login-submit:hover,
.login-submit:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(122, 162, 255, 0.4);
}

.login-submit:active {
  transform: translateY(0);
}

.login-footer {
  text-align: center;
  color: var(--text-color);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.signup-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.signup-link:hover,
.signup-link:focus-visible {
  opacity: 0.8;
}

@media (max-width: 720px) {
  .login-box {
    padding: 1.5rem;
    max-width: 95%;
  }

  .login-header h2 {
    font-size: 1.5rem;
  }

  .close-login {
    width: 36px;
    height: 36px;
  }
}


