/* YACHT DOCK — 8-bit CSS
   NES palette: deep navy, bright cyan, hot red, yellow, bone white, lime */

:root {
  --nes-navy:   #0c1a3b;
  --nes-dark:   #050814;
  --nes-blue:   #2a6df2;
  --nes-cyan:   #7cdfff;
  --nes-white:  #f8f8f8;
  --nes-bone:   #e8d9a8;
  --nes-yellow: #ffd23f;
  --nes-orange: #ff8a1f;
  --nes-red:    #ff3b3b;
  --nes-lime:   #b8ff3b;
  --nes-green:  #1fa84f;
  --nes-grey:   #7a7a9a;
  --nes-brown:  #6b3a1f;
}

@font-face {
  font-family: 'NesFont';
  /* Press Start 2P is the reference; fall back to monospace */
  src: local('Press Start 2P'), local('VT323'), local('Courier New');
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--nes-dark);
  color: var(--nes-white);
  font-family: 'Press Start 2P', 'VT323', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.5px;
  -webkit-font-smoothing: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

body {
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 30%, var(--nes-navy), var(--nes-dark) 70%);
}

.hidden { display: none !important; }

/* ============================================================= */
/*  BOOT SCREEN                                                  */
/* ============================================================= */
.boot-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  text-align: center;
  z-index: 20;
  background:
    repeating-linear-gradient(180deg, rgba(124,223,255,0.05) 0 2px, transparent 2px 6px),
    radial-gradient(ellipse at 50% 40%, #102755, #050814 75%);
}

.boot-title {
  font-size: 46px;
  line-height: 1.1;
  color: var(--nes-yellow);
  text-shadow:
    3px 3px 0 var(--nes-red),
    6px 6px 0 var(--nes-navy),
    0 0 20px rgba(255,210,63,0.4);
  letter-spacing: 4px;
  animation: titleBob 1.4s ease-in-out infinite alternate;
}

.boot-sub {
  margin-top: 14px;
  font-size: 10px;
  color: var(--nes-cyan);
  text-shadow: 2px 2px 0 var(--nes-navy);
  letter-spacing: 2px;
}

.boot-flag {
  margin-top: 22px;
  font-size: 28px;
  color: var(--nes-red);
  animation: flagBlink 0.8s steps(2) infinite;
}

.boot-credit {
  position: absolute;
  bottom: 20px;
  font-size: 8px;
  color: var(--nes-grey);
  letter-spacing: 1px;
}

@keyframes titleBob { from { transform: translateY(0); } to { transform: translateY(-4px); } }
@keyframes flagBlink { 50% { opacity: 0; } }
@keyframes blink { 50% { opacity: 0.3; } }

/* ============================================================= */
/*  NES BUTTONS                                                  */
/* ============================================================= */
.nes-btn {
  display: inline-block;
  font: inherit;
  font-size: 12px;
  padding: 14px 22px;
  background: var(--nes-white);
  color: var(--nes-navy);
  border: none;
  border-top: 4px solid #fff;
  border-left: 4px solid #fff;
  border-bottom: 4px solid #8a8a9a;
  border-right: 4px solid #8a8a9a;
  box-shadow: 0 0 0 4px var(--nes-dark), 4px 4px 0 4px rgba(0,0,0,0.5);
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  image-rendering: pixelated;
}
.nes-btn:active {
  border-top: 4px solid #8a8a9a;
  border-left: 4px solid #8a8a9a;
  border-bottom: 4px solid #fff;
  border-right: 4px solid #fff;
  transform: translate(2px, 2px);
}
.nes-btn-yellow {
  background: var(--nes-yellow);
  animation: blink 1.2s infinite;
}
.nes-btn-green {
  background: var(--nes-lime);
  color: var(--nes-dark);
}

/* ============================================================= */
/*  CONFIG SCREEN                                                */
/* ============================================================= */
.config-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 15;
  padding: 12px;
  overflow-y: auto;
}
.config-header {
  text-align: center;
  padding: 8px 0 16px;
  border-bottom: 3px dashed var(--nes-cyan);
  margin-bottom: 12px;
}
.config-title {
  font-size: 18px;
  color: var(--nes-yellow);
  text-shadow: 2px 2px 0 var(--nes-red);
  letter-spacing: 2px;
}
.config-sub {
  margin-top: 6px;
  font-size: 9px;
  color: var(--nes-cyan);
  letter-spacing: 1px;
}
.config-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.config-section { display: flex; flex-direction: column; gap: 6px; }
.config-label {
  font-size: 10px;
  color: var(--nes-bone);
  letter-spacing: 1px;
}
.config-options {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
}
.config-options-wrap { flex-wrap: wrap; }
.opt-btn {
  font: inherit;
  font-size: 9px;
  padding: 10px 10px;
  min-width: 56px;
  background: var(--nes-navy);
  color: var(--nes-cyan);
  border: 2px solid var(--nes-cyan);
  cursor: pointer;
  letter-spacing: 1px;
  white-space: nowrap;
  text-transform: uppercase;
}
.opt-btn.active {
  background: var(--nes-yellow);
  color: var(--nes-navy);
  border-color: var(--nes-white);
  box-shadow: inset 0 0 0 1px var(--nes-red);
}
.opt-btn:active { transform: translate(1px, 1px); }
.config-footer {
  padding: 14px 0 8px;
  text-align: center;
}

/* ============================================================= */
/*  GAME SCREEN                                                  */
/* ============================================================= */
.game-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
  background: var(--nes-dark);
}

.hud {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background:
    linear-gradient(180deg, rgba(12,26,59,0.9), rgba(5,8,20,0.95));
  border-bottom: 3px solid var(--nes-cyan);
  min-height: 56px;
  z-index: 3;
}
.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.hud-center { flex-direction: column; text-align: center; flex: 1; }
.hud-right { justify-content: flex-end; gap: 10px; }
.hud-label {
  font-size: 7px;
  color: var(--nes-cyan);
  letter-spacing: 1px;
}
.hud-wind { display: flex; flex-direction: column; align-items: center; }
.hud-wind-arrow {
  font-size: 22px;
  color: var(--nes-yellow);
  line-height: 1;
  transition: transform 0.2s;
}
.hud-wind-val { font-size: 9px; color: var(--nes-white); margin-top: 2px; }
.hud-status {
  font-size: 10px;
  color: var(--nes-yellow);
  margin-top: 3px;
  letter-spacing: 1px;
}
#hud-dock-label { font-size: 9px; color: var(--nes-bone); }
.hud-speed { display: flex; flex-direction: column; align-items: center; }
.hud-speed-val { font-size: 9px; color: var(--nes-lime); margin-top: 2px; }
.hud-menu-btn {
  font: inherit;
  font-size: 8px;
  padding: 8px 10px;
  background: var(--nes-red);
  color: var(--nes-white);
  border: 2px solid var(--nes-white);
  cursor: pointer;
  letter-spacing: 1px;
}

#canvas {
  flex: 1;
  width: 100%;
  display: block;
  background: #0a2340;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  min-height: 0;
}

/* ============================================================= */
/*  CONTROLS                                                     */
/* ============================================================= */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  padding: 10px 8px 14px;
  background: linear-gradient(0deg, rgba(12,26,59,0.95), rgba(5,8,20,0.9));
  border-top: 3px solid var(--nes-cyan);
  z-index: 3;
}
.ctrl-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.ctrl-col-thruster { gap: 2px; }
.ctrl-btn {
  font: inherit;
  font-size: 20px;
  width: 100%;
  height: 52px;
  background: var(--nes-blue);
  color: var(--nes-white);
  border: none;
  border-top: 3px solid #6da0ff;
  border-left: 3px solid #6da0ff;
  border-bottom: 3px solid #0a1e5c;
  border-right: 3px solid #0a1e5c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ctrl-btn.active, .ctrl-btn:active {
  background: var(--nes-yellow);
  color: var(--nes-red);
  border-top: 3px solid #0a1e5c;
  border-left: 3px solid #0a1e5c;
  border-bottom: 3px solid #fff;
  border-right: 3px solid #fff;
}
.ctrl-lr { height: 96px; font-size: 30px; }
.ctrl-sm { height: 40px; font-size: 12px; }
.ctrl-throttle { height: 38px; font-size: 16px; }
.ctrl-throttle.ctrl-up { background: var(--nes-green); border-top-color: #6eff9a; border-bottom-color: #083a1b; border-left-color: #6eff9a; border-right-color: #083a1b; }
.ctrl-throttle.ctrl-down { background: var(--nes-red); border-top-color: #ff7a7a; border-bottom-color: #5c0a0a; border-left-color: #ff7a7a; border-right-color: #5c0a0a; }
.ctrl-throttle-bar {
  width: 100%;
  height: 14px;
  background: var(--nes-dark);
  border: 2px solid var(--nes-cyan);
  position: relative;
  margin: 2px 0;
}
#throttle-fill {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  background: var(--nes-lime);
  width: 0%;
  transform-origin: left;
}
#throttle-fill.reverse {
  background: var(--nes-red);
}
.ctrl-label {
  font-size: 6px;
  color: var(--nes-cyan);
  letter-spacing: 1px;
}

/* Landscape / desktop tweaks */
@media (min-width: 700px) and (orientation: landscape) {
  .hud { min-height: 64px; }
  .ctrl-btn { height: 60px; font-size: 24px; }
  .ctrl-lr { height: 120px; }
  .controls { max-width: 960px; margin: 0 auto; width: 100%; }
  .config-body { max-width: 560px; margin: 0 auto; width: 100%; }
}

/* ============================================================= */
/*  OVERLAYS (seagull, poop)                                     */
/* ============================================================= */
.seagull-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.seagull {
  position: absolute;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  will-change: transform;
}
.seagull-sprite {
  width: 32px;
  height: 24px;
  image-rendering: pixelated;
  animation: seagullFlap 0.3s steps(2) infinite;
}
.seagull-callout {
  font-family: inherit;
  font-size: 10px;
  background: var(--nes-white);
  color: var(--nes-dark);
  padding: 6px 8px;
  border: 2px solid var(--nes-dark);
  border-radius: 8px;
  position: relative;
  white-space: nowrap;
  box-shadow: 3px 3px 0 var(--nes-red);
  letter-spacing: 1px;
}
.seagull-callout::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 10px;
  border: 6px solid transparent;
  border-right-color: var(--nes-dark);
}
@keyframes seagullFlap { 50% { transform: translateY(-2px); } }

.poop-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}
.poop {
  position: absolute;
  width: 64px;
  height: 64px;
  background: radial-gradient(ellipse at 50% 40%, #f8f8f8 0%, #e0e0d0 40%, #c8c8b0 70%, transparent 85%);
  border-radius: 50% 50% 60% 60% / 40% 40% 70% 70%;
  box-shadow: 0 0 8px rgba(255,255,255,0.4);
  filter: blur(0.5px);
  transform: translate(-50%, -50%) scale(0);
  animation: poopAppear 0.3s ease-out forwards, poopDrip 8s linear 0.4s forwards;
  mix-blend-mode: screen;
}
@keyframes poopAppear {
  to { transform: translate(-50%, -50%) scale(1); }
}
@keyframes poopDrip {
  0%   { transform: translate(-50%, -50%) scale(1, 1); opacity: 1; }
  60%  { transform: translate(-50%, 40%) scale(0.6, 2.2); opacity: 0.8; }
  100% { transform: translate(-50%, 200%) scale(0.2, 3); opacity: 0; }
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--nes-navy);
  color: var(--nes-yellow);
  border: 3px solid var(--nes-yellow);
  padding: 16px 22px;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
  box-shadow: 5px 5px 0 var(--nes-red);
  max-width: 80%;
  z-index: 30;
}
