* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #f4f5f8;
  font-family: Tahoma;
  color: #222;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: url("https://vinizinho.net/figures/backgrounds/dexter.png");
}
#page {
  display: flex;
  flex: 1;
  min-height: 0;
}

#left-bar {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  height: 80%;
  aspect-ratio: 350 / 918;
  top: 10%;
  left: 2%;
}
#coluna {
  width: 100%;
  height: 100%;
  display: block;
}
#placa-arquivo {
  position: absolute;
  left: 7.14%;
  top: 56.43%;
  width: 85.7%;
}

#main-div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 4px;
  flex: 1;
  min-width: 0;
  margin-left: -10%;
}
button {
  padding: 5px 12px;
  border: 1px solid #cfd6e2;
  cursor: pointer;
  font-family: inherit;
  background-color: #222;
  color: white;
}
button:hover { background: #9a3f3f; }
button:active { transform: translateY(1px); }
button.btn-gap { margin-left: 3em; }

@keyframes dance {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  20% { transform: rotate(-7deg) translateY(-2px); }
  50% { transform: rotate(0deg) translateY(-3px); }
  80% { transform: rotate(7deg) translateY(-2px); }
}
/* "Revelar tudo" hidden from the UI (the handler stays wired up) */
#btnRevealAll { display: none; }

#main-div button.dance { animation: dance 0.55s ease-in-out infinite; }

/* ---------- Result modal ---------- */
.result-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  opacity: 0;
  transform: scale(1.2);
  animation: row-in 0.4s ease forwards;
}
@keyframes row-in {
  to { opacity: 1; transform: scale(1); }
}
.result-row .rlabel { flex: 1; font-weight: 600; color: #444; }
.result-row .rval {
  flex: none; font-weight: 800; font-size: 15px;
  font-variant-numeric: tabular-nums; color: #222;
}
/* Full-width rows (victory message, badge): no label, centered text. */
.result-row.victory, .result-row.badge { justify-content: center; text-align: center; }
.result-row.victory .rlabel, .result-row.badge .rlabel { display: none; }
.result-row.victory .rval { flex: 1 1 auto; white-space: normal; }
.result-row.victory {
  border-color: #9ad3a5; background: linear-gradient(#fff, #eaf7ee);
  font-weight: 600;
}
.result-row.victory .rval { color: #2e8b57; }
.result-row.badge {
  border-color: #d8c56a; background: #fdf8e3;
  font-weight: 700;
}
.result-row.badge .rval { color: #8a6d12; }
.result-actions {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-top: 16px;
  opacity: 0;
  animation: row-in 0.4s ease forwards;
}
.copy-status { font-size: 12px; color: #2e8b57; font-weight: 600; min-height: 1em; }

/* ---------- Result delivery animation (arrow + paper) ---------- */
#resultModal { overflow: hidden; }
/* Invisible anchor point where the arrow's center lands (near screen center).
   All sizes derive from --paper-w so arrow and paper stay in proportion. */
#deliveryStage {
  position: absolute;
  left: 55vw;
  top: 20vh;
  width: 0;
  height: 0;
  --paper-w: min(500px, 80vw, 45vh);
  --paper-h: calc(var(--paper-w) * 1.621);   /* 1373/847 */
}
/* Flying arrow: sized to match the arrow portion of the combined image
   (arrow spans ~516px of the 847px-wide combined image). */
#deliveryArrow {
  position: absolute;
  width: calc(var(--paper-w) * 0.609);
  height: auto;
  opacity: 0;
  animation:
    arrow-fly 0.45s ease-in forwards,
    arrow-vanish 0.15s linear 0.45s forwards;
}
@keyframes arrow-fly {
  from { opacity: 1; transform: translate(calc(-50% + 40vw), calc(-50% - 75vh)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
@keyframes arrow-vanish { to { opacity: 0; } }
/* Paper (combined arrow+paper image). Positioned so that the arrow inside it
   lands exactly where the flying arrow stopped: the arrow's center sits at
   (~69.4%, ~16.8%) of the combined image. */
#deliveryPaper {
  position: absolute;
  width: var(--paper-w);
  left: calc(var(--paper-w) * -0.694);
  top: calc(var(--paper-h) * -0.168);
  opacity: 0;
  transform-origin: 40% 33%;   /* grows out of the arrow tip */
  animation: paper-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) 0.45s forwards;
}
@keyframes paper-pop {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
#paperArt { display: block; width: 100%; height: auto; }
/* Results placed over the paper's white area (x 3%..74%, y 23%..98% of image). */
.paper-content {
  position: absolute;
  left: 8%;
  top: 27%;
  width: 60%;
  bottom: 5%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.paper-content .result-rows { max-width: 100%; gap: 5px; }
.paper-content .result-row { padding: 5px 9px; font-size: 16px; gap: 6px; }
.paper-content .result-actions { margin-top: 10px; gap: 6px; flex-wrap: wrap; }
.paper-content .result-share { padding: 7px 14px; font-size: 13px; }
/* Repeat check with no board changes: show the paper immediately, no flight,
   no pop, no row stagger. */
#resultModal.instant #deliveryArrow { animation: none; opacity: 0; }
#resultModal.instant #deliveryPaper { animation: none; opacity: 1; transform: none; }
#resultModal.instant .result-row,
#resultModal.instant .result-actions { animation: none; opacity: 1; transform: none; }

#board {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 0;
}
#board canvas {
  display: block;
  flex-shrink: 0;
}

.help {
  margin: 0 0 10px;
  font-size: 12px;
  color: #6b7488;
  text-align: center;
}

.err {
  max-width: 540px;
  margin: 24px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #933;
  background: #fff5f5;
  border: 1px solid #f0c0c0;
  border-radius: 8px;
  display: none;
}
.err code {
  background: #f0f0f5;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.placa img:hover {
  transform: rotate(-5deg);
}

/* ---------- Instructions modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-family: inherit;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  width: min(90vw, 460px);
  max-height: 80vh;
  overflow: auto;
  color: #222;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e8e8ee;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #6b7488;
  padding: 0 4px;
}
.modal-close:hover { color: #9a3f3f; }
.modal-body {
  padding: 12px 18px 18px;
}
.modal-body ul {
  margin: 0;
  padding-left: 18px;
}
.modal-body li {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.45;
}