:root {
  --paper: #f3ead7;
  --paper-2: #e9dcc0;
  --ink: #3b3029;
  --ink-soft: #6d5f52;
  --accent: #d6493a;
  --ice: #4f86a8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--paper);
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  color: var(--ink);
  user-select: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }

button {
  font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;  /* hand-drawn look */
  padding: 4px 12px; font-size: 20px; line-height: 1;
  transition: transform .08s, background .15s;
}
button:hover { background: #fff8e8; transform: rotate(-1deg) scale(1.04); }
button:active { transform: scale(.96); }
button:disabled { opacity: .4; cursor: default; transform: none; }

#hud {
  position: fixed; top: 10px; left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-left, .hud-stats, .hud-right {
  background: rgba(243, 234, 215, .88);
  border: 2px solid var(--ink);
  border-radius: 15px 225px 15px 255px / 255px 15px 225px 15px;
  padding: 6px 14px; font-size: 22px;
}
.hud-stats { display: flex; gap: 22px; }
.hud-stats b { font-weight: normal; color: var(--accent); }
.hud-right { display: flex; gap: 6px; padding: 4px 8px; }
.hud-right button { padding: 2px 10px; font-size: 18px; }

#bar {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 18px; align-items: stretch;
  background: rgba(243, 234, 215, .92);
  border: 2px solid var(--ink);
  border-radius: 20px 240px 20px 220px / 220px 20px 240px 20px;
  padding: 8px 16px;
}
#bar .group { display: flex; gap: 8px; align-items: center; }
.rate { display: flex; flex-direction: column; align-items: center; font-size: 15px; min-width: 52px; }
.rate b { font-size: 22px; font-weight: normal; }
button.small { padding: 2px 9px; }
button.ctrl { width: 52px; height: 52px; padding: 0; font-size: 18px; }
button.ctrl.on { background: #ffe3a6; }

.skill {
  position: relative; width: 64px; height: 76px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.skill canvas { width: 54px; height: 54px; pointer-events: none; }
.skill .count {
  position: absolute; top: -10px; right: -8px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 50%;
  width: 28px; height: 28px; font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.skill .key { position: absolute; top: 2px; left: 6px; font-size: 13px; color: var(--ink-soft); }
.skill .name { font-size: 14px; margin-bottom: 2px; }
.skill.selected { background: #ffe3a6; transform: rotate(-2deg) scale(1.06); box-shadow: 0 0 0 3px var(--accent); }

#tip {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 250, 236, .95); border: 2px dashed var(--ink-soft);
  border-radius: 10px; padding: 8px 18px; font-size: 21px; max-width: 70vw; text-align: center;
  pointer-events: none;
}

.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(243, 234, 215, .35);
}
#screenTitle { background: url("assets/title.jpg") center / cover no-repeat; }
.title-card {
  background: rgba(243, 234, 215, .93);
  border: 3px solid var(--ink);
  border-radius: 30px 300px 30px 280px / 280px 30px 300px 30px;
  padding: 28px 48px; text-align: center; min-width: 420px;
}
.title-card h1 { font-size: 84px; margin: 0; font-weight: normal; letter-spacing: 2px; }
.title-card h2 { font-size: 52px; margin: 0 0 6px; font-weight: normal; }
.title-card .sub { font-size: 26px; margin: 0 0 18px; color: var(--ink-soft); }
.title-card .help { font-size: 18px; color: var(--ink-soft); margin-top: 18px; }
.title-card p { font-size: 24px; }
#levelList { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
#levelList button { min-width: 260px; font-size: 23px; padding: 7px 16px; text-align: left; }
.row { display: flex; gap: 12px; justify-content: center; }
