* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #101114;
  color: #fff;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  user-select: none;
}

#game { display: block; width: 100vw; height: 100vh; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 2px 6px rgba(0, 0, 0, .65); }

#score { position: absolute; left: 24px; top: 18px; }
#total { font-size: 44px; font-weight: 800; letter-spacing: 1px; line-height: 1; }
#score .sub { margin-top: 4px; font-size: 12px; letter-spacing: 2px; opacity: .85; }

#goals { position: absolute; right: 22px; top: 18px; font-size: 13px; text-align: right; line-height: 1.55; }
#goals div { opacity: .9; }
#goals div.done { opacity: .5; text-decoration: line-through; color: #b6f29a; }

#speed { position: absolute; left: 24px; bottom: 20px; font-size: 14px; letter-spacing: 1px; }
#speed b { font-size: 30px; font-weight: 800; }
#stance { margin-left: 10px; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 700; letter-spacing: 2px; background: #f2b632; color: #1b1b1d; text-shadow: none; }
#stance:empty { display: none; }

#combo { position: absolute; left: 50%; bottom: 84px; width: min(900px, 90vw); transform: translateX(-50%); text-align: center; }
#comboTricks { font-size: 19px; font-weight: 600; line-height: 1.3; }
#comboTricks .last { color: #ffd54a; }
#comboPts { margin-top: 4px; font-size: 30px; font-weight: 800; }
#comboPts small { font-size: 20px; color: #ffd54a; }

#banner { position: absolute; left: 50%; bottom: 190px; transform: translateX(-50%); font-size: 26px; font-weight: 800; letter-spacing: 1px; opacity: 0; transition: opacity .25s, transform .25s; white-space: nowrap; }
#banner.show { opacity: 1; transform: translateX(-50%) translateY(-8px); }
#banner.good { color: #9af27a; }
#banner.bad { color: #ff6b5e; }

#balance { position: absolute; left: 50%; bottom: 56px; width: 240px; height: 10px; transform: translateX(-50%); border-radius: 5px; background: rgba(0, 0, 0, .45); outline: 1px solid rgba(255, 255, 255, .5); opacity: 0; transition: opacity .15s; }
#balance.show { opacity: 1; }
#balance::after { content: ""; position: absolute; left: 50%; top: -3px; width: 2px; height: 16px; background: rgba(255, 255, 255, .7); }
#balance i { position: absolute; top: -3px; left: 50%; width: 10px; height: 16px; margin-left: -5px; border-radius: 3px; background: #ffd54a; }
#balance.danger i { background: #ff5a4c; }

#toast { position: absolute; left: 50%; top: 22px; transform: translateX(-50%); padding: 8px 16px; border-radius: 4px; background: rgba(0, 0, 0, .6); font-size: 14px; opacity: 0; transition: opacity .3s; text-shadow: none; }
#toast.show { opacity: 1; }

#help { position: absolute; right: 22px; bottom: 20px; padding: 12px 16px; border-radius: 6px; background: rgba(0, 0, 0, .55); font-size: 12.5px; line-height: 1.6; text-shadow: none; max-width: 400px; }
#help b { display: inline-block; min-width: 96px; color: #ffd54a; font-weight: 600; }
#help h4 { margin: 6px 0 2px; font-size: 11px; letter-spacing: 2px; opacity: .7; }
#help h4:first-child { margin-top: 0; }
#help.min { padding: 6px 10px; opacity: .75; }

/* ---------- telas ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(12, 13, 16, .72); backdrop-filter: blur(3px); }
#start { justify-content: flex-start; padding-left: 6vw; background: linear-gradient(90deg, rgba(14, 16, 22, .88) 0%, rgba(14, 16, 22, .55) 38%, rgba(14, 16, 22, 0) 62%); backdrop-filter: none; }
.pickTitle { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
#chars { display: flex; gap: 14px; justify-content: center; margin-bottom: 14px; }
.char { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 150px; padding: 8px 10px; background: #2b2e36; color: #fff; border: 3px solid transparent; font-size: 17px; }
.char span { font-size: 28px; line-height: 1; font-weight: 400; }
.char:hover { background: #383c46; }
.pickTitle.small { margin-top: 2px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; opacity: .7; }
.wardrobe { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px 12px; margin-bottom: 16px; text-align: left; }
.wardrobe label { margin: 0; flex-direction: column; align-items: stretch; gap: 3px; font-size: 12px; opacity: .95; }
.wardrobe select { width: 100%; font-size: 13px; padding: 5px 6px; }
.wardrobe.one { grid-template-columns: 1fr; }
#wardrobeMenu, #boardMenu { grid-template-columns: 1fr 1fr; margin: 10px 0 0; }
#wardrobeMenu label, #boardMenu label { font-size: 12px; }
.char.selected { border-color: #ffd54a; background: #3a3d45; }

.panel { padding: 26px 40px; border-radius: 10px; background: rgba(22, 24, 29, .94); text-align: center; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.panel.wide { max-width: 860px; width: 92vw; max-height: 92vh; overflow: auto; text-align: left; }
.panel h1 { margin: 0; font-size: 44px; letter-spacing: 6px; font-weight: 900; }
.panel h2 { margin: 0 0 14px; font-size: 26px; letter-spacing: 2px; }
.panel h3 { margin: 18px 0 8px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; opacity: .7; }
.tag { margin: 4px 0 14px; letter-spacing: 3px; font-size: 13px; text-transform: uppercase; color: #ffd54a; }
.hint { margin: 14px 0 0; font-size: 13px; opacity: .7; line-height: 1.5; }

button { font: inherit; color: #1b1b1d; background: #ffd54a; border: 0; border-radius: 5px; padding: 12px 34px; font-weight: 800; letter-spacing: 1px; cursor: pointer; }
button:hover { background: #ffe282; }
button.small { padding: 3px 10px; font-size: 11px; font-weight: 600; margin-left: 8px; background: #3a3d45; color: #fff; }
.row.buttons { display: flex; gap: 12px; }
button.alt { background: #3a3d45; color: #fff; }

/* ---------- abas do menu ---------- */
.tabs { display: flex; gap: 6px; margin: 16px 0 6px; border-bottom: 2px solid #3a3d45; }
.tab { padding: 8px 18px; font-size: 13px; background: transparent; color: #c9ccd3; border-radius: 5px 5px 0 0; }
.tab:hover { background: #2b2e36; }
.tab.selected { background: #3a3d45; color: #ffd54a; }
#keys { columns: 2; column-gap: 30px; }
#keys .key { break-inside: avoid; }
/* na aba de personalização o painel vai para o lado e o personagem aparece */
#menu.look { justify-content: flex-start; padding-left: 5vw; background: linear-gradient(90deg, rgba(14, 16, 22, .85) 0%, rgba(14, 16, 22, .5) 40%, rgba(14, 16, 22, 0) 64%); backdrop-filter: none; }
#menu.look .panel.wide { max-width: 520px; }
button.alt:hover { background: #4a4e58; }

/* ---------- replay ---------- */
#replay { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; background: rgba(16, 17, 21, .82); width: min(820px, 94vw); }
#replay .badge { padding: 3px 9px; border-radius: 3px; background: #d8432e; font-size: 12px; font-weight: 800; letter-spacing: 2px; }
#replay button { padding: 7px 14px; font-size: 13px; }
#replay #rpPlay { min-width: 46px; }
#replay input[type=range] { flex: 1; width: auto; }
#replay select { padding: 7px 8px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } }

label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; font-size: 14px; }
label.check { justify-content: flex-start; }
input[type=range] { width: 170px; accent-color: #ffd54a; }
select { font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 4px; border: 0; background: #3a3d45; color: #fff; }
input[type=checkbox] { accent-color: #ffd54a; width: 16px; height: 16px; }

#keys .key { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 13.5px; }
#keys .key button { min-width: 92px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; background: #3a3d45; color: #fff; }
#keys .key button.wait { background: #ffd54a; color: #1b1b1d; }
#stats { font-size: 13.5px; line-height: 1.7; opacity: .9; }

/* créditos (tela inicial e menu) */
.credit { margin: 10px 0 0; font-size: 11px; opacity: 0.65; letter-spacing: 0.3px; }

/* ---------- celular: controles de toque ---------- */
body.touch, body.touch #game { touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#touch .tbtn, #touch .stick { pointer-events: auto; touch-action: none; }
#touch .tbtn { border: 2px solid rgba(255, 255, 255, .45); background: rgba(20, 22, 28, .45); color: #fff; font: 800 13px/1 "Segoe UI", system-ui, sans-serif; letter-spacing: 1px; border-radius: 50%; }
#touch .tbtn.on { background: rgba(255, 213, 74, .75); color: #1b1b1d; border-color: #ffd54a; }
#touch .stick { position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(20, 22, 28, .3); }
#touch .knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(255, 255, 255, .55); }
#touch .actions { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 270px; height: 250px; }
#touch .actions .tbtn { position: absolute; }
#touch .ollie { width: 92px; height: 92px; right: 0; bottom: 0; font-size: 16px; }
#touch .pad { width: 56px; height: 56px; font-size: 18px; }
#touch .pad.up { right: 152px; bottom: 150px; }
#touch .pad.down { right: 152px; bottom: 30px; }
#touch .pad.left { right: 210px; bottom: 90px; }
#touch .pad.right { right: 94px; bottom: 90px; }
#touch .small { width: 66px; height: 40px; border-radius: 20px; font-size: 11px; }
#touch .small.manual { right: 12px; bottom: 108px; }
#touch .small.grab { right: 12px; bottom: 156px; }
#touch .small.slide { right: 12px; bottom: 204px; }
#touch .top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; }
#touch .top .tbtn { width: 46px; height: 46px; font-size: 16px; }
body.touch #total { font-size: 34px; }
body.touch #combo { bottom: 170px; }

/* celular em pé: pede para deitar */
#rotate { display: none; }
@media (orientation: portrait) {
  body.touch #rotate { display: flex; position: fixed; inset: 0; z-index: 50; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: #101114; color: #fff; text-align: center; padding: 24px; font-size: 18px; }
  body.touch #rotate .phone { width: 46px; height: 80px; border: 4px solid #ffd54a; border-radius: 10px; animation: girar 2s ease-in-out infinite; }
}
@keyframes girar { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { body.touch #rotate .phone { animation: none; transform: rotate(-90deg); } }

/* telas baixas (celular deitado): a tela inicial e o menu rolam e ficam mais compactos */
.overlay { overflow-y: auto; align-items: flex-start; padding: 10px; }
.overlay > .panel { margin: auto; }
@media (max-height: 560px) {
  .panel { padding: 14px 20px; }
  .panel h1 { font-size: 28px; letter-spacing: 4px; }
  .panel.wide { max-height: none; }
  #chars { margin-bottom: 8px; }
  .wardrobe { margin-bottom: 10px; }
}

/* no toque o lembrete de tecla (H) não faz sentido; a ajuda aberta fica acima dos botões */
body.touch #help.min { display: none; }
body.touch #help:not(.min) { z-index: 6; }

/* celular deitado: a lista de objetivos ficaria por baixo dos botões */
@media (max-height: 500px) { body.touch #goals { display: none; } }

/* instalar como app */
#install { margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#install p { margin: 0; max-width: 420px; font-size: 13px; line-height: 1.45; opacity: .9; }
#install.highlight { padding: 10px 14px; border: 2px solid #ffd54a; border-radius: 8px; }
