:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #fff8df;
  --panel: rgba(24, 23, 18, 0.86);
  --line: rgba(255, 248, 223, 0.16);
  --gold: #f5c451;
  --green: #86c66e;
  --danger: #ef766f;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #171810;
}

body { user-select: none; }

button, kbd { font: inherit; }

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #b9d58b;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  outline: none;
}

#hud {
  position: absolute;
  inset: 18px 18px auto 18px;
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(190px, .9fr) minmax(180px, .78fr) minmax(245px, 1.15fr);
  gap: 10px;
  pointer-events: none;
}

#hud > div {
  min-height: 68px;
  padding: 12px 15px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 7px 28px rgba(0,0,0,.22);
  backdrop-filter: blur(9px);
}

.brand-card { display: flex; align-items: center; gap: 11px; }
.brand-mark { font-size: 32px; filter: drop-shadow(0 3px 4px #0006); }
.brand-card strong { display: block; font-size: 17px; letter-spacing: .08em; }
.brand-card small { display: block; margin-top: 4px; color: #ddd2b1; }

.day-card { display: flex; flex-direction: column; justify-content: center; }
.day-line { display: flex; align-items: center; justify-content: space-between; }
.day-line span { color: #ddd2b1; }
.day-line strong { font-size: 23px; font-variant-numeric: tabular-nums; }
.time-track, .durability {
  overflow: hidden;
  height: 6px;
  margin-top: 8px;
  background: rgba(255,255,255,.1);
  border-radius: 99px;
}
.time-track i, .durability i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ef8454, var(--gold));
  border-radius: inherit;
  transition: width .2s ease;
}

.score-card { display: flex; align-items: center; justify-content: space-around; gap: 10px; }
.score-card span { color: #ddd2b1; text-align: center; }
.score-card strong { display: block; margin-top: 2px; color: #fff; font-size: 23px; }

.tools-card { display: grid; gap: 7px; padding-top: 8px !important; padding-bottom: 8px !important; }
.tool-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 12px; font-size: 13px; }
.tool-row strong { color: #fff1bb; font-variant-numeric: tabular-nums; }
.tool-row .durability { grid-column: 1 / -1; height: 4px; margin-top: 0; }
.tool-row .durability i { background: linear-gradient(90deg, #6aae66, #c4dd75); }
.tool-row.empty { opacity: .58; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  min-width: 310px;
  padding: 11px 18px;
  color: #fff9e9;
  text-align: center;
  background: rgba(23, 20, 16, .88);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  box-shadow: 0 8px 30px #0005;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.prompt kbd {
  display: inline-block;
  margin: 0 4px;
  padding: 2px 7px;
  color: #34250d;
  font-weight: 800;
  background: var(--gold);
  border-radius: 5px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.22);
}

.toast {
  position: absolute;
  top: 108px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 9px 18px;
  color: #33240c;
  font-weight: 800;
  background: #fff1b7;
  border-radius: 99px;
  box-shadow: 0 8px 28px #0004;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { visibility: hidden; }

#sound-button {
  position: absolute;
  right: 18px;
  bottom: 20px;
  width: 43px;
  height: 43px;
  padding: 0;
  color: white;
  font-size: 18px;
  background: rgba(22,21,17,.82);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 7px 22px #0004;
}
#sound-button:hover { transform: translateY(-1px); background: rgba(42,39,29,.94); }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,216,132,.16), transparent 34%),
    rgba(11, 13, 9, .82);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s;
}
.overlay.visible { opacity: 1; visibility: visible; }

.start-panel {
  width: min(670px, 90vw);
  padding: 36px 42px 31px;
  color: var(--ink);
  text-align: center;
  background: linear-gradient(155deg, rgba(51,49,34,.98), rgba(25,24,18,.98));
  border: 1px solid rgba(255,240,185,.22);
  border-radius: 24px;
  box-shadow: 0 26px 90px #0009, inset 0 1px rgba(255,255,255,.08);
}
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 13px; letter-spacing: .22em; }
.start-panel h1 { margin: 0; font-size: clamp(34px, 5vw, 57px); letter-spacing: .08em; text-shadow: 0 4px 15px #0007; }
.intro { max-width: 520px; margin: 13px auto 22px; color: #ded5bb; line-height: 1.75; }
.control-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 0 0 23px; }
.control-grid div { min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 9px 5px; background: #fff1; border: 1px solid #fff1; border-radius: 12px; }
.control-grid kbd { padding: 4px 7px; color: #3c2a0a; font-size: 12px; font-weight: 800; background: #f4ca65; border-radius: 5px; box-shadow: inset 0 -2px #0003; }
.control-grid span { color: #ddd3ba; font-size: 12px; }
#start-button {
  padding: 13px 28px;
  color: #392708;
  font-weight: 900;
  letter-spacing: .08em;
  background: linear-gradient(#ffd978, #e8ad39);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 7px 22px #0006, inset 0 1px #fff9;
}
#start-button:hover { transform: translateY(-2px); filter: brightness(1.06); }
.small-note { margin: 15px 0 0; color: #a9a089; font-size: 12px; }
#sleep-transition {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 42px;
  letter-spacing: .3em;
  background: #090c19;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .65s ease;
}
#sleep-transition.active { opacity: 1; visibility: visible; }

@media (max-width: 1000px) {
  #hud { grid-template-columns: 1fr 1fr 1fr; }
  .brand-card { display: none !important; }
  .control-grid { grid-template-columns: repeat(3, 1fr); }
}
