:root {
  --paper: #f4ead5;
  --card: #fff8e8;
  --ink: #2b2233;
  --muted: #7b6f66;
  --accent: #e76f51;
  --good: #5aa469;
  --warn: #d62839;
  --line: 3px solid var(--ink);
  --drop: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', sans-serif;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.device {
  max-width: 420px;
  min-height: 100%;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name {
  margin: 0;
  font-size: 22px;
  padding: 4px 0;
}

.tag {
  font-size: 12px;
  padding: 3px 8px;
  background: var(--ink);
  color: var(--paper);
}

.age {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.screen {
  border: var(--line);
  box-shadow: var(--drop);
  background: var(--ink);
  line-height: 0;
}

#scene {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.say {
  margin: 4px 0 0;
  min-height: 44px;
  padding: 10px 12px;
  border: var(--line);
  background: var(--card);
  font-size: 15px;
  line-height: 1.4;
  text-wrap: pretty;
}

.stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.stats li {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar {
  height: 14px;
  border: 2px solid var(--ink);
  background: var(--card);
}

.fill {
  display: block;
  height: 100%;
  background: var(--good);
  transition: width 0.3s steps(6);
}

.stats li.low .fill { background: var(--warn); }
.stats li.low .stat-label { color: var(--warn); }

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.actions.single { grid-template-columns: 1fr; }

[hidden] { display: none !important; }

.actions button,
.debug button {
  font: inherit;
  font-size: 16px;
  min-height: 52px;
  color: var(--ink);
  background: var(--card);
  border: var(--line);
  box-shadow: var(--drop);
  cursor: pointer;
  touch-action: manipulation;
}

.actions button:active,
.debug button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.actions button:focus-visible,
.name:focus-visible,
.plain:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.actions button.urgent {
  background: var(--warn);
  color: #fff;
}

.debug {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.debug button {
  font-size: 13px;
  min-height: 40px;
  background: var(--paper);
}

.sheet {
  width: min(360px, calc(100% - 32px));
  padding: 16px;
  border: var(--line);
  box-shadow: var(--drop);
  background: var(--paper);
  color: var(--ink);
}

.sheet::backdrop { background: rgba(43, 34, 51, 0.55); }

.sheet p {
  margin: 0 0 12px;
  min-height: 42px;
  font-size: 15px;
  line-height: 1.4;
}

.plain {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.sheet label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.sheet input {
  font: inherit;
  font-size: 16px;
  padding: 10px;
  color: var(--ink);
  background: var(--card);
  border: var(--line);
  border-radius: 0;
  user-select: text;
  -webkit-user-select: text;
}

.sheet input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sheet .hint {
  min-height: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.sheet .error {
  min-height: 20px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--warn);
}
