/* Enable smooth viewport sizing */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden; /* Prevents whole-page scrolling */
  font-family: system-ui, -apple-system, sans-serif;
  background-color: #12131C;
  color: #FFFFFF;
}

/* App Layout Container */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  padding: 12px;
  gap: 10px;
}

/* Header Section */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap; /* Wraps items nicely on very narrow screens */
  gap: 8px;
  padding: 8px 12px;
  background: #1B1C28;
  border-radius: 8px;
  flex-shrink: 0; /* Ensures header never gets compressed */
}

.stats-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #7A7E9D;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: bold;
  color: #00E5FF;
}

/* Canvas Container */
#canvas-container {
  flex: 1; /* Takes up all remaining vertical space */
  position: relative;
  min-height: 0; /* Important: Allows flex child to shrink properly */
  background: #181924;
  border-radius: 10px;
  border: 1px solid #2A2B3D;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Controls / Bottom Action Bar */
#controls {
  display: flex;
  gap: 10px;
  flex-shrink: 0; /* Keeps controls pinned inside screen boundaries */
  width: 100%;
}

/* Shared button sizing for Reset, Submit, and Split Container */
#reset-btn,
#submit-btn,
.split-btn-container {
  flex: 1;
  min-width: 0; /* Prevents flex overflow */
}

button {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

#reset-btn {
  background-color: #2A2B3D;
  color: #A0A5C0;
}

#reset-btn:active {
  background-color: #3B3D54;
}

#submit-btn {
  background-color: #4E9F3D;
  color: #FFFFFF;
}

#submit-btn:disabled {
  background-color: #253326;
  color: #556B57;
  cursor: not-allowed;
}

/* ==========================================
   SPLIT BUTTON CONTAINER & SUB-BUTTONS
   ========================================== */
.split-btn-container {
  display: flex;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

.main-load-btn {
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, padding 0.35s ease;
  max-width: 100%;
  opacity: 1;
  background-color: #00E5FF;
  color: #12131C;
}

.main-load-btn:disabled {
  background-color: #1E2D38;
  color: #3E5A6E;
  cursor: not-allowed;
}

.split-actions {
  display: flex;
  width: 100%;
  gap: 6px;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

/* Expanded Split State */
.split-btn-container.expanded .main-load-btn {
  max-width: 0;
  opacity: 0;
  padding: 0;
  border: none;
  pointer-events: none;
}

.split-btn-container.expanded .split-actions {
  max-width: 100%;
  opacity: 1;
  pointer-events: auto;
}

/* Solution and Map sub-buttons taking equal 50% width inside the container */
.sub-btn {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  padding: 12px 4px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s ease, transform 0.1s ease;
}

.sub-btn.solution-btn {
  background: #00E5FF;
  color: #12131C;
}

.sub-btn.solution-btn:hover {
  background: #33EBFF;
}

.sub-btn.map-btn {
  background: #FF9800;
  color: #12131C;
}

.sub-btn.map-btn:hover {
  background: #FFA726;
}

/* ==========================================
   MOBILE QUERY adjustments (< 600px)
   ========================================== */
@media (max-width: 600px) {
  #app-container {
    padding: 8px;
    gap: 8px;
  }

  header {
    padding: 6px 10px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 15px;
  }

  button, .sub-btn {
    padding: 10px 4px;
    font-size: 13px;
  }
}