:root {
  color-scheme: light;
  --ink: #1f2a2e;
  --muted: #66777b;
  --panel: #fffdf5;
  --line: #d8e2d1;
  --water: #8fd3c8;
  --leaf: #69a86f;
  --moss: #365f44;
  --sun: #ffd36e;
  --coral: #ef7d68;
  --lavender: #8d87d8;
  --sand: #f4d99a;
  font-family: ui-rounded, "SF Pro Rounded", "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #b9ecdf 0%, #e8f7d8 54%, #f8e3ae 100%);
  transition: background 1.2s ease;
}

body[data-time-phase="dawn"] {
  background: linear-gradient(180deg, #ff9c7a 0%, #ffd9a8 60%, #f5deb0 100%);
}

body[data-time-phase="dusk"] {
  background: linear-gradient(180deg, #6a4a8a 0%, #d97a6f 50%, #f4a672 100%);
}

body[data-time-phase="night"] {
  background: linear-gradient(180deg, #0e1133 0%, #252a6a 60%, #3d4275 100%);
}

@media (max-width: 860px) {
  /* Safari iOS — URL bar lives at the bottom */
  body.game-active.in-browser .app-shell {
    padding-top: max(56px, env(safe-area-inset-top));
  }

  body.game-active.in-browser .mobile-action-bar {
    bottom: max(80px, env(safe-area-inset-bottom));
  }

  body.game-active.in-browser .care-layout {
    padding-bottom: 200px;
    justify-content: flex-start;
    gap: 12px;
  }

  body.game-active.in-browser #turtleCanvas {
    max-height: 16vh;
  }

  /* Chrome iOS / Firefox iOS / Edge iOS — URL bar at the top */
  body.game-active.top-bar-browser .app-shell {
    padding-top: 110px;
  }

  body.game-active.top-bar-browser .mobile-action-bar {
    bottom: max(28px, env(safe-area-inset-bottom));
  }

  body.game-active.top-bar-browser .care-layout {
    padding-bottom: 120px;
  }
}

body[data-time-phase="night"] .brand-panel h1,
body[data-time-phase="night"] .brand-panel p,
body[data-time-phase="night"] .eyebrow,
body[data-time-phase="night"] .identity-main h1,
body[data-time-phase="night"] .identity-meta,
body[data-time-phase="night"] .identity-row .identity-meta strong,
body[data-time-phase="night"] .identity-sep {
  color: #f0eef5;
}

body[data-time-phase="night"] .growth-boost {
  background: rgba(121, 184, 93, 0.32);
  color: #d6f5b6;
}

body[data-time-phase="night"] .growth-boost-label {
  color: #d6f5b6;
}

body[data-time-phase="dusk"] .eyebrow {
  color: #fff2d8;
  text-shadow: 0 1px 0 rgba(35, 56, 58, 0.35);
}

body[data-time-phase="dawn"] .eyebrow {
  color: #5a2c2c;
}

body[data-time-phase="night"] .upturtle-credit,
body[data-time-phase="dusk"] .upturtle-credit {
  background: #fffdf5;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 2px solid #23383a;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #23383a;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #23383a;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #23383a;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1160px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.auth-view {
  min-height: calc(100vh - 44px);
  display: grid;
  grid-template-columns: 1fr 390px;
  align-items: center;
  gap: 28px;
}

.brand-panel h1 {
  margin: 0;
  font-size: 4.75rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.identity-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.identity-main h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.identity-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 700;
}

.identity-meta #stageLabel {
  margin: 0;
}

.identity-row .identity-meta strong {
  display: inline;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.identity-sep {
  color: var(--muted);
  font-weight: 700;
}

.growth-boost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #3f7b45;
  font-weight: 800;
  font-size: 0.85rem;
  background: rgba(121, 184, 93, 0.18);
  padding: 2px 8px;
  border-radius: 999px;
}

.growth-leaf {
  flex-shrink: 0;
  image-rendering: pixelated;
}

.growth-boost-label {
  font-weight: 700;
  opacity: 0.78;
  text-transform: lowercase;
}

.identity-controls {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.info-actions {
  display: none;
  gap: 8px;
  margin-top: 12px;
}

.info-actions button {
  flex: 1;
}

.brand-panel p {
  max-width: 580px;
  color: #31464a;
  font-size: 1.2rem;
  line-height: 1.55;
}

.mini-logo {
  width: 72px;
  height: 72px;
  border: 3px solid #23383a;
  border-radius: 8px;
  background: var(--leaf);
  box-shadow: 0 6px 0 #23383a;
  image-rendering: pixelated;
  margin-bottom: 28px;
}

.auth-form,
.stats-panel,
.habitat-panel,
.journal,
.collection {
  border: 3px solid #23383a;
  border-radius: 8px;
  background: rgba(255, 253, 245, 0.92);
  box-shadow: 0 8px 0 rgba(35, 56, 58, 0.22);
}

.auth-form {
  padding: 18px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-switch button.active {
  background: var(--sun);
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  color: var(--muted);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.primary {
  width: 100%;
  margin-top: 8px;
  background: var(--leaf);
  color: #fffdf5;
}

.error {
  min-height: 22px;
  color: #ad352d;
  font-weight: 700;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 10px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #4f7170;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.upturtle-credit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #23383a;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid #23383a;
  border-radius: 8px;
  min-height: 42px;
  box-sizing: border-box;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.upturtle-credit strong {
  color: #69a86f;
}

.upturtle-credit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #23383a;
  background: #ffffff;
}

.upturtle-credit:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #23383a;
}

.upturtle-credit-mark {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  image-rendering: pixelated;
}


.care-layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap: 18px;
  align-items: stretch;
}

.habitat-panel {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(142, 211, 200, 0.7), rgba(255, 253, 245, 0.8) 58%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0 12px, transparent 12px 24px);
}

.skyline {
  display: flex;
  gap: 10px;
  height: 48px;
}

.skyline span {
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.skyline span:nth-child(2) {
  width: 74px;
  margin-top: 12px;
}

.skyline span:nth-child(3) {
  width: 38px;
  margin-top: 6px;
  background: var(--sun);
}

canvas {
  width: min(100%, 430px);
  aspect-ratio: 1;
  justify-self: center;
  margin-bottom: 22px;
  image-rendering: pixelated;
}

.action-progress {
  margin: 0 auto 6px;
  width: min(85%, 320px);
  height: 12px;
  background: rgba(255, 253, 245, 0.85);
  border: 2px solid #23383a;
  border-radius: 6px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 180ms ease;
}

.action-progress.visible {
  opacity: 1;
}

.action-progress-fill {
  height: 100%;
  width: 0%;
  background: #69a86f;
}

.identity-row,
.status-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.identity-row p,
.identity-row strong {
  margin: 0;
}

.identity-row p {
  color: var(--muted);
  font-weight: 800;
}

.field-label {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.identity-row strong {
  display: block;
  font-size: 1.55rem;
}

.stats-panel {
  padding: 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.guide-grid p {
  margin: 0;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.guide-grid strong {
  display: block;
  margin: 0 0 6px;
  line-height: 1.15;
}

.guide-grid p > span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 42, 46, 0.46);
}

.help-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  border: 3px solid #23383a;
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 10px 0 rgba(35, 56, 58, 0.35);
}

.help-modal h2 {
  margin: 0 46px 16px 0;
  font-size: 1.6rem;
}

.forage-modal {
  position: relative;
  width: min(720px, 100%);
  border: 3px solid #23383a;
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 10px 0 rgba(35, 56, 58, 0.35);
}

.forage-head,
.forage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.forage-head h2 {
  margin: 0;
  font-size: 1.45rem;
}

.forage-head strong,
.forage-foot span {
  font-size: 1.15rem;
  font-weight: 900;
}

#forageTimer {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  padding: 4px 14px;
  background: #fff7d5;
  border: 2px solid #23383a;
  border-radius: 8px;
  z-index: 1;
}

.forage-field {
  position: relative;
  height: min(48vh, 360px);
  margin: 16px 0;
  overflow: hidden;
  border: 3px solid #23383a;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.22) 0 10px, transparent 10px 20px),
    linear-gradient(180deg, #8fd3c8, #f4d99a);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.forage-ready {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #31464a;
  font-weight: 900;
  text-align: center;
}

.forage-countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 6rem;
  font-weight: 900;
  color: #23383a;
  text-shadow: 0 4px 0 rgba(35, 56, 58, 0.18);
  pointer-events: none;
  z-index: 2;
  animation: forage-pop 700ms ease-out;
}

@keyframes forage-pop {
  0% { transform: scale(0.6); opacity: 0; }
  30% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.forage-results {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
  background: rgba(255, 253, 245, 0.92);
}

.forage-results h3 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
}

.forage-gains {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
}

.forage-gains li {
  background: #fff;
  border: 2px solid #23383a;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
}

.forage-gains li strong {
  color: #69a86f;
}

.forage-growth {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.forage-target {
  position: absolute;
  width: 76px;
  min-height: 76px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 8px 6px 7px;
  border-radius: 8px;
  border: 2px solid #23383a;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 900;
  box-shadow: 0 4px 0 #23383a;
  animation: targetPulse 800ms ease-in-out infinite alternate;
  transform-origin: center;
}

@keyframes targetPulse {
  from {
    transform: translateY(0) scale(0.96);
  }
  to {
    transform: translateY(-1px) scale(1.02);
  }
}

.forage-art {
  position: relative;
  display: block;
  width: 38px;
  height: 38px;
}

.forage-label {
  font-size: 0.68rem;
  line-height: 1;
  color: #31464a;
}

.forage-art--seaweed {
  width: 24px;
  height: 34px;
  border-radius: 12px 12px 14px 14px;
  background:
    radial-gradient(circle at 50% 8%, #c9f0ad 0 12%, transparent 13%),
    linear-gradient(180deg, #74b96c 0%, #4f8f56 100%);
  box-shadow:
    -10px 6px 0 -9px #4f8f56,
    10px 4px 0 -9px #3f7b45;
  transform: skewX(-10deg);
}

.forage-art--seaweed::before,
.forage-art--seaweed::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #74b96c, #3f7b45);
}

.forage-art--seaweed::before {
  left: 1px;
  height: 34px;
  transform: rotate(-6deg);
}

.forage-art--seaweed::after {
  right: 1px;
  height: 28px;
  transform: rotate(8deg);
}

.forage-art--starfish {
  width: 32px;
  height: 32px;
  background: #ef8b7a;
  clip-path: polygon(50% 0%, 60% 20%, 82% 18%, 70% 38%, 88% 52%, 66% 58%, 70% 82%, 50% 70%, 30% 82%, 34% 58%, 12% 52%, 30% 38%, 18% 18%, 40% 20%);
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.18);
}

.forage-art--starfish::before {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.forage-art--shell {
  width: 34px;
  height: 28px;
  border-radius: 50% 50% 42% 42%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.4) 0 14%, transparent 15%),
    radial-gradient(circle at 50% 60%, #f2d48b 0 8%, transparent 9%),
    linear-gradient(180deg, #e8bf6c, #c89245);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);
}

.forage-art--shell::before {
  content: '';
  position: absolute;
  inset: 6px 7px 6px 7px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  border-left-color: transparent;
  transform: rotate(20deg);
}

.forage-art--crab {
  width: 30px;
  height: 20px;
  border-radius: 50% 50% 40% 40%;
  background: #ef7d68;
  box-shadow:
    -14px 5px 0 -11px #ef7d68,
    14px 5px 0 -11px #ef7d68,
    -8px 15px 0 -11px #ef7d68,
    8px 15px 0 -11px #ef7d68;
}

.forage-art--crab::before,
.forage-art--crab::after {
  content: '';
  position: absolute;
  top: -3px;
  width: 10px;
  height: 10px;
  border: 2px solid #23383a;
  border-radius: 50%;
  background: #fff;
}

.forage-art--crab::before {
  left: 6px;
}

.forage-art--crab::after {
  right: 6px;
}

.forage-art--coral {
  width: 28px;
  height: 34px;
  background:
    linear-gradient(180deg, #ff9b78, #e66d5a);
  clip-path: polygon(40% 100%, 40% 65%, 22% 54%, 16% 38%, 23% 16%, 36% 28%, 50% 0%, 64% 28%, 77% 16%, 84% 38%, 78% 54%, 60% 65%, 60% 100%);
}

.forage-art--anemone {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffd36e 0 30%, transparent 31%),
    radial-gradient(circle at 50% 50%, transparent 0 15%, #8fd3c8 16% 22%, transparent 23%),
    linear-gradient(180deg, #8fd3c8, #4ea9a0);
  box-shadow: inset 0 0 0 2px rgba(35,56,58,0.25);
}

.forage-art--anemone::before,
.forage-art--anemone::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  clip-path: polygon(50% 0%, 55% 20%, 70% 6%, 64% 28%, 86% 24%, 70% 40%, 92% 50%, 70% 60%, 86% 76%, 64% 72%, 70% 94%, 55% 80%, 50% 100%, 45% 80%, 30% 94%, 36% 72%, 14% 76%, 30% 60%, 8% 50%, 30% 40%, 14% 24%, 36% 28%, 30% 6%, 45% 20%);
}

.forage-art--anemone::after {
  inset: -1px;
  border-color: rgba(255,255,255,0.18);
}

.icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.status-strip div {
  min-height: 76px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.status-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-strip strong {
  display: block;
  margin-top: 7px;
  font-size: 1rem;
}

.meters {
  display: grid;
  gap: 10px;
}

.supplies-panel {
  margin-bottom: 14px;
}

.ap-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.ap-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ap-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.ap-panel small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.ap-panel button {
  min-width: 110px;
  background: var(--sun);
}

.supplies-panel h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.supplies {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.supplies span {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: #fff;
  text-align: center;
  font-weight: 900;
}

.supplies b {
  color: var(--muted);
  font-size: 0.72rem;
}

.meter {
  display: grid;
  grid-template-columns: 92px 1fr 42px;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.bar {
  height: 18px;
  border: 2px solid #23383a;
  border-radius: 4px;
  overflow: hidden;
  background: #f1f1ea;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--bar-color);
}

.ap-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  margin-top: 18px;
  background: rgba(255, 247, 213, 0.7);
  border-radius: 10px;
}

.ap-bolt {
  flex-shrink: 0;
  image-rendering: pixelated;
}

.ap-badge-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ap-badge-text strong {
  font-size: 1.8rem;
  font-weight: 900;
  color: #c87a1f;
  line-height: 1;
}

.ap-badge-text small {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.mobile-action-bar,
.actions-open-btn,
.actions-backdrop,
.actions-overlay-head,
.info-open-btn,
.info-backdrop,
.info-overlay-head {
  display: none;
}

.info-container > .status-strip {
  width: 100%;
}

.actions-grid button {
  display: grid;
  place-items: center;
  gap: 2px;
}

.actions-grid small {
  color: rgba(31, 42, 46, 0.72);
  font-size: 0.72rem;
  font-weight: 900;
}

.actions-grid button:disabled,
.ap-panel button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: 0 2px 0 #23383a;
}

.actions-grid button[data-action="pet"],
.actions-grid button[data-action="restock"],
.ap-panel button[data-action="restock"] {
  background: #ffc0a8;
}

.ap-panel button small {
  display: none;
}

.ap-panel button span {
  color: var(--ink);
  font-weight: 900;
}

.actions-grid button[data-action="forage"] {
  background: #b9e79f;
}

.actions-grid button[data-action="feed"] {
  background: #a8d8b0;
}

.actions-grid button[data-action="snack"],
.actions-grid button[data-action="play"] {
  background: #ffd36e;
}

.actions-grid button[data-action="clean"] {
  background: #8fd3c8;
}

.actions-grid button[data-action="nap"] {
  background: #c0bdec;
}

.actions-grid button[data-action="teach"],
.actions-grid button[data-action="explore"] {
  background: #a9d7f2;
}

.actions-grid button[data-action="medicine"] {
  background: #f4a795;
}

.danger {
  width: 100%;
  margin-top: 14px;
  background: #ef7d68;
  color: #fff;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
  margin-top: 18px;
}

.journal,
.collection {
  padding: 16px;
}

.journal h2,
.collection h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.journal ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.journal li {
  border-left: 6px solid var(--water);
  padding: 8px 10px;
  background: #fff;
  border-radius: 6px;
}

.souvenirs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.souvenirs span {
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff;
  font-weight: 800;
}

@media (max-width: 860px) {
  .brand-panel h1 {
    font-size: 3.2rem;
  }

  .identity-main h1 {
    font-size: 1.4rem;
  }

  .eyebrow {
    display: none;
  }

  .topbar {
    padding-bottom: 4px;
    margin-bottom: 16px;
  }

  .skyline {
    display: none;
  }

  #turtleCanvas {
    width: auto;
    max-width: 100%;
    max-height: 24vh;
    margin-bottom: 6px;
  }

  body.game-active {
    overflow: hidden;
    height: 100%;
  }

  body.game-active .app-shell {
    height: 100svh;
    box-sizing: border-box;
    padding-top: 8px;
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar {
    flex-shrink: 0;
  }

  .care-layout {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 80px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 8px;
  }

  .mobile-action-bar {
    display: flex;
    gap: 8px;
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 20;
  }

  .info-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 56px;
    min-height: 56px;
    background: #a9d7f2;
    color: #23383a;
    font-size: 1.4rem;
    font-style: italic;
    font-weight: 900;
    font-family: 'Times New Roman', Georgia, serif;
    border: 2px solid #23383a;
    border-radius: 10px;
    box-shadow: 0 3px 0 #23383a;
  }

  .actions-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 56px;
    padding: 10px 16px;
    background: #79b85d;
    color: #fffdf5;
    font-size: 1.05rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid #23383a;
    border-radius: 10px;
    box-shadow: 0 3px 0 #23383a;
    margin-top: 0;
  }

  .stats-panel .info-container {
    display: none;
  }

  body.info-open .info-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 32, 0.5);
    z-index: 99;
    animation: fadeIn 180ms ease;
  }

  body.info-open .stats-panel .info-container {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 75vh;
    overflow-y: auto;
    padding: 14px 16px 28px;
    background: #fffdf5;
    border-top: 3px solid #23383a;
    border-radius: 18px 18px 0 0;
    z-index: 100;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
    animation: slideUp 220ms ease;
  }

  body.info-open .info-overlay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
  }

  .info-overlay-head h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  body.info-open .status-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body.info-open .info-actions {
    display: flex;
  }

  .habitat-panel .identity-controls {
    display: none;
  }

  .habitat-panel {
    padding: 16px;
    min-height: auto;
    position: sticky;
    top: 8px;
    z-index: 5;
    background:
      linear-gradient(180deg, rgba(142, 211, 200, 0.7), rgba(255, 253, 245, 0.8) 58%),
      repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0 12px, transparent 12px 24px),
      #b9ecdf;
  }

  body[data-time-phase="dawn"] .habitat-panel {
    background:
      linear-gradient(180deg, rgba(255, 156, 122, 0.55), rgba(255, 253, 245, 0.85) 58%),
      repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 12px, transparent 12px 24px),
      #ffd9a8;
  }

  body[data-time-phase="dusk"] .habitat-panel {
    background:
      linear-gradient(180deg, rgba(106, 74, 138, 0.55), rgba(244, 166, 114, 0.7) 58%),
      repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 12px, transparent 12px 24px),
      #d97a6f;
  }

  body[data-time-phase="night"] .habitat-panel {
    background:
      linear-gradient(180deg, rgba(22, 25, 74, 0.65), rgba(61, 66, 117, 0.7) 58%),
      repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 12px, transparent 12px 24px),
      #252a6a;
  }

  canvas {
    margin-bottom: 8px;
  }

  .identity-row {
    gap: 12px;
    flex-wrap: wrap;
  }

  .identity-controls {
    gap: 6px;
    margin-left: auto;
  }

  .identity-controls button {
    min-height: 34px;
    padding: 4px 10px;
    font-size: 0.85rem;
  }

  .actions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
  }

  .actions-grid button {
    min-height: 36px;
    padding: 4px 6px;
    font-size: 0.85rem;
  }

  .actions-grid small {
    display: none;
  }

  .app-shell {
    padding: 12px 0 24px;
  }

  .care-layout {
    gap: 12px;
  }

  .stats-panel {
    padding: 12px;
  }

  .ap-badge {
    margin-top: 0;
    padding: 6px 12px;
    gap: 10px;
  }

  .ap-badge-text strong {
    font-size: 1.4rem;
  }

  .ap-badge-text small {
    font-size: 0.75rem;
  }

  .status-strip {
    grid-template-columns: repeat(3, 1fr);
    padding: 4px 0;
  }

  .status-strip div {
    text-align: center;
  }

  .status-strip span {
    font-size: 0.7rem;
  }

  .status-strip strong {
    font-size: 0.95rem;
  }

  .meter {
    font-size: 0.78rem;
    grid-template-columns: 52px 1fr 26px;
    gap: 4px;
  }

  .auth-view,
  .care-layout,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .auth-view {
    align-content: center;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .habitat-panel {
    min-height: auto;
  }

  .actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }

  .top-actions button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 34px;
    padding: 4px 8px;
    font-size: 0.85rem;
  }

  .upturtle-credit {
    flex: 1 1 0;
    min-width: 0;
    min-height: 34px;
    padding: 4px 8px;
    font-size: 0.72rem;
    justify-content: center;
  }

  .upturtle-credit-mark {
    width: 18px;
    height: 18px;
  }

  .stats-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .stats-panel .ap-badge {
    order: -11;
    margin-top: 0;
  }

  .stats-panel .status-strip {
    order: -9;
  }

  .stats-panel .meters {
    order: -8;
  }

  .stats-panel .supplies-panel {
    order: -7;
    margin-bottom: 0;
  }

  .stats-panel .actions-open-btn {
    order: 99;
  }

  .stats-panel .ap-panel,
  .lower-grid {
    display: none;
  }

  .supplies-panel h2 {
    margin-bottom: 6px;
    font-size: 0.72rem;
  }

  .supplies {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  .supplies span {
    min-height: 0;
    padding: 4px 2px;
    font-size: 0.85rem;
    gap: 0;
    border-width: 1.5px;
  }

  .supplies b {
    font-size: 0.55rem;
    letter-spacing: 0.02em;
  }

  .meters {
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
  }

  .meter {
    grid-template-columns: 60px 1fr 30px;
    font-size: 0.82rem;
    gap: 6px;
  }

  .actions-open-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #23383a;
  }

  .actions-container {
    display: none;
  }

  body.actions-open .actions-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 32, 0.5);
    z-index: 99;
    animation: fadeIn 180ms ease;
  }

  body.actions-open .actions-container {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    overflow-y: auto;
    padding: 14px 16px 24px;
    background: #fffdf5;
    border-top: 3px solid #23383a;
    border-radius: 18px 18px 0 0;
    z-index: 100;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
    animation: slideUp 220ms ease;
  }

  body.actions-open .actions-overlay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  body.actions-open .actions-overlay-head .icon-button,
  body.info-open .info-overlay-head .icon-button {
    position: static;
    top: auto;
    right: auto;
  }

  .actions-overlay-head h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  body.actions-open .actions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 0;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand-panel h1 {
    font-size: 2.35rem;
  }

  .identity-main h1 {
    font-size: 1.2rem;
  }

  #turtleCanvas {
    width: auto;
    max-width: 100%;
    max-height: 26vh;
  }

  .upturtle-credit span {
    display: none;
  }

  .app-shell {
    width: min(100vw - 18px, 1160px);
    padding-top: 10px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .ap-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .ap-panel button {
    width: 100%;
  }

  .meter {
    grid-template-columns: 78px 1fr 36px;
    font-size: 0.9rem;
  }
}
