:root {
  color-scheme: light;
  --bg: #f6efe3;
  --panel: rgba(26, 31, 43, 0.74);
  --panel-border: rgba(255, 242, 216, 0.22);
  --text: #fff8ed;
  --accent: #ffdd95;
  --accent-strong: #ffba62;
  --ghost: rgba(255, 248, 237, 0.16);
  --shadow: rgba(40, 19, 10, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 236, 199, 0.7), transparent 36%),
    linear-gradient(180deg, #fbf6ef 0%, #efe2cf 100%);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
  display: grid;
  place-items: center;
  padding: 18px;
}

.app-shell {
  position: relative;
  width: min(100vw - 36px, 1280px);
  aspect-ratio: 16 / 9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  box-shadow:
    0 28px 56px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  background: #e8dcca;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 18px 18px auto 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.hud__left,
.hud__right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
}

.hud__left {
  pointer-events: none;
}

.hud__right {
  pointer-events: auto;
}

.hud__chapter,
.hud__task,
.hud__sand {
  margin: 0;
}

.hud__chapter {
  font-size: 20px;
  font-weight: 700;
}

.hud__task,
.hud__sand {
  font-size: 14px;
  line-height: 1.45;
  max-width: 28rem;
}

.hud__right {
  align-items: flex-end;
}

.hud__button {
  min-width: 124px;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  color: #372318;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 10px 18px rgba(114, 57, 16, 0.18);
  cursor: pointer;
  touch-action: manipulation;
}

.hud__button--ghost {
  background: var(--ghost);
  color: var(--text);
  box-shadow: none;
}

.hud__button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
}

@media (max-width: 920px) {
  html,
  body {
    min-height: 100dvh;
  }

  body {
    display: block;
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .app-shell {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    aspect-ratio: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  canvas {
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 22px;
  }

  .hud {
    position: static;
    inset: auto;
    flex-direction: column;
    gap: 10px;
  }

  .hud__left,
  .hud__right {
    border-radius: 18px;
    padding: 12px 14px;
  }

  .hud__right {
    align-items: stretch;
  }

  .hud__chapter {
    font-size: 18px;
  }

  .hud__task,
  .hud__sand {
    max-width: none;
    font-size: 13px;
  }

  .hud__button {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 560px) {
  body {
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .app-shell {
    gap: 10px;
  }

  canvas {
    border-radius: 18px;
  }

  .hud__left,
  .hud__right {
    border-radius: 16px;
    padding: 11px 12px;
  }

  .hud__chapter {
    font-size: 17px;
  }

  .hud__task,
  .hud__sand {
    font-size: 12px;
    line-height: 1.5;
  }

  .hud__button {
    padding: 10px 16px;
    font-size: 14px;
  }
}
