/* =====================================================================
 *  DEV QUEST — STYL (grywalna gra top-down, retro / CRT)
 * ===================================================================== */

:root {
  --bg:      #0e1021;
  --panel:   #1a1d3a;
  --border:  #4d5cff;
  --accent:  #ffd23f;
  --accent2: #54f2c8;
  --text:    #e8ecff;
  --muted:   #8b92c9;
  --bar-bg:  #2a2e55;
  --pixel:   "Press Start 2P", monospace;
  --read:    system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--read);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---- scena / CRT --------------------------------------------------- */
.crt {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: radial-gradient(circle at 50% 30%, #1a1d3a 0%, #0e1021 70%);
}
.crt::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.16) 3px, rgba(0,0,0,0.16) 4px);
}

.stage {
  position: relative;
  /* największy rozmiar mieszczący się w oknie (proporcja 1440:900 = 1.6) */
  width: min(98vw, calc((100vh - 50px) * 1.6));
  width: min(98vw, calc((100dvh - 50px) * 1.6));
  border: 4px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 0 0 4px #0e1021, 0 0 50px rgba(77,92,255,0.4);
  overflow: hidden;
  background: #0e1021;
}

/* ---- HUD ----------------------------------------------------------- */
#hud {
  display: flex; justify-content: space-between; align-items: center;
  background: #0e1021; border-bottom: 3px solid var(--border);
  padding: 8px 14px; font-size: 14px; min-height: 40px; gap: 10px;
}
#hud b { color: var(--accent); }
.hud-mode { color: var(--muted); white-space: nowrap; }
.hud-mode button {
  font-family: var(--read); font-size: 13px; font-weight: 700;
  background: var(--border); color: #fff; border: none;
  border-radius: 4px; padding: 2px 8px; cursor: pointer; margin-left: 4px;
}

/* przełącznik języka na ekranach menu */
.lang-switch { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.lang-switch button {
  font-family: var(--pixel); font-size: 11px; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 2px solid var(--border); border-radius: 4px; padding: 6px 10px;
}
.lang-switch button.on { background: var(--accent); color: #0e1021; border-color: var(--accent); }
#hud:empty { display: none; }

/* ---- canvas -------------------------------------------------------- */
#world {
  display: block; width: 100%; height: auto;
}

/* ---- overlay (start / wybór) -------------------------------------- */
#overlay {
  position: absolute; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(8, 10, 25, 0.92);
  padding: 20px; text-align: center;
}
#overlay.show { display: flex; }
.ov-card { max-width: 620px; animation: pop 0.18s ease-out; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.logo {
  font-family: var(--pixel); font-size: 38px; color: var(--accent);
  letter-spacing: 2px; line-height: 1.4; margin-bottom: 16px;
  text-shadow: 3px 3px 0 #b3001b, 6px 6px 0 rgba(0,0,0,0.4);
}
.subtitle { color: var(--accent2); margin-bottom: 18px; font-size: 16px; }
.heading { font-family: var(--pixel); font-size: 16px; color: var(--accent2); margin-bottom: 16px; line-height: 1.6; }
.ov-desc { color: var(--muted); line-height: 1.55; margin-bottom: 26px; font-size: 16px; }
.ov-desc b { color: var(--text); }

/* ---- przyciski ----------------------------------------------------- */
.btn {
  font-family: var(--pixel); background: var(--border); color: #fff;
  border: none; border-radius: 4px; padding: 14px 22px; cursor: pointer;
  box-shadow: 0 4px 0 #2c36b3; transition: transform 0.08s, box-shadow 0.08s, background 0.08s;
}
.btn:hover { background: #5e6cff; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #2c36b3; }
.btn-big { font-size: 18px; padding: 16px 36px; }

/* ---- wybór klasy --------------------------------------------------- */
.choices { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.card-choice {
  flex: 1 1 230px; background: #0e1021; border: 3px solid var(--border);
  border-radius: 8px; padding: 22px 16px; cursor: pointer; color: var(--text);
  font-family: var(--read); transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
}
.card-choice:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 0 24px rgba(255,210,63,0.4); }
.card-emoji { font-size: 46px; margin-bottom: 10px; }
.card-title { font-family: var(--pixel); font-size: 12px; color: var(--accent); margin-bottom: 10px; line-height: 1.5; }
.card-desc { color: var(--muted); font-size: 14px; line-height: 1.4; }

/* ---- dialog (treść CV) -------------------------------------------- */
#dialog {
  position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 120%);
  width: min(760px, 92%); max-height: 78%; overflow-y: auto; z-index: 60;
  background: var(--panel); border: 3px solid var(--border); border-radius: 10px;
  box-shadow: 0 0 0 3px #0e1021, 0 10px 40px rgba(0,0,0,0.6);
  transition: transform 0.22s ease-out; opacity: 0; pointer-events: none;
}
#dialog.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.dlg-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--pixel); font-size: 13px; color: var(--accent);
  padding: 14px 16px; border-bottom: 2px solid var(--border); line-height: 1.5;
}
.dlg-close {
  background: #b3001b; color: #fff; border: none; border-radius: 4px;
  width: 28px; height: 28px; cursor: pointer; font-size: 16px;
}
.dlg-body { padding: 16px; line-height: 1.5; }
.dlg-foot { padding: 8px 16px 12px; color: var(--muted); font-size: 13px; text-align: right; }
.para { margin-bottom: 16px; }

/* ---- paski / staty ------------------------------------------------- */
.bar { background: var(--bar-bg); border: 2px solid #3a3f73; border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.6s ease-out; }
.stats { display: grid; gap: 6px; margin-top: 10px; }
.stat-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; }
.stat-label { color: var(--muted); font-size: 14px; }

.skill-row { display: grid; grid-template-columns: 1fr 140px 50px; align-items: center; gap: 10px; margin-bottom: 10px; }
.skill-name { font-size: 15px; }
.skill-lvl { color: var(--accent); font-size: 14px; text-align: right; }

.quest {
  background: #0e1021; border: 2px solid var(--border); border-left: 5px solid var(--accent);
  border-radius: 6px; padding: 14px 16px; margin-bottom: 12px;
}
.quest-title { font-family: var(--pixel); font-size: 12px; color: var(--accent); margin-bottom: 6px; line-height: 1.5; }
.quest-meta { color: var(--accent2); font-size: 14px; margin-bottom: 8px; }
.quest-reward { line-height: 1.5; }

.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ach { background: #0e1021; border: 2px solid var(--border); border-radius: 6px; padding: 14px; line-height: 1.4; }
.ach-icon { font-size: 22px; margin-right: 8px; }

.contact-links { display: grid; gap: 12px; }
.contact-link {
  display: block; background: #0e1021; border: 2px solid var(--border); border-radius: 6px;
  padding: 14px 16px; color: var(--text); text-decoration: none; transition: border-color 0.1s, transform 0.08s;
}
.contact-link:hover { border-color: var(--accent); transform: translateX(4px); }
.contact-link strong { color: var(--accent2); }

/* ---- sterowanie dotykowe ------------------------------------------ */
#touch {
  display: none; position: absolute; inset: auto 0 0 0; z-index: 40;
  justify-content: space-between; align-items: flex-end; padding: 18px;
  pointer-events: none;
}
#joystick {
  pointer-events: auto; position: relative;
  width: 132px; height: 132px; border-radius: 50%;
  background: rgba(77,92,255,0.18); border: 3px solid rgba(84,242,200,0.6);
  touch-action: none; user-select: none;
}
#joyknob {
  position: absolute; left: 50%; top: 50%; width: 62px; height: 62px;
  margin: -31px 0 0 -31px; border-radius: 50%;
  background: rgba(84,242,200,0.85); border: 2px solid #fff;
  transition: transform 0.04s linear; pointer-events: none;
}
.tbtn {
  pointer-events: auto; cursor: pointer; user-select: none; touch-action: none;
  background: rgba(77,92,255,0.7); color: #fff; border: 2px solid var(--accent2); border-radius: 14px;
}
.tbtn-a {
  width: 92px; height: 92px; background: rgba(255,210,63,0.9); color: #0e1021;
  font-family: var(--pixel); font-size: 22px;
}

/* pokaż sterowanie dotykowe na urządzeniach dotykowych / wąskich */
@media (pointer: coarse), (max-width: 760px) {
  #touch { display: flex; }
}
/* pewne wykrycie dotyku z JS */
body.has-touch #touch { display: flex; }

/* ---- pełny ekran na telefonie ------------------------------------- */
@media (pointer: coarse) {
  .crt { padding: 0; }
  .stage {
    width: min(100dvw, calc((100dvh - 40px) * 1.6));
    border-width: 2px; border-radius: 0;
  }
}

/* ---- prośba o obrót telefonu (w pionie) --------------------------- */
#rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  #rotate {
    display: flex; position: fixed; inset: 0; z-index: 10000;
    background: #0e1021; color: var(--text);
    align-items: center; justify-content: center; text-align: center; padding: 24px;
  }
  .crt { display: none; }   /* ukryj grę, dopóki telefon w pionie */
}
.rot-inner { max-width: 360px; }
.rot-emoji { font-size: 64px; margin-bottom: 18px; animation: rotatePhone 2.2s ease-in-out infinite; }
#rotate h3 { font-family: var(--pixel); font-size: 13px; color: var(--accent); line-height: 1.7; }
@keyframes rotatePhone { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }

@media (max-width: 700px) {
  html, body { font-size: 18px; }
  .logo { font-size: 26px; }
  .ach-grid { grid-template-columns: 1fr; }
  .skill-row { grid-template-columns: 1fr 90px 44px; }
}
