:root {
  --s: 3;                 /* mērogs, ko iestata game.js */
  --ink: #1b1f2a;
  --paper: #fff7e0;
  --accent: #e8452c;
  --green: #2f6d3a;
  --gold: #f2b632;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #14202b;
  overflow: hidden;
  font-family: 'Pixelify Sans', ui-monospace, monospace;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

/* Skatuve aizņem visu ekrānu; kanvu novieto game.js. Pārklājumi (HUD, dialogi) ir pret visu ekrānu,
   tāpēc telefonā vertikāli teksts paliek liels un vilkt var arī tukšajā laukumā zem spēles. */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-size: 16px;          /* precīzo vērtību iestata game.js */
  line-height: 1.25;
  touch-action: none;
  cursor: crosshair;
}

canvas {
  position: absolute;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

button, a { touch-action: manipulation; }

[hidden] { display: none !important; }

/* ---------- Pogas ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1em;
  color: #fff;
  background: var(--accent);
  border: none;
  padding: .45em .9em;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 calc(var(--s) * 2px) 0 #a02a17, inset 0 calc(var(--s) * 1px) 0 #ff7a5c;
  transition: transform .08s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(calc(var(--s) * 2px)); box-shadow: 0 0 0 #a02a17; }
.btn:focus-visible { outline: calc(var(--s) * 1px) solid var(--gold); outline-offset: 2px; }
.btn.big { font-size: 1.35em; }
.btn.ghost { background: #3a4a5c; box-shadow: 0 calc(var(--s) * 2px) 0 #222c38; }

/* ---------- Ekrāni ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .5em;
  padding: 1em;
}

#title { background: linear-gradient(rgba(20,32,43,.15), rgba(20,32,43,.55)); color: #fff; }

.logo {
  font-weight: 700;
  font-size: 3.6em;
  line-height: .95;
  color: var(--gold);
  text-shadow:
    calc(var(--s) * 1px) calc(var(--s) * 1px) 0 #a02a17,
    calc(var(--s) * 2px) calc(var(--s) * 2px) 0 #a02a17,
    calc(var(--s) * 3px) calc(var(--s) * 3px) 0 var(--ink);
  letter-spacing: .04em;
}
.logo.small { font-size: 2.6em; }
.sub { margin: .2em 0 .6em; font-size: 1.2em; text-shadow: 0 2px 0 var(--ink); }
.by { margin: .8em 0 0; opacity: .9; font-size: .9em; text-shadow: 0 2px 0 var(--ink); }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: max(.4em, env(safe-area-inset-top)); left: max(.4em, env(safe-area-inset-left)); right: max(.4em, env(safe-area-inset-right));
  display: flex;
  gap: .35em;
  flex-wrap: wrap;
  pointer-events: none;
}
.hud-box {
  background: rgba(27,31,42,.78);
  color: #fff;
  padding: .2em .45em;
  font-size: .85em;
  white-space: nowrap;
}
.hud-box .lbl { opacity: .7; font-size: .8em; }
.disc-box { display: flex; align-items: center; gap: .35em; }
#hud-disc-dot {
  display: inline-block;
  width: .9em; height: .45em;
  background: var(--accent);
  box-shadow: inset 0 calc(var(--s) * -1px) 0 rgba(0,0,0,.35);
}
.hud-btn {
  margin-left: auto;
  pointer-events: auto;
  font: inherit;
  background: rgba(27,31,42,.78);
  color: #fff;
  border: none;
  padding: .2em .55em;
  cursor: pointer;
}
.hud-btn.off { opacity: .45; text-decoration: line-through; }

/* ---------- Paziņojumi ---------- */
#toast {
  position: absolute;
  left: 50%;
  top: calc(2.4em + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: 88%;
  background: var(--paper);
  border: calc(var(--s) * 1px) solid var(--ink);
  box-shadow: calc(var(--s) * 2px) calc(var(--s) * 2px) 0 var(--ink);
  padding: .35em .6em;
  font-size: 1.05em;
  text-align: center;
  pointer-events: none;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(.85); opacity: 0; } }

/* ---------- Dialogs ---------- */
#dialog {
  position: absolute;
  left: max(.6em, env(safe-area-inset-left)); right: max(.6em, env(safe-area-inset-right)); top: max(.6em, env(safe-area-inset-top));
  max-width: 52em;
  margin: 0 auto;
  background: var(--paper);
  border: calc(var(--s) * 1px) solid var(--ink);
  box-shadow: calc(var(--s) * 2px) calc(var(--s) * 2px) 0 var(--ink);
  padding: .55em .7em .5em;
  animation: rise .25s ease-out;
}
@keyframes rise { from { transform: translateY(-20%); opacity: 0; } }
#dlg-text { margin: 0 0 .4em; min-height: 2.5em; font-size: 1.12em; line-height: 1.35; }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; }
#dlg-step { opacity: .55; font-size: .8em; }

#cards { display: flex; gap: .4em; margin-bottom: .5em; }
.card {
  flex: 1;
  background: #fff;
  border: calc(var(--s) * 1px) solid var(--ink);
  padding: .3em .2em;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  font-size: .85em;
}
.card i {
  width: 2.2em; height: .9em;
  margin: .1em 0 .3em;
  background: var(--c);
  box-shadow: inset 0 calc(var(--s) * -2px) 0 rgba(0,0,0,.3), inset 0 calc(var(--s) * 1px) 0 rgba(255,255,255,.35);
}
.card span { opacity: .65; font-size: .85em; }

/* ---------- Beigas ---------- */
#end {
  background: rgba(20,32,43,.82);
  color: #fff;
  overflow-y: auto;
  touch-action: pan-y;
  cursor: auto;
  justify-content: flex-start;
  padding-top: max(1.2em, env(safe-area-inset-top));
  padding-bottom: max(1em, env(safe-area-inset-bottom));
}
#end p { margin: .15em 0; max-width: 34em; }
#end-text { font-size: 1.1em; }
#terms {
  list-style: none;
  padding: 0;
  margin: .3em 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25em .6em;
  font-size: .95em;
  text-align: left;
}
#terms li { padding: .15em .4em; background: rgba(255,255,255,.08); opacity: .7; }
#terms li.hit { background: var(--gold); color: var(--ink); opacity: 1; }
.outro { font-size: 1.05em; opacity: .95; line-height: 1.35; }
#countdown { color: var(--gold); min-height: 1.2em; }
.end-btns { display: flex; gap: .6em; flex-wrap: wrap; justify-content: center; margin-top: .3em; }

#rotate {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--gold);
  text-align: center;
  font-size: .8em;
  padding: .2em;
  pointer-events: none;
}

#title, #dialog { cursor: auto; }
.hud-btn + .hud-btn { margin-left: 0; }

/* ---------- Mobilie ekrāni ---------- */
#rotate {
  padding: .5em .8em calc(.5em + env(safe-area-inset-bottom));
  font-size: .9em;
}
@media (max-height: 480px) {           /* telefons horizontāli */
  .logo { font-size: 2.8em; }
  .logo.small { font-size: 1.9em; }
  #end { padding-top: .6em; gap: .3em; }
  #terms { font-size: .9em; }
  .btn.big { font-size: 1.15em; }
  #cards { margin-bottom: .3em; }
  .card { padding: .15em .2em; }
}
@media (max-width: 520px) {            /* telefons vertikāli */
  #terms { grid-template-columns: 1fr; }
  #cards { flex-wrap: wrap; }
  .card { flex: 1 1 40%; }
  .hud-box { font-size: 1em; }
  .hud-box .lbl { font-size: .75em; }
}

/* ---------- Ace balva ---------- */
#ace-prize {
  background: var(--paper);
  color: var(--ink);
  border: calc(var(--s) * 1px) solid var(--ink);
  box-shadow: calc(var(--s) * 2px) calc(var(--s) * 2px) 0 var(--gold);
  padding: .5em .8em;
  max-width: 30em;
  animation: pop-in .4s ease-out;
}
@keyframes pop-in { from { transform: scale(.8); opacity: 0; } }
#ace-prize p { margin: .15em 0; }
.prize-title { font-size: 1.1em; }
.prize-title b { color: var(--accent); }
.code-row { display: flex; gap: .5em; justify-content: center; align-items: center; margin: .35em 0; flex-wrap: wrap; }
.code {
  font-weight: 700;
  font-size: 1.35em;
  letter-spacing: .08em;
  padding: .15em .6em;
  background: #fff;
  border: calc(var(--s) * 1px) dashed var(--accent);
  user-select: all;
  -webkit-user-select: all;
}
.prize-note { font-size: .85em; opacity: .8; }
