/* Night-sky styling shared by every page. Colors come from the iOS app's
   Deep Space theme and its Night palette. */
:root {
  --bg-top: #0d0f29;
  --bg-bottom: #000000;
  --tile: #17143b;
  --wall: #2e2961;
  --wall-edge: #4a458f;
  --amber: #f2b866;
  --ivory: #f5edd6;
  --rose: #ff8f8f;
  --ink: #0a0d21;
  --text: #e9e6f5;
  --muted: rgba(233, 230, 245, 0.62);
  --line: rgba(255, 255, 255, 0.1);
  --card: #121430;
  --card-hover: #1a1d3f;
  --radius: 16px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%) fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  /* a faint starfield */
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 9%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 83% 36%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 31% 61%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 54% 78%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 91% 84%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 7% 88%, rgba(255,255,255,.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 33%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 44%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 76% 58%, rgba(242,184,102,.8) 50%, transparent 51%);
}
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; margin: 0 0 .35em; }
h1 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); color: var(--ivory); }
h2 { font-size: 1.3rem; color: var(--ivory); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* header */
.top {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 18px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.brand { font-family: var(--font-display); font-size: 1.25rem; color: var(--ivory); display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 26px; height: 26px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.nav a { padding: 7px 12px; border-radius: 999px; color: var(--text); border: 1px solid transparent; }
.nav a:hover { background: var(--card); text-decoration: none; }
.nav a[aria-current="page"] { border-color: var(--line); background: var(--card); color: var(--amber); }

/* controls */
button, .btn, input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px;
}
button, .btn { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: background .15s, transform .08s; }
button:hover, .btn:hover { background: var(--card-hover); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary, .btn.primary { background: var(--amber); color: var(--ink); border-color: transparent; font-weight: 600; }
button.primary:hover { background: #f7c882; }
button.danger { color: var(--rose); }
input, select, textarea { width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
textarea.xsb { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; min-height: 180px; line-height: 1.25; letter-spacing: .08em; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 160px; }
.row > .fixed { flex: 0 0 auto; width: auto; }
.notice { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); margin: 12px 0; }
.notice.ok { border-color: rgba(242,184,102,.5); }
.notice.bad { border-color: rgba(255,143,143,.6); color: #ffd2d2; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); color: var(--muted); }
.pill.easy { color: #a8e6c3; } .pill.medium { color: var(--amber); } .pill.hard { color: #f7a1a1; } .pill.expert { color: #d9b3ff; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; color: var(--text); transition: background .15s, border-color .15s;
}
.card:hover { background: var(--card-hover); border-color: rgba(242,184,102,.4); text-decoration: none; }
.card canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 10px; background: rgba(0,0,0,.25); }
.card .title { font-weight: 600; margin: 10px 0 2px; color: var(--ivory); }
.card .meta { font-size: .82rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

/* play page */
.play { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 860px) { .play { grid-template-columns: minmax(0, 1fr) 280px; } }
.board-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 78vh; border-radius: var(--radius); background: rgba(0,0,0,.25); border: 1px solid var(--line); overflow: hidden; touch-action: none; user-select: none; }
.board-wrap canvas { width: 100%; height: 100%; display: block; }
.hud { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.hud .stat { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.hud .stat b { color: var(--ivory); font-size: 1.3rem; font-family: var(--font-display); }
.side h2 { font-size: 1.1rem; }
.side .box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
kbd { font: .8rem ui-monospace, Menlo, monospace; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: rgba(0,0,0,.3); }
.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  background: rgba(10,13,33,.78); backdrop-filter: blur(4px); padding: 20px;
}
.overlay.show { display: flex; }
.overlay .panel { max-width: 360px; }
.overlay h2 { font-size: 1.8rem; }
.moons { font-size: 1.6rem; letter-spacing: .1em; color: var(--amber); margin: 6px 0 12px; }
.moons .dim { color: rgba(255,255,255,.2); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; opacity: 0; transition: opacity .2s; pointer-events: none; backdrop-filter: blur(6px); }
.toast.show { opacity: 1; }

/* skin upload */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile-slot { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.tile-slot img { width: 64px; height: 64px; image-rendering: auto; display: block; margin: 6px auto; background: rgba(0,0,0,.3); border-radius: 8px; }
.tile-slot input[type=file] { font-size: .75rem; padding: 4px; }
.preview { width: 100%; max-width: 420px; aspect-ratio: 7 / 5; display: block; border-radius: 12px; background: rgba(0,0,0,.3); }

/* App Store card */
.app-card { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 44px; padding: 18px 20px; border-radius: var(--radius); background: var(--card); border: 1px solid rgba(242,184,102,.35); }
.app-card .app-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--bg-top); display: grid; place-items: center; flex: 0 0 auto; }
.app-card .app-icon .mark { width: 34px; height: 34px; }
.app-card > div:nth-child(2) { flex: 1 1 260px; }
.app-card .app-title { font-family: var(--font-display); font-size: 1.15rem; color: var(--ivory); }
.app-card .btn { flex: 0 0 auto; }
.card .pills { display: flex; gap: 4px; flex: 0 0 auto; }
.pill.ios { color: var(--ivory); border-color: rgba(242,184,102,.5); }

footer { margin: 48px 0 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.sr { position: absolute; left: -9999px; }
