:root {
  color-scheme: dark;
  --bg: #07131f;
  --panel: rgba(12, 27, 43, .82);
  --panel-2: rgba(18, 42, 66, .72);
  --text: #eef7ff;
  --muted: #9fb4c8;
  --line: rgba(160, 210, 255, .17);
  --mint: #77ffc2;
  --cyan: #55d9ff;
  --violet: #9d86ff;
  --gold: #ffd36d;
  --danger: #ff6f8f;
  --shadow: 0 28px 90px rgba(0, 0, 0, .38);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(64, 221, 255, .18), transparent 34rem),
    radial-gradient(circle at 84% 4%, rgba(159, 112, 255, .18), transparent 34rem),
    linear-gradient(135deg, #07131f 0%, #0b1d2e 52%, #101329 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
.game-shell { width: min(1580px, calc(100% - 24px)); }
.game-topbar { z-index: 40; }
.game-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
  padding: 24px 0 16px;
}
.game-copy, .game-status {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(14, 32, 52, .82), rgba(7, 15, 29, .9));
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 36px);
}
.game-copy h1 { font-size: clamp(40px, 5.6vw, 78px); max-width: 1050px; }
.game-status { display: grid; align-content: center; gap: 8px; }
.game-status span, .hud span { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.game-status b { font-size: 30px; color: var(--gold); }
.game-status small { color: #cfe0ef; font-size: 16px; line-height: 1.4; }
.play-screen {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(188, 229, 255, .22);
  border-radius: 28px;
  background: #08131f;
  box-shadow: var(--shadow);
}
#keepsiaCanvas {
  display: block;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 520px;
  touch-action: none;
}
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  pointer-events: none;
}
.hud div, .interaction, .controls-help {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  background: rgba(5, 16, 28, .62);
  backdrop-filter: blur(12px);
}
.hud div { padding: 12px 14px; }
.hud b { display: block; margin-top: 4px; font-size: 20px; }
.interaction {
  position: absolute;
  left: 18px;
  bottom: 76px;
  z-index: 5;
  width: min(520px, calc(100% - 36px));
  padding: 15px 16px;
}
.interaction b { display: block; color: var(--mint); margin-bottom: 4px; }
.interaction span { color: #d8e9fa; }
.interaction.active { border-color: rgba(119,255,194,.5); box-shadow: 0 0 28px rgba(119,255,194,.15); }
.controls-help {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
}
.controls-help span {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  color: #cfe0ef;
  font-weight: 800;
  font-size: 13px;
}
.mobile-pad {
  position: absolute;
  right: 18px;
  bottom: 76px;
  z-index: 6;
  display: none;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 8px;
}
.mobile-pad button {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(7, 19, 31, .68);
  color: var(--text);
  font-weight: 950;
  touch-action: none;
}
.mobile-pad [data-pad="up"] { grid-column: 2; grid-row: 1; }
.mobile-pad [data-pad="left"] { grid-column: 1; grid-row: 2; }
.mobile-pad [data-pad="down"] { grid-column: 2; grid-row: 3; }
.mobile-pad [data-pad="right"] { grid-column: 3; grid-row: 2; }
.mobile-pad [data-pad="act"] {
  grid-column: 3;
  grid-row: 3;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  color: #06111b;
}
.memory-panel .memory-grid small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  min-height: 34px;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 54px);
  background: rgba(5, 14, 24, .74);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--mint), var(--cyan), var(--violet));
  color: #06111b;
  font-weight: 950;
  box-shadow: 0 12px 34px rgba(85, 217, 255, .24);
}
.brand b { display: block; font-size: 23px; letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .04);
  color: #dcecff;
  font-weight: 800;
  font-size: 14px;
}
.nav a:hover { background: rgba(119, 255, 194, .13); border-color: rgba(119, 255, 194, .34); }
main { width: min(1440px, calc(100% - 32px)); margin: 0 auto; }
.hero {
  min-height: calc(100vh - 78px);
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, .98fr);
  gap: 28px;
  align-items: center;
  padding: 54px 0 36px;
}
.hero-copy, .panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(14, 32, 52, .82), rgba(7, 15, 29, .84));
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.hero-copy { padding: clamp(24px, 5vw, 56px); }
.eyebrow {
  margin: 0 0 12px;
  color: var(--mint);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .18em;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(44px, 7vw, 92px); line-height: .93; margin-bottom: 22px; letter-spacing: -.04em; }
h2 { font-size: clamp(30px, 4.4vw, 56px); line-height: 1; letter-spacing: -.035em; margin-bottom: 16px; }
h3 { font-size: 23px; }
.lead { color: #cfe0ef; font-size: clamp(18px, 2.1vw, 23px); line-height: 1.55; max-width: 830px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 28px 0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 13px 18px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 16px;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  font-weight: 950;
}
.btn.primary { background: linear-gradient(135deg, var(--mint), var(--cyan)); color: #05131d; border: 0; }
.btn.ghost:hover { border-color: rgba(85, 217, 255, .42); background: rgba(85, 217, 255, .09); }
.btn.full { width: 100%; }
.signal-row { display: flex; gap: 8px; flex-wrap: wrap; }
.signal-row span {
  padding: 9px 11px;
  border-radius: 999px;
  color: #d5e7f8;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  font-weight: 800;
}
.world-stage {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border-radius: 34px;
  border: 1px solid rgba(188, 229, 255, .22);
  background: linear-gradient(180deg, #13243d, #07111f 62%, #061821);
  box-shadow: var(--shadow), inset 0 0 80px rgba(85, 217, 255, .08);
}
.sky { position: absolute; inset: 0; overflow: hidden; }
.sun, .moon {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  top: 68px;
}
.sun {
  left: 13%;
  background: #ffd36d;
  box-shadow: 0 0 60px #ffd36d;
  animation: sunArc 22s linear infinite;
}
.moon {
  right: 11%;
  background: #cfe6ff;
  box-shadow: 0 0 42px #7fb8ff;
  animation: moonGlow 8s ease-in-out infinite;
}
.star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 12px white;
  animation: twinkle 3s ease-in-out infinite;
}
.s1 { left: 18%; top: 16%; } .s2 { left: 62%; top: 12%; animation-delay: .8s; }
.s3 { left: 86%; top: 28%; animation-delay: 1.6s; } .s4 { left: 43%; top: 24%; animation-delay: 2.2s; }
.cloud {
  position: absolute;
  width: 220px;
  height: 72px;
  border-radius: 999px;
  background: rgba(205, 232, 255, .16);
  filter: blur(.2px);
  animation: drift 28s linear infinite;
}
.cloud:before, .cloud:after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.cloud:before { width: 96px; height: 96px; left: 28px; bottom: 22px; }
.cloud:after { width: 126px; height: 126px; right: 24px; bottom: 14px; }
.c1 { top: 154px; left: -15%; } .c2 { top: 228px; left: 42%; animation-duration: 36s; opacity: .7; }
.c3 { top: 94px; left: 62%; animation-duration: 44s; opacity: .5; }
.planet {
  position: absolute;
  left: 50%;
  bottom: -220px;
  translate: -50% 0;
  width: min(760px, 112vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, .16), transparent 28%),
    linear-gradient(155deg, #1a9fd1, #097b9a 36%, #0e4d66 62%, #0a263d);
  box-shadow: inset -50px -80px 120px rgba(0, 0, 0, .35), 0 0 90px rgba(85, 217, 255, .2);
  overflow: hidden;
}
.continent, .river, .city, .wind { position: absolute; display: block; }
.continent { background: linear-gradient(135deg, #56d08d, #2b8d72); border-radius: 42% 58% 36% 64%; filter: drop-shadow(0 10px 20px rgba(0,0,0,.2)); }
.continent.a { width: 210px; height: 118px; left: 94px; top: 180px; rotate: -18deg; }
.continent.b { width: 280px; height: 150px; right: 84px; top: 246px; rotate: 13deg; }
.continent.c { width: 190px; height: 130px; left: 270px; bottom: 158px; rotate: -4deg; }
.river { width: 160px; height: 10px; background: #a7efff; border-radius: 999px; box-shadow: 0 0 18px #a7efff; opacity: .85; }
.river.r1 { left: 150px; top: 234px; rotate: 24deg; } .river.r2 { right: 190px; top: 330px; rotate: -18deg; }
.city { width: 15px; height: 15px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 24px var(--gold); animation: cityPulse 2.4s ease-in-out infinite; }
.p1 { left: 230px; top: 230px; } .p2 { right: 225px; top: 310px; animation-delay: .8s; } .p3 { left: 360px; bottom: 224px; animation-delay: 1.4s; }
.wind { width: 140px; height: 2px; border-radius: 999px; background: rgba(255,255,255,.5); animation: wind 5s linear infinite; }
.w1 { left: 20%; top: 30%; } .w2 { left: 54%; top: 45%; animation-delay: 2s; }
.stage-note { position: absolute; left: 24px; right: 24px; bottom: 24px; color: #d8ebff; font-weight: 850; opacity: .8; }
.panel { padding: clamp(22px, 4vw, 42px); margin: 24px 0; }
.play-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 22px; }
.choices { display: grid; gap: 10px; margin-top: 22px; }
.choices button {
  text-align: left;
  border: 1px solid rgba(119, 255, 194, .24);
  border-radius: 16px;
  color: var(--text);
  background: rgba(119, 255, 194, .07);
  padding: 16px;
  cursor: pointer;
  font-weight: 900;
}
.choices button:hover { background: rgba(119, 255, 194, .16); }
.micro, .world-card span, .goal-list span, .feature-grid span, .timeline small { color: var(--muted); }
.world-card {
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  padding: 22px;
  background: rgba(255, 255, 255, .05);
}
label { display: grid; gap: 8px; margin: 12px 0; color: #d6e8f8; font-weight: 850; }
input, select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(0, 0, 0, .24);
  color: var(--text);
}
.invite { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 12px; border-radius: 14px; background: rgba(0,0,0,.22); }
.section-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.memory-grid, .feature-grid, .plans, .admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.memory-grid article, .feature-grid article, .plans article, .goal-list article, .timeline article, .admin-stats article {
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 20px;
  background: rgba(255, 255, 255, .055);
  padding: 18px;
}
.memory-grid b, .feature-grid b, .plans b, .goal-list b, .timeline b, .admin-stats b { display: block; margin-bottom: 8px; }
.meter { height: 9px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 14px; }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--cyan)); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.chat { display: grid; gap: 12px; }
.chat article { padding: 14px 16px; border-radius: 18px; background: rgba(85, 217, 255, .08); border: 1px solid rgba(85, 217, 255, .17); }
.chat b { color: var(--mint); }
.goal-list { display: grid; gap: 12px; }
.timeline { display: grid; grid-template-columns: repeat(7, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.timeline span { color: var(--gold); font-weight: 950; }
.plans article.hot { border-color: rgba(119, 255, 194, .5); box-shadow: 0 0 34px rgba(119, 255, 194, .12); }
.plans strong, .admin-stats strong { display: block; font-size: 34px; margin: 8px 0; color: var(--gold); }
.footer { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 32px 16px 48px; color: var(--muted); }
.admin-shell { padding-top: 24px; }
.admin-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: center; }
.admin-table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 18px; }
.admin-table th, .admin-table td { text-align: left; padding: 14px; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--mint); background: rgba(255,255,255,.05); }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(120vw); } }
@keyframes twinkle { 0%, 100% { opacity: .25; scale: .8; } 50% { opacity: 1; scale: 1.35; } }
@keyframes sunArc { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(58px); } }
@keyframes moonGlow { 0%, 100% { opacity: .7; } 50% { opacity: 1; } }
@keyframes cityPulse { 0%, 100% { scale: 1; opacity: .75; } 50% { scale: 1.35; opacity: 1; } }
@keyframes wind { from { transform: translateX(-60px); opacity: 0; } 30% { opacity: .7; } to { transform: translateX(160px); opacity: 0; } }
@media (max-width: 980px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; }
  .hero, .play-grid, .split, .admin-hero, .game-hero { grid-template-columns: 1fr; }
  .hud { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .mobile-pad { display: grid; }
  .world-stage { min-height: 520px; }
  .section-head { flex-direction: column; }
}
@media (max-width: 560px) {
  main { width: min(100% - 20px, 1440px); }
  .hero { padding-top: 24px; }
  .hero-copy, .panel { border-radius: 22px; }
  h1 { font-size: 42px; }
  h2 { font-size: 30px; }
  .brand { min-width: 0; }
  .nav a { font-size: 13px; padding: 9px 10px; }
  .world-stage { min-height: 430px; }
  .sun, .moon { width: 64px; height: 64px; }
  .planet { width: 560px; bottom: -180px; }
  .game-shell { width: min(100% - 12px, 1580px); }
  .game-copy h1 { font-size: 34px; }
  #keepsiaCanvas { height: 72vh; min-height: 500px; }
  .hud { grid-template-columns: 1fr 1fr; gap: 6px; top: 8px; left: 8px; right: 8px; }
  .hud div { padding: 9px 10px; }
  .hud b { font-size: 16px; }
  .interaction { left: 10px; right: 10px; bottom: 86px; width: auto; }
  .controls-help { left: 10px; right: 10px; bottom: 10px; }
  .mobile-pad { right: 10px; bottom: 158px; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); }
}
