@font-face {
  font-family: 'Pixelify Sans';
  src: url('./assets/fonts/pixelify-sans-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #1d2a17;
  --wood: #6e4429;
  --wood-dark: #46291a;
  --wood-edge: #f2894a;
  --text: #fbefd8;
  --muted: #e0c39a;
  --accent: #ef6a32;
  --ink: #2a1a10;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font-family: 'Pixelify Sans', ui-monospace, monospace;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
[hidden] { display: none !important; }

/* ---------- Scene ---------- */

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
#view { position: relative; }
#scene { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; cursor: pointer; }
#labels { position: absolute; inset: 0; pointer-events: none; }
/* Player names, drawn at screen resolution over the pixel art (drawNames in src/main.js). */
#names { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.label {
  position: absolute; transform: translate(-50%, -100%);
  padding: 3px 9px 4px; white-space: nowrap; font-size: 15px;
  background: var(--wood-dark); color: var(--text);
  border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--wood-edge), 2px 2px 0 rgba(0,0,0,0.35);
  animation: bob 1.6s ease-in-out infinite;
}
.label::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}
@keyframes bob { 50% { margin-top: -4px; } }

/* ---------- Wood UI (Ninja Adventure "Theme Wood") ---------- */

.panel {
  border: 12px solid transparent;
  border-image: url('./assets/ui/panel.png') 6 / 12px;
  background: var(--wood) padding-box;
  image-rendering: pixelated;
  padding: 4px 8px 6px;
}
.wood-btn {
  font: inherit; font-size: 16px; color: var(--text);
  background: none; padding: 4px 14px 6px; cursor: pointer;
  border: 8px solid transparent;
  border-image: url('./assets/ui/button.png') 3 fill / 6px;
  image-rendering: pixelated;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.45);
}
.wood-btn:hover:not(:disabled) { border-image-source: url('./assets/ui/button_hover.png'); }
.wood-btn:active:not(:disabled) { border-image-source: url('./assets/ui/button_pressed.png'); transform: translateY(1px); }
.wood-btn:disabled { opacity: 0.6; cursor: default; }
.wood-btn.small { font-size: 13px; padding: 2px 10px 4px; }
.wood-btn.big { font-size: 20px; padding: 6px 26px 8px; }

/* ---------- HUD ---------- */

#top {
  position: fixed; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 12px; pointer-events: none;
}
#top > * { pointer-events: auto; }
.plate {
  background: var(--wood-dark); border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--wood-edge), 3px 3px 0 rgba(0,0,0,0.35);
  padding: 6px 14px 8px;
}
.plate-title { font-size: 22px; letter-spacing: 1px; }
.plate-sub { font-size: 13px; color: var(--muted); }

#games {
  position: fixed; left: 12px; bottom: 12px; width: 230px;
}
.panel-head { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
#game-list { display: flex; flex-direction: column; gap: 6px; }
#game-list .wood-btn { width: 100%; text-align: left; }
.game-sub { display: block; font-size: 12px; color: var(--muted); }

#hint {
  position: fixed; right: 12px; bottom: 14px; max-width: 46%;
  font-size: 13px; color: var(--text); text-align: right;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  transition: opacity 0.6s;
}

/* ---------- Overlays ---------- */

.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 8, 0.55); padding: 16px;
}
.card { width: min(380px, 100%); text-align: center; animation: pop 0.15s ease-out; }
.card-title { font-size: 26px; margin-top: 4px; }
.card-tag { font-size: 13px; color: var(--muted); }
.card p { font-size: 15px; line-height: 1.35; margin: 10px 4px 14px; }
.card-actions { display: flex; gap: 10px; justify-content: center; }
.start p { margin-bottom: 12px; }

/* Fight mode picker: the village player card and the fight page's start screen. */
.mode-row { display: flex; gap: 6px; justify-content: center; margin: 0 0 12px; }
.mode-row button { flex: 1; max-width: 110px; padding: 6px 4px; font: inherit; font-size: 14px; color: var(--muted); background: var(--ink); border: 1px solid #000; cursor: pointer; }
.mode-row button.on { color: #fff; background: var(--accent); }
.mode-row button:disabled { opacity: 0.4; cursor: default; }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } }

#load { height: 8px; margin: 0 20px 14px; background: var(--ink); border: 1px solid #000; }
#load-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

@media (max-width: 560px) {
  #games { left: 8px; right: 8px; bottom: 8px; width: auto; }
  #hint { left: 8px; right: 8px; bottom: auto; top: 76px; max-width: none; text-align: center; }
  .plate-title { font-size: 18px; }
}

/* Inside Discord a game opens in this frame over the village (see openGame in src/main.js). */
#game-frame { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; background: #000; z-index: 50; }

/* Challenge banners and short messages, near the top so they do not cover the player (src/main.js, Challenges). */
.banner {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%);
  width: min(340px, calc(100% - 24px)); text-align: center; font-size: 15px; z-index: 20;
  animation: pop 0.15s ease-out;
}
.banner .timer { height: 6px; margin: 6px 4px 8px; background: var(--ink); }
.banner .timer > div { height: 100%; width: 100%; background: var(--accent); }
#toast { top: auto; bottom: 16px; z-index: 21; }

/* Trade form on a player's card (src/main.js, Trades). */
.trade-fields { display: flex; gap: 10px; justify-content: center; margin: 12px 0 6px; }
.trade-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.trade-fields input {
  width: 130px; font: inherit; font-size: 16px; text-align: center; color: var(--text);
  background: var(--wood-dark); border: 2px solid var(--ink); padding: 4px; user-select: text;
}
.card p.trade-note { font-size: 12px; color: var(--muted); margin: 6px 4px 12px; }

/* The fights you can watch, on the Draft Fight card */
#live-duels { margin: 0 0 12px; text-align: left; }
.live-head { font-size: 12px; opacity: 0.75; margin-bottom: 6px; }
.live-row { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.live-names { grid-column: 1; font-size: 14px; }
.live-sub { grid-column: 1; font-size: 11px; opacity: 0.7; }
.live-row button { grid-column: 2; grid-row: 1 / span 2; }
