:root {
  /* Turtle-green theme palette */
  --shell-dark: #2E7D44;
  --shell: #3FA34D;
  --shell-light: #8FD694;
  --sand: #F4E4C1;
  --sand-dark: #E6CF9C;
  --sky: #BFE9FF;
  --sky-soft: #E8F8FF;
  --ocean: #39B6D8;
  --ocean-dark: #2E9CCA;
  --coral: #FF8A80;
  --sun: #FFD66B;
  --ink: #1F3D29;
  --white: #ffffff;

  --ui-font: "Fredoka", system-ui, "Segoe UI", "Nunito", "Quicksand", sans-serif;
  --radius: 22px;
  --shadow: 0 10px 0 rgba(31, 61, 41, 0.18), 0 14px 26px rgba(31, 61, 41, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--ui-font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  background: linear-gradient(180deg, var(--sky-soft) 0%, var(--sky) 55%, var(--ocean) 100%);
}

#game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* ---------- Overlay screens ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fade-in 0.25s ease both;
}

.screen.hidden { display: none; }

.card {
  pointer-events: auto;
  width: min(440px, 92vw);
  background: linear-gradient(180deg, #ffffff 0%, #f3fff4 100%);
  border: 4px solid var(--shell-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px 22px;
  text-align: center;
}

.logo {
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 700;
  margin: 4px 0 2px;
  color: var(--shell-dark);
  letter-spacing: 0.5px;
  text-shadow: 0 3px 0 var(--shell-light);
}
.logo-turtle { display: inline-block; animation: bob 2.4s ease-in-out infinite; }

.tagline {
  margin: 0 0 18px;
  font-size: clamp(15px, 3.6vw, 18px);
  color: var(--shell-dark);
  opacity: 0.9;
}

h2 {
  color: var(--shell-dark);
  font-weight: 700;
  font-size: clamp(24px, 5vw, 30px);
  margin: 2px 0 14px;
}

.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 8px 0;
  flex-wrap: wrap;
}

.btn {
  pointer-events: auto;
  font-family: var(--ui-font);
  font-weight: 600;
  font-size: clamp(16px, 4vw, 19px);
  color: var(--shell-dark);
  background: var(--white);
  border: 3px solid var(--shell);
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(46, 125, 68, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}
.btn:hover { background: #f0fff2; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(46, 125, 68, 0.35); }

.btn-primary {
  color: var(--white);
  background: linear-gradient(180deg, var(--shell-light) 0%, var(--shell) 60%, var(--shell-dark) 100%);
  border-color: var(--shell-dark);
  box-shadow: 0 6px 0 var(--shell-dark);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:active { box-shadow: 0 2px 0 var(--shell-dark); }

.best-line, .go-sub { color: var(--shell-dark); opacity: 0.85; margin-top: 16px; }
.go-score { font-size: clamp(18px, 4.6vw, 22px); margin: 6px 0; }
.go-newbest { color: var(--coral); font-weight: 700; font-size: 20px; margin: 6px 0 0; }

.howto {
  text-align: left;
  margin: 0 auto 14px;
  padding-left: 20px;
  line-height: 1.7;
  color: var(--ink);
  font-size: clamp(14px, 3.6vw, 16px);
}
.howto b { color: var(--shell-dark); }

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 9px 0;
  font-size: 18px;
  color: var(--shell-dark);
  font-weight: 600;
}
.toggle input { width: 22px; height: 22px; accent-color: var(--shell); }

/* ---------- In-game corner & touch buttons ---------- */
.corner-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  pointer-events: auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--shell-dark);
  background: rgba(255, 255, 255, 0.85);
  color: var(--shell-dark);
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(46, 125, 68, 0.35);
}
.corner-btn.hidden { display: none; }

#touch-controls {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  padding: 0 20px 24px;
  pointer-events: none;
}
#touch-controls.hidden { display: none; }
.touch-btn {
  pointer-events: auto;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 4px solid var(--shell-dark);
  background: rgba(255, 255, 255, 0.55);
  color: var(--shell-dark);
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 5px 0 rgba(46, 125, 68, 0.3);
}
.touch-btn:active { transform: translateY(3px); }

.hidden { display: none !important; }

@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Respect reduced motion when the player opts in (class toggled from JS too) */
@media (prefers-reduced-motion: reduce) {
  .logo-turtle { animation: none; }
  .screen { animation: none; }
}
body.reduced-motion .logo-turtle,
body.reduced-motion .screen { animation: none; }

/* ---------- Skins shop ---------- */
.card-wide { width: min(640px, 94vw); }
.skins-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0 4px;
}
.skin-card {
  background: #ffffff;
  border: 3px solid var(--shell-light);
  border-radius: 16px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.skin-card.selected {
  border-color: var(--shell-dark);
  box-shadow: 0 0 0 3px var(--sun) inset;
}
.skin-swatch { width: 86px; height: 64px; object-fit: contain; }
.skin-name { font-weight: 600; color: var(--shell-dark); font-size: 14px; }
.skin-card .btn { padding: 7px 14px; font-size: 14px; box-shadow: 0 4px 0 rgba(46,125,68,0.3); }
.skins-msg { color: var(--coral); font-weight: 600; min-height: 18px; margin: 8px 0 0; }
@media (max-width: 480px) { .skins-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- High contrast ---------- */
body.high-contrast .card { border-width: 5px; border-color: #08311a; background: #ffffff; }
body.high-contrast .btn { border-width: 4px; color: #08311a; border-color: #08311a; }
body.high-contrast .btn-primary { background: #1d7a3a; color: #ffffff; }
body.high-contrast h1, body.high-contrast h2,
body.high-contrast .tagline, body.high-contrast .best-line,
body.high-contrast .toggle, body.high-contrast .skin-name { color: #08311a; }
body.high-contrast .corner-btn, body.high-contrast .touch-btn {
  background: #ffffff; border-color: #08311a; color: #08311a;
}
