/* style.css — Knight's Ascent */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #0a0608;
  color: #e8e2dc;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  color-scheme: dark;
}
:root { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="light"] body { background: #e8e2dc; color: #1a1410; }

#game { position: fixed; inset: 0; }
canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 14px;
  pointer-events: none;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
  z-index: 5;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-right { align-items: flex-end; }

.hearts { display: flex; gap: 4px; }
.heart {
  width: 18px; height: 16px;
  background:
    radial-gradient(circle at 30% 30%, #ff6a6a 0%, #d33040 60%, #8a1020 100%);
  clip-path: path('M9 15 C -2 6, 1 0, 9 4 C 17 0, 20 6, 9 15 Z');
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  opacity: 0.25;
  transition: opacity .2s, transform .2s;
}
.heart.on { opacity: 1; }

.floor-label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: #c8b896; text-shadow: 0 1px 2px #000;
  background: rgba(10,6,8,0.5); padding: 3px 8px; border-radius: 6px;
  align-self: flex-start;
}

.powers { display: flex; gap: 4px; }
.pw {
  width: 22px; height: 22px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: rgba(30,24,28,0.6); color: #6a5a4a;
  border: 1px solid rgba(255,255,255,0.05);
  transition: all .2s;
}
.pw.on {
  background: linear-gradient(180deg, #4a3a2a, #2a1f18);
  color: #ffd24a; border-color: #6a4a2a;
  box-shadow: 0 0 8px rgba(255,210,74,0.25);
}

.daggers {
  font-size: 13px; color: #dfe6f0; text-shadow: 0 1px 2px #000;
  background: rgba(10,6,8,0.5); padding: 4px 8px; border-radius: 6px;
  letter-spacing: 0.05em;
}

/* ---------- Touch controls ---------- */
#touch {
  position: absolute; inset: 0;
  display: none;
  pointer-events: none;
  z-index: 6;
}
@media (pointer: coarse), (hover: none) {
  #touch { display: block; }
}
.pad-left, .pad-right {
  position: absolute; bottom: 18px;
  display: flex; gap: 10px;
  pointer-events: none;
}
.pad-left { left: 16px; }
.pad-right { right: 16px; gap: 8px; flex-wrap: wrap; max-width: 180px; justify-content: flex-end; }

.tbtn {
  pointer-events: auto;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(40,30,28,0.55);
  border: 2px solid rgba(255,210,74,0.25);
  color: #e8d8b6;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform .08s, background .1s;
  touch-action: none;
}
.tbtn:active { transform: scale(0.92); background: rgba(80,60,40,0.7); }
.t-left::after { content: '◀'; font-size: 18px; }
.t-right::after { content: '▶'; font-size: 18px; }
.t-jump::after { content: 'JMP'; font-size: 10px; }
.t-attack::after { content: 'ATK'; font-size: 10px; }
.t-dagger::after { content: 'DAG'; font-size: 10px; }
.t-shield::after { content: 'SHD'; font-size: 10px; }
.pad-right .t-jump, .pad-right .t-attack { background: rgba(120,40,40,0.5); border-color: rgba(255,140,140,0.3); }

/* ---------- Overlay ---------- */
.overlay {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(6,4,6,0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
  padding: 20px;
}
.overlay.show { display: flex; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card {
  max-width: 460px; width: 100%;
  background: linear-gradient(180deg, #1f1812, #14100c);
  border: 1px solid #4a3a2a;
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,210,74,0.1);
  animation: rise .3s ease;
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.card h1 {
  margin: 0 0 12px;
  font-size: 26px; letter-spacing: 0.06em;
  color: #ffd8a0;
  text-shadow: 2px 2px 0 #2a1810, 0 0 18px rgba(255,160,60,0.3);
  font-weight: 800;
}
.card p {
  margin: 0 0 20px;
  font-size: 14px; line-height: 1.6;
  color: #c8b896;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  white-space: pre-wrap;
}
.card button {
  font-family: inherit;
  background: linear-gradient(180deg, #c08840, #8a5a28);
  color: #1a1008;
  border: none;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 15px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 0 #5a3a18, 0 8px 20px rgba(0,0,0,0.4);
  transition: transform .08s, box-shadow .08s;
}
.card button:active { transform: translateY(3px); box-shadow: 0 1px 0 #5a3a18; }
.card button:focus-visible { outline: 2px solid #ffd24a; outline-offset: 3px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  bottom: 90px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(20,14,10,0.92);
  border: 1px solid #6a4a2a;
  color: #ffd8a0;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 15;
  max-width: 80vw; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (pointer: coarse), (hover: none) {
  .toast { bottom: 160px; }
}

html[data-theme="light"] .card {
  background: linear-gradient(180deg, #f4ece0, #e8dcc8);
  border-color: #8a6a4a;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.5);
}
html[data-theme="light"] .card h1 { color: #5a3018; text-shadow: 2px 2px 0 #d8c8a8; }
html[data-theme="light"] .card p { color: #5a4a3a; }
html[data-theme="light"] .toast { background: rgba(248,240,228,0.95); color: #5a3018; border-color: #8a6a4a; }
html[data-theme="light"] .floor-label { background: rgba(248,240,228,0.6); color: #5a3018; }
html[data-theme="light"] .daggers { background: rgba(248,240,228,0.6); color: #3a2818; }
