:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101914;
  color: #eef4ed;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #19251e;
  --surface-raised: #202f26;
  --line: #33473a;
  --muted: #a4b5a7;
  --accent: #b4e68e;
  --accent-dark: #23351f;
  --danger: #e48d82;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1d3024 0, #101914 52rem);
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted, .control-hint { color: var(--muted); }

.topbar {
  height: 68px;
  padding: 0 max(20px, calc((100vw - 1100px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #26362b;
  background: #111a15cc;
}

.brand {
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.04em;
  text-decoration: none;
}
.brand span { color: #f0f3ed; font-weight: 500; }
.account-bar { display: flex; align-items: center; gap: 14px; }

main {
  width: min(1100px, calc(100% - 32px));
  margin: 44px auto 80px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.7rem, 5vw, 2.4rem); letter-spacing: -.04em; }
h2 { margin-bottom: 5px; font-size: 1.15rem; }
.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.auth-card {
  width: min(440px, 100%);
  margin: 8vh auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 80px #0005;
}

.form { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #dce5dc; font-size: .9rem; }
input:not([type="file"]) {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  background: #101914;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}
.button-primary { color: #13200f; background: var(--accent); }
.button-secondary { color: #eef4ed; background: var(--surface-raised); border-color: var(--line); }
.button-danger { color: #ffe9e6; background: #542a27; border-color: #78413a; }
.button-quiet { min-height: 34px; padding: 6px 10px; color: #d9e2d9; background: transparent; border-color: var(--line); }
.button:hover { filter: brightness(1.08); }

.page-heading, .play-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-heading .muted { margin-bottom: 5px; }

.panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.panel p { margin-bottom: 0; }
.upload-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.upload-form input[type="file"] { max-width: 100%; color: var(--muted); }
.invite-result { flex-basis: 100%; overflow-wrap: anywhere; }
.invite-result a { color: var(--accent); }
.user-list-wrap { flex-basis: 100%; padding-top: 12px; border-top: 1px solid var(--line); }
.user-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.user-list li { padding: 6px 10px; border: 1px solid var(--line); border-radius: 20px; color: #dce5dc; font-size: .82rem; }

.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 14px; margin-top: 24px; }
.game-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.game-name { margin: 0; overflow-wrap: anywhere; font-weight: 700; }
.game-meta { margin: 5px 0 0; color: var(--muted); font-size: .8rem; }
.game-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.game-actions a { display: inline-flex; align-items: center; color: var(--accent); font-size: .88rem; }
.delete-button {
  padding: 0;
  border: 0;
  color: var(--danger);
  background: transparent;
  font-size: .88rem;
}
.empty-state { margin: 32px 0; color: var(--muted); text-align: center; }

.play-panel {
  margin-top: 36px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.play-heading { align-items: center; }
.play-heading h2 { margin: 0; }
.screen-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 720px);
  margin: auto;
  overflow: hidden;
  border: 1px solid #435547;
  border-radius: 8px;
  background: #080d0a;
  aspect-ratio: 3 / 2;
}
#emulator-screen { width: 100%; height: 100%; }
.control-hint { margin: 12px 0 0; font-size: .8rem; text-align: center; }
.message { min-height: 1.2em; margin: 12px 0 0; color: var(--danger); font-size: .9rem; }
footer { padding: 20px; color: #829286; font-size: .78rem; text-align: center; }

@media (max-width: 620px) {
  main { margin-top: 28px; }
  .page-heading, .play-heading { align-items: flex-start; flex-direction: column; }
  .play-heading { flex-direction: row; align-items: center; }
  .play-panel { padding: 14px 10px; }
  .play-heading .button { max-width: 150px; font-size: .8rem; }
  .auth-card { padding: 24px; }
}
