/* ─── Training Animations & Interactive States ─── */

/* Game Grid Cell Flash */
.grid-cell {
  position: relative;
  overflow: hidden;
}

.grid-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 1;
}

.grid-cell.flash::before {
  opacity: 1;
  animation: cellFlash 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes cellFlash {
  0% { opacity: 0; transform: scale(0.8); }
  20% { opacity: 1; transform: scale(1); box-shadow: 0 0 40px var(--accent-glow); }
  100% { opacity: 0; transform: scale(1.05); }
}

/* Mouse Icon Animation */
.mouse-icon {
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.mouse-icon.press-active {
  transform: scale(0.92) translateY(2px);
}

.mouse-icon.correct-match {
  border-color: #4CAF50 !important;
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

.mouse-icon.wrong-match {
  border-color: #F44336 !important;
  box-shadow: 0 0 15px rgba(244, 67, 54, 0.4);
}

/* Key Cap Press */
.key-cap.pressed {
  transform: translateY(2px);
  box-shadow: 0 0px 0 rgba(0,0,0,0.5);
  background: var(--accent);
  color: #000;
}

/* Progress Bar Shine */
.progress-container {
  overflow: hidden;
  position: relative;
}

.progress-container::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  20% { left: 150%; }
  100% { left: 150%; }
}

/* Status overlays */
.game-status-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  line-height: 1.1; /* Tighter line height for 2-line mode */
  font-size: 38px; /* Larger text */
  letter-spacing: 4px;
  font-weight: 900;
  color: var(--accent); /* Back to branded gold */
  text-shadow: 0 0 20px rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100; /* Over everything */
  text-align: center;
  filter: none !important; /* Never blur the status */
}

.game-status-msg.show {
  opacity: 1;
}

/* ─── Pause & Blur Logic ─── */
.training-layout.is-paused .nback-grid-wrap {
  filter: blur(8px) grayscale(0.2) !important;
  opacity: 0.8;
  pointer-events: none;
}

.nback-grid-wrap {
  transition: filter 0.5s ease, opacity 0.5s ease;
  will-change: filter, opacity;
}

.nback-grid-wrap {
  transition: filter 0.5s ease, opacity 0.5s ease;
  will-change: filter, opacity;
}

/* ─── Tutorial Styles ─── */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.1); /* Very subtle overlay */
  backdrop-filter: none; /* Remove blur to see the grid */
  z-index: 99999;
  display: flex;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none; /* Allow clicking the game UI through the overlay */
}

.tutorial-overlay.show {
  opacity: 1;
  visibility: visible;
}

.tutorial-box {
  background: rgba(25, 25, 35, 0.98);
  border: 2px solid var(--accent);
  padding: 24px;
  border-radius: 16px;
  width: 320px;
  text-align: left;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 215, 0, 0.15);
  animation: boxPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto; /* Re-enable clicks on the box/button itself */
}

@keyframes boxPop {
  from { opacity: 0; transform: translateY(-50%) scale(0.9); }
  to { opacity: 1; transform: translateY(-50%) scale(1); }
}

.tutorial-arrow {
  position: absolute;
  width: 15px;
  height: 15px;
  background: rgba(25, 25, 35, 0.98);
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  top: 50%;
  transform: translateY(-50%) rotate(-45deg);
}

.pos-right .tutorial-arrow {
  left: -9px;
}

.pos-left .tutorial-arrow {
  right: -9px;
  transform: translateY(-50%) rotate(135deg);
}

.pos-top .tutorial-arrow {
  bottom: -9px;
  top: auto;
  left: 50%;
  transform: translateX(-50%) rotate(225deg);
}

.pos-bottom .tutorial-arrow {
  top: -9px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
}

@media (max-width: 1024px) {
  .tutorial-box {
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }

  .tutorial-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 12px;
  }

  .tutorial-action-container {
    gap: 15px;
    padding-top: 10px;
    margin-top: 10px;
  }

  .tutorial-action-hint .hint-label {
    font-size: 8px;
  }

  .tutorial-action-hint .hint-visuals {
    gap: 8px;
  }

  .tutorial-action-hint .key-cap {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  /* Mobile Touch Hint Visual */
  .touch-hint-visual {
    display: flex;
    width: 100px;
    height: 44px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    margin-top: 5px;
  }

  .touch-hint-visual .hint-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .touch-hint-visual .hint-half.left {
    border-right: 1px solid rgba(255, 255, 255, 0.1);
  }

  .touch-hint-visual .hint-half.active {
    background: var(--accent);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
  }

  .touch-hint-visual .hint-half svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.3);
  }

  .touch-hint-visual .hint-half.active svg {
    color: #000;
  }

  .touch-hint-visual .hint-half.pressed {
    transform: scale(0.95);
    filter: brightness(1.2);
  }
}

.tutorial-box.is-centered {
  text-align: center;
}

.tutorial-text {
  font-size: 15px;
  line-height: 1.5;
  color: #fff;
  margin-bottom: 20px;
}

.tutorial-text b {
  color: var(--accent);
}

.tutorial-next-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.2);
}

.tutorial-next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

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

/* Highlighting during tutorial */
.is-tutorial .grid-stage {
  position: relative;
  z-index: 2100;
}

.tutorial-action-container {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tutorial-action-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tutorial-action-hint .hint-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.tutorial-action-hint .hint-visuals {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hint-separator {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: lowercase;
  opacity: 0.6;
}
/* ─── Tablet Tap Hint (Dashboard Controls) ─── */
.tablet-tap-hint {
  display: none;
}

@media (max-width: 1024px) {
  .tablet-tap-hint {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 20px;
  }

  .touch-controls-wrapper {
    display: flex;
    align-items: center;
    gap: 32px;
  }

  .touch-control-group {
    display: flex;
    align-items: center;
    gap: 15px;
  }

  .touch-text-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .touch-control-group.left .touch-text-stack {
    text-align: right;
  }

  .touch-control-group.right .touch-text-stack {
    text-align: left;
  }

  .touch-label {
    font-size: 8px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
  }

  .touch-action {
    font-size: 18px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 2px;
    text-transform: uppercase;
  }

  .touch-box-half {
    width: 48px !important;
    height: 80px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 2px solid rgba(255, 255, 255, 0.1) !important;
    box-sizing: border-box !important;
    transition: all 0.15s ease !important;
  }

  .touch-box-half.left-half {
    border-radius: 10px 0 0 10px !important;
  }

  .touch-box-half.right-half {
    border-radius: 0 10px 10px 0 !important;
  }

  /* Interactive States */
  .touch-box-half.press-active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(0.95);
  }

  .touch-box-half.correct-match {
    background: #4CAF50;
    border-color: #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
  }

  .touch-box-half.wrong-match {
    background: #F44336;
    border-color: #F44336;
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.5);
  }
}

/* Hide mouse controls and hotkeys on mobile to leave only the tap icon */
@media (max-width: 480px) {
  .controls-group,
  .game-area-wrapper .side-info:first-child {
    display: none !important;
  }
  
  .tablet-tap-hint {
    margin-bottom: 10px;
  }
  
  .touch-controls-wrapper {
    gap: 15px;
  }
  
  .touch-box-half {
    width: 40px !important;
    height: 70px !important;
  }
  
  .touch-action {
    font-size: 14px;
  }
  
  .touch-label {
    font-size: 8px;
  }
}

/* ─── Mobile Start/Pause Button (Dynamic Order) ─── */
.mobile-start-pause-btn {
  display: none !important;
}

@media (max-width: 1024px) {
  .mobile-start-pause-btn {
    display: block !important;
    width: 100% !important;
    max-width: 320px !important;
    margin: 10px auto !important;
    padding: 12px 24px !important;
    background: linear-gradient(135deg, rgba(255, 205, 48, 0.15) 0%, rgba(255, 205, 48, 0.05) 100%) !important;
    border: 1px solid rgba(255, 205, 48, 0.3) !important;
    border-radius: 12px !important;
    color: #FFCD30 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: center !important;
    box-sizing: border-box !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
  }

  .mobile-start-pause-btn:active {
    transform: scale(0.98) !important;
    background: linear-gradient(135deg, rgba(255, 205, 48, 0.25) 0%, rgba(255, 205, 48, 0.1) 100%) !important;
    box-shadow: 0 2px 8px rgba(255, 205, 48, 0.2) !important;
  }

  /* Flex order for dynamic positioning inside .training-bottom */
  .training-bottom {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  /* Default or Paused State: button is at the top */
  .training-layout.is-paused .mobile-start-pause-btn {
    order: -1 !important;
    margin-bottom: 20px !important;
    margin-top: 0 !important;
  }

  /* Active Training State: button is at the bottom */
  .training-layout.is-training .mobile-start-pause-btn {
    order: 10 !important;
    margin-top: 20px !important;
    margin-bottom: 0 !important;
  }

  /* Order of other children inside .training-bottom */
  .training-bottom > .label-dim {
    order: 1 !important;
  }

  .training-bottom > .tablet-tap-hint {
    order: 2 !important;
  }

  .training-bottom > .controls-group {
    order: 3 !important;
  }
}

@media (max-width: 768px) {
  .mobile-start-pause-btn {
    max-width: 290px !important;
  }
}

@media (max-width: 480px) {
  .mobile-start-pause-btn {
    max-width: 260px !important;
    padding: 10px 20px !important;
    font-size: 13px !important;
  }
}


