:root {
  color-scheme: light;
  --ink: #171923;
  --muted: #656a76;
  --paper: rgba(255, 255, 255, 0.9);
  --line: rgba(23, 25, 35, 0.12);
  --red: #ee4d5a;
  --yellow: #f5c542;
  --green: #1fae78;
  --blue: #3d7eea;
  --dark: #202638;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(61, 126, 234, 0.18), transparent 36%),
    linear-gradient(225deg, rgba(238, 77, 90, 0.14), transparent 38%),
    #f3f1e8;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  grid-template-columns: minmax(320px, 760px) minmax(280px, 340px);
  gap: 16px;
  align-items: center;
  justify-content: center;
}

.game-panel,
.side {
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

nav a,
.ghost {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--dark);
  font-weight: 850;
}

.stage {
  position: relative;
  border: 4px solid #fff;
  border-radius: 8px;
  overflow: hidden;
  background: #cfe0f6;
  box-shadow: 0 22px 54px rgba(23, 25, 35, 0.18);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 45 / 28;
  touch-action: manipulation;
}

.curtain {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(rgba(255, 255, 255, 0.12), rgba(23, 25, 35, 0.28));
}

.curtain.hidden {
  display: none;
}

.modal {
  width: min(360px, 96%);
  padding: 20px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 44px rgba(23, 25, 35, 0.18);
}

.modal h2 {
  margin-bottom: 8px;
  font-size: 2rem;
  line-height: 1;
}

.modal p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.primary,
.work-button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 10px 20px rgba(238, 77, 90, 0.24);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hud div,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 10px 26px rgba(23, 25, 35, 0.08);
}

.hud div {
  min-height: 66px;
  padding: 10px;
}

.hud span,
dt,
.tips p {
  color: var(--muted);
}

.hud span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 850;
}

.hud strong {
  font-size: 1.35rem;
  font-weight: 950;
}

.controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 8px;
}

.work-button {
  min-height: 58px;
  font-size: 1.1rem;
}

.work-button.hot {
  animation: pulse 420ms ease infinite alternate;
}

.work-button.safe {
  background: var(--green);
  box-shadow: 0 10px 20px rgba(31, 174, 120, 0.22);
}

.side {
  align-content: center;
}

.card {
  padding: 14px;
}

.status-card p {
  min-height: 52px;
  margin-bottom: 12px;
  color: var(--dark);
  font-weight: 800;
  line-height: 1.45;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(23, 25, 35, 0.12);
}

.meter div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  transition: width 100ms linear;
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

dl div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(23, 25, 35, 0.05);
}

dt {
  font-size: 0.72rem;
  font-weight: 850;
}

dd {
  margin: 4px 0 0;
  font-size: 1.18rem;
  font-weight: 950;
}

.tips p {
  margin-bottom: 0;
  line-height: 1.55;
}

@keyframes pulse {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-2px);
  }
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 16px, 560px);
    grid-template-columns: 1fr;
    align-items: start;
    padding: max(8px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  }

  .side {
    align-content: start;
  }
}

@media (max-width: 460px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .hud div {
    min-height: 58px;
    padding: 8px;
  }

  .hud strong {
    font-size: 1.15rem;
  }

  .controls {
    grid-template-columns: 1fr 74px 74px;
  }

  .work-button {
    min-height: 54px;
    font-size: 0.98rem;
  }

  .ghost {
    padding: 8px 6px;
    font-size: 0.86rem;
  }
}
