:root {
  color-scheme: light;
  --paper: #fff;
  --ink: #202124;
  --muted: #747474;
  --line: #e5e5e5;
  --accent: #a9322a;
  --surface: #f6f6f6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #181818;
  --ink: #e4e4e4;
  --muted: #aaa;
  --line: #343434;
  --accent: #e2968c;
  --surface: #232323;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font:
    15px/1.6 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}
button {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active {
  filter: brightness(0.93);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
a:focus-visible,
button:focus-visible,
h1:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
h1:focus:not(:focus-visible),
canvas:focus:not(:focus-visible) {
  outline: none;
}
header {
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 10px max(18px, calc((100vw - 760px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  min-height: 65px;
}
header > span {
  color: var(--muted);
}
header button {
  padding: 6px 9px;
  font-size: 12px;
}
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 20px 0;
  min-height: 70vh;
}
.connection {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 20px;
}
.connection.ready::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #52745b;
  margin-right: 7px;
}
h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.3;
  letter-spacing: -0.5px;
}
.intro {
  color: var(--muted);
  margin: 10px 0 22px;
  font-size: 14px;
}
.game-list {
  border-top: 1px solid var(--line);
}
.game-card {
  display: grid;
  grid-template-columns: 78px 1fr 18px;
  align-items: center;
  gap: 20px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.game-card strong {
  display: block;
  font-size: 20px;
  font-weight: 650;
}
.game-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 3px 0 7px;
}
.game-card em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}
.cover {
  width: 78px;
  height: 78px;
  position: relative;
  overflow: hidden;
  border-radius: 9px;
}
.brick-cover {
  background: #efe6d7;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 10px;
  align-content: start;
}
.brick-cover i {
  height: 10px;
  border-radius: 2px;
  background: #cd805d;
}
.brick-cover i:nth-child(n + 3) {
  background: #d8ae6b;
}
.brick-cover b {
  position: absolute;
  top: 37px;
  left: 35px;
  color: #605344;
  font-size: 10px;
}
.brick-cover em {
  position: absolute;
  bottom: 10px;
  left: 23px;
  height: 5px;
  width: 33px;
  background: #605344;
  border-radius: 3px;
}
.space-cover {
  background: #172630;
  color: #97d7cb;
}
.space-cover i {
  position: absolute;
  left: 15px;
  top: 8px;
  width: 9px;
  height: 9px;
  background: #e6b782;
  transform: rotate(45deg);
}
.space-cover b {
  position: absolute;
  top: 31px;
  left: 31px;
  font-size: 27px;
}
.space-cover em {
  position: absolute;
  top: 14px;
  right: 14px;
  color: #97d7cb;
}
.run-cover {
  background: #f3dfb8;
}
.run-cover b {
  position: absolute;
  width: 15px;
  height: 20px;
  left: 19px;
  top: 27px;
  background: #4c6970;
  border-radius: 3px;
  transform: rotate(-8deg);
}
.run-cover i {
  position: absolute;
  width: 12px;
  height: 22px;
  bottom: 16px;
  right: 15px;
  background: #ac7251;
}
.run-cover em {
  position: absolute;
  height: 2px;
  bottom: 14px;
  width: 100%;
  background: #ac7251;
}
.footnote,
footer {
  color: var(--muted);
  font-size: 12px;
}
.footnote {
  margin: 24px 0;
  max-width: 460px;
}
footer {
  text-align: center;
  padding: 30px 20px max(24px, env(safe-area-inset-bottom));
}
.back {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}
.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.game-heading button {
  font-size: 13px;
}
.game-heading h1 {
  font-size: 25px;
}
#play .intro {
  margin: 6px 0 12px;
  font-size: 13px;
}
.scorebar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  max-width: 360px;
  margin: 0 auto 8px;
  font-variant-numeric: tabular-nums;
}
.stage {
  position: relative;
  width: min(100%, 360px);
  margin: 0 auto;
  border-radius: 9px;
  overflow: hidden;
  background: #172630;
  aspect-ratio: 360/460;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  background: #101d27a8;
  color: #fff;
  backdrop-filter: blur(3px);
}
.game-overlay h2 {
  margin: 0 0 8px;
  font-size: 24px;
}
.game-overlay p {
  font-size: 14px;
  color: #ffffffce;
  margin: 0 0 22px;
}
.game-overlay button {
  background: #fff;
  color: #202124;
  border: 0;
  padding: 12px 25px;
  font-weight: 600;
}
.game-overlay #restart-game {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 400;
}
.game-status {
  min-height: 24px;
  margin: 8px auto 0;
  max-width: 360px;
  font-size: 13px;
  color: var(--accent);
}
.play-note {
  margin: 4px auto 0;
  max-width: 360px;
  font-size: 11px;
}
.notice {
  background: var(--surface);
  padding: 10px 12px;
  font-size: 13px;
}
.notice button {
  padding: 2px 6px;
  color: var(--accent);
}
dialog {
  max-width: 520px;
  width: calc(100% - 36px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  color: var(--ink);
  background: var(--paper);
}
dialog::backdrop {
  background: #0006;
}
dialog h2 {
  font-size: 20px;
  margin: 0;
}
dialog h3 {
  font-size: 15px;
}
dialog p {
  font-size: 14px;
  color: var(--muted);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
@media (max-width: 760px) {
  header {
    border-top: 0;
  }
}
@media (max-width: 380px) {
  main {
    padding: 16px 14px 0;
  }
  .game-card {
    grid-template-columns: 64px 1fr 14px;
    gap: 12px;
  }
  .cover {
    width: 64px;
    height: 64px;
  }
  .game-card small {
    font-size: 12px;
  }
}

body.playing {
  overflow: hidden;
  position: fixed;
  inset: 0;
}
body.playing > header,
body.playing > footer,
body.playing .connection,
body.playing #offline-tools {
  display: none;
}
body.playing main {
  padding: 0;
  margin: 0;
  min-height: 0;
  max-width: none;
}
body.playing #play {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: var(--play-height, 100vh);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #14232d;
  color: #eef3f4;
}
body.playing .game-heading {
  flex: none;
  gap: 8px;
  padding: 2px 10px;
  min-height: 50px;
}
body.playing .game-heading h1 {
  flex: 1;
  font-size: 16px;
  text-align: center;
  white-space: nowrap;
}
body.playing .game-heading button {
  padding: 7px 10px;
  color: #eef3f4;
  background: #243643;
  border-color: #405362;
}
body.playing .back {
  margin: 0;
  padding: 10px 2px;
  min-height: 44px;
  color: #d0dce1;
}
body.playing .scorebar {
  flex: none;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 16px 6px;
  color: #a7bbc6;
  font-size: 12px;
}
body.playing .stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  border-radius: 0;
  aspect-ratio: auto;
}
body.playing .intro,
body.playing .play-note {
  display: none;
}
body.playing .game-status {
  position: absolute;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  width: max-content;
  max-width: calc(100% - 24px);
  color: #fff;
  background: #14232dc9;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  font-size: 12px;
  min-height: 0;
}
body.playing .game-status:empty {
  display: none;
}
body.playing #storage-notice {
  position: fixed;
  left: 10px;
  right: 10px;
  top: 75px;
  z-index: 5;
}
.game-overlay {
  padding: 20px;
}
.game-overlay > div {
  max-width: 340px;
}
@media (min-width: 1100px) and (min-height: 600px) {
  body.playing #play {
    max-width: 1000px;
    margin: auto;
  }
}

.offline-tools {
  margin-bottom: 18px;
}
.offline-tools .connection {
  margin-bottom: 6px;
}
.offline-tools button {
  min-height: 36px;
  padding: 4px 9px;
  font-size: 12px;
}
.offline-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
#offline-secure-link {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 13px;
}
