:root {
  --bg: #0c0e12;
  --panel: #131722;
  --text: #d6e1ff;
  --muted: #7f8aa5;
  --accent: #55c1ff;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
}
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 70% 20%, #151a25, var(--bg));
  color: var(--text);
  font-family: 'Press Start 2P', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
    Noto Sans, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  letter-spacing: 0.5px;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
  
  .hud {
    order: 2;
  }
  
  .game {
    order: 1;
  }
  
  .panel {
    padding: 12px;
  }
  
  .panel h1 {
    font-size: 14px;
    margin: 8px 0;
  }
  
  .stats {
    font-size: 12px;
  }
  
  .buttons button {
    font-size: 12px;
    padding: 8px 12px;
  }
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: linear-gradient(180deg, #0f1320 0%, #0b0e17 100%);
  border: 1px solid #1d2435;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.panel.canada {
  position: relative;
  overflow: hidden;
  /* Ice theme: deep arctic blues */
  background: linear-gradient(180deg, #0e1b2a 0%, #0b0e17 100%);
  border: 1px solid #1e3a5a;
}
.panel.blue {
  position: relative;
  overflow: hidden;
  /* Blue theme: cool gradients */
  background: linear-gradient(180deg, #0e1b2a 0%, #0b0e17 100%);
  border: 1px solid #1e3a5a;
}
.panel.canada::before,
.panel.canada::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.panel.blue::before,
.panel.blue::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.panel.canada::before {
  /* Icy sheen */
  background: linear-gradient(135deg, rgba(120,180,255,0.12) 0%, transparent 60%);
}
.panel.blue::before {
  /* Icy sheen */
  background: linear-gradient(135deg, rgba(120,180,255,0.12) 0%, transparent 60%);
}
.panel.canada::after {
  /* Frosted glow */
  background: radial-gradient(600px 200px at 20% -20%, rgba(220,240,255,0.08), transparent 60%);
}
.panel.blue::after {
  /* Frosted glow */
  background: radial-gradient(600px 200px at 20% -20%, rgba(220,240,255,0.08), transparent 60%);
}
.panel.canada h1 {
  color: #aee4ff;
}
.panel.blue h1 { color: #aee4ff; }
.panel.canada .stats .label {
  color: #cbe9ff;
}
.panel.blue .stats .label { color: #cbe9ff; }
.canada-note {
  margin-top: 10px;
  color: #cbe9ff;
}
.blue-note { margin-top: 10px; color: #cbe9ff; }

/* Canadian maple leaf badge */
.panel.canada .buttons {
  position: relative;
}
.panel.canada .buttons::after {
  content: '🍁 Canada Strong';
  position: absolute;
  right: 8px;
  top: -26px;
  font-size: 10px;
  color: #e2f2ff;
}
.panel.blue .buttons { position: relative; }
.panel.blue .buttons::after {
  content: '❄️ Ice Mode';
  position: absolute;
  right: 8px;
  top: -26px;
  font-size: 10px;
  color: #e2f2ff;
}

.canada-banner {
  margin: 8px 0 6px 0;
  font-size: 10px;
  color: #d7efff;
}
.blue-banner { margin: 8px 0 6px 0; font-size: 10px; color: #d7efff; }

.maple-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}
.blue-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }

/* Subtle maple + frost background */
.panel.canada {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.06) 0 120px, transparent 121px),
    radial-gradient(circle at 80% 20%, rgba(200,230,255,0.05) 0 90px, transparent 91px),
    repeating-linear-gradient(135deg, rgba(140,190,255,0.06) 0 8px, transparent 8px 16px);
  background-blend-mode: lighten;
}
.panel.blue {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.06) 0 120px, transparent 121px),
    radial-gradient(circle at 80% 20%, rgba(200,230,255,0.05) 0 90px, transparent 91px),
    repeating-linear-gradient(135deg, rgba(140,190,255,0.06) 0 8px, transparent 8px 16px);
  background-blend-mode: lighten;
}

.panel h1 {
  font-size: 18px;
  margin: 0 0 12px 0;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 8px;
  column-gap: 12px;
  align-items: center;
  font-size: 12px;
}
.stats .label {
  color: var(--muted);
}
.stats .value { color: var(--text); }

.buttons {
  display: flex;
  gap: 8px;
  margin: 12px 0 0 0;
  flex-wrap: wrap;
}
.buttons button {
  appearance: none;
  background: #111525;
  color: var(--text);
  border: 1px solid #2a3250;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.35);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}
.buttons button:hover {
  border-color: var(--accent);
}

.help {
  margin-top: 14px;
  font-size: 10px;
  color: var(--muted);
}
.help-title {
  color: var(--text);
  margin-bottom: 8px;
}
.help ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}

/* Keyboard-style hints */
.key-row { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.key {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid #2a3d5a;
  background: linear-gradient(180deg, #0f1a2a, #0a1320);
  color: #d6e1ff;
  font-size: 10px;
}
.hint { color: var(--muted); font-size: 10px; margin-left: 2px; }
.sep { color: var(--muted); margin: 0 6px; }

.panel.next {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 12px;
}

.game {
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

canvas#board {
  width: 480px;
  height: 960px;
  image-rendering: pixelated;
  border-radius: 16px;
  background: #0a0d15;
  border: 1px solid #1d2435;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}

canvas#next {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  border-radius: 8px;
  background: #0a0d15;
  border: 1px solid #1d2435;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}
.overlay.hidden { display: none; }

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    place-items: center;
  }
}

/* Mobile Touch Controls Overlay */
.mobile-controls-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  background: transparent;
  border-radius: 0;
  padding: 20px;
  backdrop-filter: none;
  border: none;
  box-shadow: none;
  
  /* No animation needed without background */
}

.mobile-controls-overlay .touch-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: auto;
}

/* Liquid ripple effect for buttons */
.touch-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, 
    rgba(120, 180, 255, 0.15) 0%, 
    transparent 70%);
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.touch-btn:active::before {
  opacity: 0.6;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.touch-btn {
  position: relative;
  width: 80px;
  height: 80px;
  border: 1px solid rgba(120, 180, 255, 0.25);
  background: linear-gradient(135deg, 
    rgba(120, 180, 255, 0.12) 0%, 
    rgba(85, 193, 255, 0.08) 50%, 
    rgba(120, 180, 255, 0.06) 100%);
  color: rgba(214, 225, 255, 0.9);
  border-radius: 20px;
  font-size: 28px;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(120, 180, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 2px 8px rgba(120, 180, 255, 0.15),
    0 0 20px rgba(120, 180, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(3px);
  /* Debug: make sure button is visible */
  min-height: 80px;
  min-width: 80px;
  
  /* Pulsing red outline for individual buttons */
  animation: pulseRedButton 1.5s ease-in-out infinite;
}

.touch-btn:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, 
    rgba(120, 180, 255, 0.1) 0%, 
    rgba(85, 193, 255, 0.06) 50%, 
    rgba(120, 180, 255, 0.04) 100%);
  border-color: rgba(120, 180, 255, 0.15);
  box-shadow: 
    0 1px 2px rgba(120, 180, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.touch-btn:hover {
  border-color: rgba(120, 180, 255, 0.15);
  box-shadow: 
    0 2px 8px rgba(120, 180, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

/* Temporarily show mobile controls on all devices for testing */
/* Hide mobile controls on desktop */
@media (min-width: 769px) {
  .mobile-controls-overlay {
    /* display: none; */
    opacity: 0.8;
  }
}

/* Mobile canvas sizing */
@media (max-width: 768px) {
  canvas#board {
    width: 320px;
    height: 640px;
  }
  
  canvas#next {
    width: 96px;
    height: 96px;
  }
  
  /* Improve mobile button sizing */
  .buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .buttons button {
    width: 100%;
    padding: 12px;
    font-size: 14px;
  }
  
  /* Better mobile touch targets */
  .touch-btn {
    width: 75px;
    height: 75px;
    font-size: 26px;
  }
  
  .control-row {
    gap: 18px;
  }
  
  /* Position overlay controls properly on mobile */
  .mobile-controls-overlay {
    bottom: 16px;
    padding: 16px;
  }
}

/* Pulsing blue outline animation for mobile controls */
@keyframes pulseBlueOutline {
  0% {
    box-shadow: 
      0 4px 15px rgba(120, 180, 255, 0.12),
      0 0 25px rgba(120, 180, 255, 0.08),
      0 0 0 0 rgba(100, 150, 255, 0.8),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
  50% {
    box-shadow: 
      0 4px 15px rgba(120, 180, 255, 0.12),
      0 0 25px rgba(120, 180, 255, 0.08),
      0 0 0 8px rgba(150, 200, 255, 0.5),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
  100% {
    box-shadow: 
      0 4px 15px rgba(120, 180, 255, 0.12),
      0 0 25px rgba(120, 180, 255, 0.08),
      0 0 0 0 rgba(100, 150, 255, 0.8),
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
}

/* Pulsing blue outline animation for individual buttons */
@keyframes pulseBlueButton {
  0% {
    box-shadow: 
      0 2px 8px rgba(120, 180, 255, 0.15),
      0 0 20px rgba(120, 180, 255, 0.1),
      0 0 0 0 rgba(80, 140, 255, 0.9),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  50% {
    box-shadow: 
      0 2px 8px rgba(120, 180, 255, 0.15),
      0 0 20px rgba(120, 180, 255, 0.1),
      0 0 0 6px rgba(140, 190, 255, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  100% {
    box-shadow: 
      0 2px 8px rgba(120, 180, 255, 0.15),
      0 0 20px rgba(120, 180, 255, 0.1),
      0 0 0 0 rgba(80, 140, 255, 0.9),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .app {
    padding: 12px;
  }
  
  .panel {
    padding: 10px;
  }
  
  .touch-btn {
    width: 70px;
    height: 70px;
    font-size: 24px;
  }
  
  .control-row {
    gap: 14px;
  }
  
  /* Extra small mobile overlay positioning */
  .mobile-controls-overlay {
    bottom: 12px;
    padding: 12px;
  }
}


