/*
Design System — puzzledethan
Light | Funky | Minimal
*/

:root {
  --bg-main: #f7f9fc;
  --bg-card: #ffffff;

  --color-primary: #4f46e5;   /* Indigo */
  --color-accent: #22c55e;    /* Green */
  --color-danger: #ef4444;    /* Red */

  --color-text-main: #111827;
  --color-text-muted: #6b7280;

  --border-radius: 10px;
  --border-light: #e5e7eb;

  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* CRITICAL: Force the app to be exactly the screen size. */
html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none; /* Stops pull-to-refresh at CSS level */
}

body {
  background: var(--bg-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--color-text-main);
  line-height: 1.5;
  
  /* Flex Layout: Header -> Main -> Footer */
  display: flex;
  flex-direction: column;
}

/* Layout */

header {
  flex: 0 0 auto;
  padding: 12px; /* Reduced padding */
  text-align: center;
  font-weight: 800;
  font-size: 1.4rem;
}

main {
  flex: 1; /* Takes all remaining space */
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
  
  /* Center the content vertically & horizontally */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  
  /* Critical for allowing children to shrink if screen is small */
  min-height: 0; 
  overflow: hidden; 
}

footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 10px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Links */

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

a:hover {
  text-decoration: underline;
}

/* Cards */

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  
  /* Flex allow it to shrink */
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px; /* Prevent it getting too wide */
  
  /* Ensure it doesn't overflow parent main */
  max-height: 100%;
  overflow: hidden; 
}

/* Controls */

button,
select {
  padding: 8px 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
}

button {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  opacity: 0.9;
}

select {
  background: #ffffff;
}

/* Game Canvas Areas (Maze, Sliding, etc.) */

#maze-canvas, 
#game-canvas {
  margin-top: 12px;
  width: 100%;
  display: flex;
  justify-content: center;
  
  /* Prevent gestures */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Win banner */

.win-banner {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #065f46;
  border-radius: var(--border-radius);
  padding: 8px;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
}