* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

/* Prevent double-tap zoom and remove the 300ms tap delay on all
   interactive elements. iOS ignores user-scalable=no since iOS 10,
   so this CSS approach is the only reliable cross-browser fix. */
button, .grid-box {
  touch-action: manipulation;
}

body {
  /* 100dvh fills the *actual* visible area, adjusting as the browser
     URL bar appears/disappears — much better than 100vh on mobile. */
  height: 100vh;        /* fallback for older browsers */
  height: 100dvh;
  overscroll-behavior: none;
  font-family: 'Inter', sans-serif;
}

/* ---- Animations ---- */
.pop {
  animation: pop 0.1s ease-in-out;
}
@keyframes pop {
  50% { transform: scale(1.1); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.row-checking > .grid-box {
  animation: checking 0.7s ease-in-out infinite;
}
@keyframes checking {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.flip-anim {
  animation: flip-anim 0.6s ease-in-out forwards;
}
@keyframes flip-anim {
  0%   { transform: rotateX(0); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

/* ---- Grid boxes ---- */
/* clamp() makes boxes shrink on narrow phones so the 7-letter row
   never overflows, while growing nicely on wider screens/tablets.   */
.grid-box {
  width:     clamp(2.2rem, 10.5vw, 3.25rem);
  height:    clamp(2.2rem, 10.5vw, 3.25rem);
  font-size: clamp(0.85rem, 4vw, 1.5rem);
  transition: all 0.2s;
  flex-shrink: 0;
  text-align: center;
}

.box-active {
  border-color: #1e40af !important;
  border-width: 3px !important;
}

/* ---- Row states ---- */
.row-inactive {
  opacity: 0.4;
  pointer-events: none;
}

.row-inactive .grid-box {
  background-color: #f1f5f9;
}

@media (hover: hover) {
  .row-clickable .grid-box:hover {
    background-color: #f8fafc;
    cursor: pointer;
  }
}

.row-clickable .grid-box:active {
  opacity: 0.7;
}

/* ---- Loader spinner ---- */
.loader {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

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