/* Paper-and-pencil UI theme */
:root {
  --paper: #f6f2e8;
  --paper-2: #efe9db;
  --ink: #34343d;
  --ink-soft: rgba(52, 52, 61, .65);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", "Chalkboard SE", cursive, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- hand-drawn bits ---------- */
.wobbly, .charCard, button, .fileBtn, .panel, #hint, #banner, #battleBar, #hpWrap {
  border: 2px solid var(--ink);
  border-radius: 14px 10px 15px 9px / 9px 15px 10px 14px;
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255,255,255,.55), rgba(0,0,0,0) 70%),
    var(--paper);
  overflow-y: auto;
  z-index: 10;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 8vw, 72px);
  letter-spacing: 2px;
  transform: rotate(-2deg);
}
.sub { margin: -6px 0 8px; color: var(--ink-soft); transform: rotate(-1deg); }
.tip { color: var(--ink-soft); text-align: center; font-size: 14px; margin: 4px 0 10px; }

.charCard {
  background: var(--paper-2);
  box-shadow: 4px 5px 0 rgba(52,52,61,.18);
  padding: 12px 12px 6px;
  text-align: center;
  transform: rotate(-.6deg);
  width: 248px;
}
@media (max-height: 760px) { .charCard { width: 188px; } }
.charCard canvas { width: 220px; height: 440px; display: block; background: #fffdf5;
  border: 1.5px dashed rgba(52,52,61,.3); border-radius: 10px; }
@media (max-height: 760px) { .charCard canvas { width: 160px; height: 320px; } }
.charCard .desc { font-size: 14px; color: var(--ink-soft); min-height: 22px; padding: 4px 0; }

/* ---------- buttons ---------- */
button {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper-2);
  padding: 8px 18px;
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(52,52,61,.2);
  pointer-events: auto;
}
button:hover:not(:disabled) { background: #fffdf5; }
button:active:not(:disabled) { transform: translate(1px, 2px); box-shadow: none; }
button:disabled { opacity: .4; cursor: default; }
button.big { font-size: 20px; padding: 10px 28px; }
button.ghost { border-style: dashed; box-shadow: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

#version {
  position: fixed;
  right: 14px; bottom: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  transform: rotate(-1.5deg);
  border-bottom: 1.5px dashed rgba(52,52,61,.35);
  padding: 0 2px 1px;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#hpWrap {
  position: absolute;
  top: 12px; left: 12px;
  width: 190px; height: 26px;
  background: rgba(246,242,232,.9);
  overflow: hidden;
}
#hpBar {
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(-45deg,
    rgba(52,52,61,.35) 0 5px, rgba(52,52,61,.18) 5px 10px);
  transition: width .3s ease;
}
#hpText {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

#hint {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%) rotate(-.5deg);
  background: rgba(246,242,232,.92);
  padding: 6px 14px;
  font-size: 14px;
  max-width: 70vw;
  text-align: center;
  transition: opacity 1.2s ease;
}

#prompt {
  position: absolute;
  bottom: 108px; left: 50%;
  transform: translateX(-50%);
}
#sideBtns {
  position: absolute;
  right: 14px; bottom: 16px;
  display: flex; gap: 10px;
}
#sideBtns button { font-size: 24px; padding: 10px 14px; }

#battleBar {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(246,242,232,.95);
  padding: 8px 16px;
  display: flex; gap: 16px; align-items: center;
  font-size: 15px;
}
#battleBar .pips { letter-spacing: 2px; }
#turnLabel { font-weight: 600; min-width: 90px; }
#turnLabel.enemy { color: #8c2f2f; }

#floats { position: absolute; inset: 0; overflow: hidden; }
.float {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  animation: floatUp 1.1s ease-out forwards;
  text-shadow: 0 0 4px rgba(246,242,232,.9);
}
.float.bleed { color: #8c2f2f; font-size: 15px; }
.float.heal { color: #3d6b3d; }
@keyframes floatUp {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -46px; }
}

#banner {
  position: absolute;
  top: 38%; left: 50%;
  transform: translate(-50%, -50%) rotate(-2deg);
  background: rgba(255,253,245,.96);
  border-width: 3px;
  padding: 18px 36px;
  font-size: clamp(20px, 4vw, 32px);
  text-align: center;
  box-shadow: 5px 6px 0 rgba(52,52,61,.25);
}

/* ---------- character panel ---------- */
.panel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-.4deg);
  background: rgba(246,242,232,.98);
  padding: 16px 20px;
  z-index: 20;
  width: min(420px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 6px 7px 0 rgba(52,52,61,.22);
}
.panel h3 { margin: 6px 0; border-bottom: 1.5px dashed rgba(52,52,61,.3); }
.panel #menuPortrait { width: 90px; height: 180px; float: right; background: #fffdf5;
  border: 1.5px dashed rgba(52,52,61,.3); border-radius: 10px; }
#stats { font-size: 15px; line-height: 1.6; min-height: 90px; }
.invList { min-height: 40px; }
.invItem {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px dashed rgba(52,52,61,.2);
  font-size: 14px;
}
.invItem .iname { font-weight: 600; }
.invItem .idesc { color: var(--ink-soft); font-size: 12.5px; flex: 1; }
.invItem button { font-size: 13px; padding: 3px 10px; }
.emptyInv { color: var(--ink-soft); font-size: 14px; padding: 8px 2px; }
