/* ==========================================
   PIXEL COURIER — STYLESHEET
   Uses 5 colors maximum inside the gameplay:
   Navy:   #0a0e17
   Cream:  #f4ebd0
   Mint:   #00f5d4
   Orange: #ff7b00
   Red:    #ff3366
   ========================================== */

:root {
  --navy: #0a0e17;
  --cream: #f4ebd0;
  --mint: #00f5d4;
  --orange: #ff7b00;
  --red: #ff3366;
  
  --font-logo: 'VT323', monospace;
  --font-mono: 'Share Tech Mono', monospace;
}

/* Base resets & prevent scrolling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation; /* disables double tap zoom */
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--navy);
  color: var(--cream);
  font-family: var(--font-mono);
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 600px;
  max-height: 900px;
  background-color: var(--navy);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

/* Pixel Borders & Containers */
.pixel-border {
  border: 4px solid var(--cream);
  position: relative;
  background: var(--navy);
  image-rendering: pixelated;
}

/* Screens */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  padding: 16px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* Panels */
.panel {
  width: 100%;
  max-width: 420px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.panel.wide {
  max-width: 520px;
  height: 90%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Logo and Headings */
.logo-container {
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pixel-art-logo {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.pixel-art-logo .p-block {
  width: 16px;
  height: 16px;
  display: block;
}

.pixel-art-logo .p-block.green { background: var(--mint); }
.pixel-art-logo .p-block.orange { background: var(--orange); }
.pixel-art-logo .p-block.cream { background: var(--cream); }

.game-title {
  font-family: var(--font-logo);
  font-size: 52px;
  line-height: 1;
  color: var(--cream);
  text-shadow: 4px 4px 0px var(--orange);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 16px;
  color: var(--mint);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Pixel Buttons */
.btn-pixel {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: bold;
  padding: 12px 20px;
  border: 4px solid var(--cream);
  background: var(--navy);
  color: var(--cream);
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.05s ease, background 0.1s ease;
  image-rendering: pixelated;
  width: 100%;
  margin-bottom: 12px;
  text-align: center;
}

.btn-pixel:active {
  transform: translate(2px, 2px);
}

.btn-pixel.btn-primary {
  background: var(--orange);
  color: var(--navy);
  border-color: var(--cream);
  text-shadow: none;
}

.btn-pixel.btn-primary:hover {
  background: var(--cream);
  color: var(--navy);
}

.btn-pixel.btn-secondary:hover {
  background: rgba(244, 235, 208, 0.15);
}

.btn-pixel-sm {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  padding: 6px 12px;
  border: 2px solid var(--cream);
  background: var(--navy);
  color: var(--cream);
  cursor: pointer;
  transition: background 0.1s ease;
}

.btn-pixel-sm:hover {
  background: var(--cream);
  color: var(--navy);
}

.menu-buttons {
  width: 100%;
  max-width: 280px;
}

.title-footer {
  margin-top: 32px;
  font-size: 16px;
  color: var(--cream);
}

/* Level Select Layout */
.panel-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--cream);
  padding-bottom: 12px;
}

.panel-header h2 {
  font-family: var(--font-logo);
  font-size: 32px;
  letter-spacing: 1px;
}

.stamp-pill {
  font-size: 16px;
  background: rgba(0, 245, 212, 0.15);
  color: var(--mint);
  padding: 4px 8px;
  border: 2px solid var(--mint);
}

/* Tabs */
.tabs {
  display: flex;
  width: 100%;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1 1 45%;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: bold;
  padding: 8px 4px;
  border: 2px solid var(--cream);
  background: var(--navy);
  color: var(--cream);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--cream);
  color: var(--navy);
}

.tab-contents {
  flex-grow: 1;
  width: 100%;
  overflow-y: auto;
  border: 2px solid var(--cream);
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
}

/* Hide scrollbar for tab contents */
.tab-contents::-webkit-scrollbar {
  width: 6px;
}
.tab-contents::-webkit-scrollbar-track {
  background: var(--navy);
}
.tab-contents::-webkit-scrollbar-thumb {
  background: var(--cream);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 12px;
}

/* Level Select Cards */
.level-card {
  aspect-ratio: 1;
  border: 2px solid var(--cream);
  background: var(--navy);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  position: relative;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.level-card:hover:not(.locked) {
  border-color: var(--mint);
  transform: scale(1.05);
}

.level-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-card .num {
  font-size: 18px;
  font-weight: bold;
  color: var(--cream);
}

.level-card .stamps-row {
  display: flex;
  justify-content: space-around;
  font-size: 10px;
}

.level-card .stamps-row span {
  opacity: 0.2;
}

.level-card .stamps-row span.earned {
  opacity: 1;
  color: var(--mint);
  text-shadow: 0 0 2px var(--mint);
}

.level-card.locked::after {
  content: '🔒';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
}

/* Gameplay Layout */
.gameplay-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  justify-content: space-between;
}

/* HUD */
.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--navy);
  margin-bottom: 8px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-info {
  display: flex;
  flex-direction: column;
}

.level-name {
  font-size: 16px;
  font-weight: bold;
  color: var(--cream);
}

.level-difficulty {
  font-size: 10px;
  font-weight: bold;
  padding: 2px 4px;
  margin-top: 2px;
  align-self: flex-start;
}

.badge-beginner { background: rgba(0, 245, 212, 0.15); color: var(--mint); border: 1px solid var(--mint); }
.badge-intermediate { background: rgba(244, 235, 208, 0.15); color: var(--cream); border: 1px solid var(--cream); }
.badge-advanced { background: rgba(255, 123, 0, 0.15); color: var(--orange); border: 1px solid var(--orange); }
.badge-expert { background: rgba(255, 51, 102, 0.15); color: var(--red); border: 1px solid var(--red); }

.hud-center {
  flex-grow: 1;
  text-align: center;
}

.moves-badge {
  font-size: 16px;
  font-weight: bold;
  color: var(--cream);
}

.moves-badge .moves-val {
  color: var(--mint);
}

.moves-badge .moves-val-target {
  color: var(--orange);
}

.hud-stamps {
  display: flex;
  gap: 6px;
}

.hud-stamps .stamp-icon {
  font-size: 18px;
  filter: grayscale(100%) opacity(0.3);
}

.hud-stamps .stamp-icon.earned {
  filter: none;
  opacity: 1;
}

/* Board Wrapper & Canvas */
.board-wrapper {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
  background: var(--navy);
  overflow: hidden;
}

#game-canvas {
  background: var(--navy);
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  display: block;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--navy);
  margin-top: 8px;
}

.controls-bar .btn-pixel {
  margin-bottom: 0;
  flex: 1;
  font-size: 16px;
  padding: 10px 4px;
}

/* Overlays */
.overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 23, 0.9);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.overlay.active {
  display: flex;
}

.overlay-panel {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: overlayPop 0.15s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes overlayPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.overlay-panel h2 {
  font-family: var(--font-logo);
  font-size: 40px;
  margin-bottom: 16px;
  color: var(--cream);
}

/* Settings Checkbox Styles */
.settings-group {
  width: 100%;
  margin-bottom: 24px;
  border-top: 2px solid var(--cream);
  border-bottom: 2px solid var(--cream);
  padding: 16px 0;
}

.settings-group h3 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--orange);
  text-align: left;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
  font-size: 16px;
  cursor: pointer;
  position: relative;
}

.setting-item input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-chk {
  height: 20px;
  width: 20px;
  border: 2px solid var(--cream);
  background: var(--navy);
  display: block;
}

.setting-item input:checked ~ .custom-chk {
  background: var(--mint);
}

.overlay-buttons {
  width: 100%;
}

/* Results panel styles */
.result-subtitle {
  font-size: 18px;
  color: var(--cream);
  margin-bottom: 20px;
  text-transform: uppercase;
}

.title-win {
  color: var(--mint) !important;
  text-shadow: 2px 2px 0 var(--navy);
}

.title-fail {
  color: var(--red) !important;
  text-shadow: 2px 2px 0 var(--navy);
}

.fail-reason {
  font-size: 18px;
  color: var(--cream);
  margin-bottom: 30px;
}

.stamps-award {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  margin-bottom: 24px;
}

.stamp-card {
  flex: 1;
  border: 2px solid var(--cream);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  background: rgba(0,0,0,0.3);
  opacity: 0.3;
}

.stamp-card.earned {
  opacity: 1;
  border-color: var(--mint);
  color: var(--mint);
}

.stamp-card .stamp-circle {
  font-size: 24px;
  margin-bottom: 6px;
}

.stats-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 24px;
  border-top: 2px dotted var(--cream);
  border-bottom: 2px dotted var(--cream);
  padding: 12px 0;
}

.stat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-box .lbl {
  font-size: 11px;
  color: var(--orange);
  margin-bottom: 4px;
}

.stat-box .val {
  font-size: 18px;
  font-weight: bold;
}

/* NNPlays Score Nudge styling override (matches 5 colors) */
.nn-score-nudge {
  background: var(--navy);
  border: 2px solid var(--cream);
  padding: 12px;
  margin-bottom: 16px;
  width: 100%;
  text-align: center;
}
.nn-score-nudge p {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--cream);
}
.nn-nudge-btns {
  display: flex;
  gap: 8px;
}
.nn-nudge-signup {
  flex: 1;
  background: var(--mint) !important;
  color: var(--navy) !important;
  border: 2px solid var(--cream);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: bold;
  padding: 6px;
  display: block;
}
.nn-nudge-later {
  flex: 1;
  background: var(--navy) !important;
  color: var(--cream) !important;
  border: 2px solid var(--cream);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  padding: 6px;
}

/* Reduced Motion overrides */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

.reduced-motion * {
  transition: none !important;
  animation: none !important;
}
