:root {
    --bg: #0f1b3d;
    --panel: rgba(20, 28, 60, .92);
    --border: #2b3a6b;
    --text: #f4f6ff;
    --accent: #f5c518;
    --pink: #ff6ea6;
}

body.dark-mode {
    --bg: #060b16;
    --panel: rgba(7, 12, 28, .94);
    --border: #425fb4;
    --text: #fff;
    --accent: #ffd84f;
    --pink: #ff79b0;
}

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

html,
body {
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "VT323", monospace;
    font-size: 18px;
    image-rendering: pixelated;
}

h1,
h2,
h3,
.label,
.key,
.btn-icon,
.coin .bubble,
.hint-bubble,
.dpad button,
.cv,
.modal-head button,
.socials a {
    font-family: "Press Start 2P", monospace;
}

.accent {
    color: var(--accent);
}

/* Elementos partilhados */
.panel {
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
    backdrop-filter: blur(4px);
}

.marquee {
    overflow: hidden;
    padding: 8px 0;
    border-top: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
    background: rgba(0, 0, 0, .4);
}

.marquee-track {
    display: inline-block;
    color: var(--accent);
    font-family: "Press Start 2P", monospace;
    font-size: 10px;
    letter-spacing: .2em;
    white-space: nowrap;
    animation: marquee 40s linear infinite;
}

@keyframes marquee {
    to { transform: translateX(-50%); }
}

/* Mapa */
.stage {
    max-width: 1600px;
    margin: 24px auto;
    padding: 0 16px;
}

.map {
    position: relative;
    width: 100%;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: #1a3a1a url("../imagens/mapa1.jpg") center / cover no-repeat;
    touch-action: none;
}

.greeting {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 5;
    padding: 12px;
    border-radius: 12px;
    background: rgba(12, 20, 45, .55);
    backdrop-filter: blur(3px);
}

.greeting p {
    margin-top: 12px;
    color: rgba(255, 255, 255, .9);
    font-size: 20px;
}

.top-buttons {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 6;
    display: flex;
    gap: 8px;
}

.btn-icon {
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--accent);
}

/* Painel de controlos */
.controls {
    position: absolute;
    top: 50%;
    left: 12px;
    z-index: 5;
    display: block;
    width: 240px;
    padding: 16px;
    transform: translateY(-50%);
}

.controls .label {
    margin-bottom: 12px;
    color: var(--accent);
    font-size: 10px;
    letter-spacing: .2em;
}

.controls .row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.controls .row > span:last-child {
    margin-left: auto;
    color: #fff;
}

.keys {
    display: flex;
    gap: 4px;
}

.key {
    min-width: 24px;
    padding: 4px 8px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    color: #fff;
    font-size: 9px;
    text-align: center;
}

.hint {
    margin-top: 12px;
    color: rgba(255, 255, 255, .7);
    font-size: 16px;
    line-height: 1.3;
}

/* Botões do mapa */
.coin {
    position: absolute;
    width: 58px;
    height: 58px;
    border: 3px solid #8a4d00;
    border-radius: 6px;
    background: linear-gradient(to bottom, #ffd54f 0%, #ffca28 45%, #f9a825 100%);
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35),
                inset 0 -4px 0 rgba(0, 0, 0, .2),
                0 6px 10px rgba(0, 0, 0, .35);
    cursor: pointer;
    transform: translate(-50%, -50%);
    animation: float-box 1.5s ease-in-out infinite;
}

.coin::before {
    content: "?";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: "Press Start 2P", monospace;
    font-size: 22px;
    text-shadow: 2px 2px 0 #8a4d00;
}

.coin .bubble {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    z-index: 10;
    padding: 8px 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
    transform: translateX(-50%);
}

@keyframes float-box {
    0%, 100% { transform: translate(-50%, -50%); }
    50% { transform: translate(-50%, -56%); }
}

/* Personagem */
.character {
    position: absolute;
    z-index: 4;
    user-select: none;
    transform: translate(-50%, -100%);
    transition: left .2s ease, top .2s ease;
    touch-action: none;
    -webkit-user-select: none;
}

.sprite {
    width: 120px;
    height: 120px;
    background: url("../imagens/personagem.png") center / contain no-repeat;
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .4));
    animation: bob 1.2s ease-in-out infinite;
}

.hint-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    padding: 6px 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: #fff;
    font-size: 9px;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    transform: translateX(-50%);
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Minimapa */
.minimap {
    position: absolute;
    right: 24px;
    bottom: 24px;
    z-index: 5;
    padding: 8px;
}

.mini-inner {
    position: relative;
    width: 200px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: url("../imagens/mapa1.jpg") center / cover;
}

.mini-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border: 1px solid #fff;
    border-radius: 50%;
    background: var(--pink);
    transform: translate(-50%, -50%);
}

/* Controlos direcionais */
.dpad {
    position: absolute;
    right: 24px;
    bottom: 250px;
    z-index: 5;
    display: grid;
    grid-template: repeat(3, 44px) / repeat(3, 44px);
    gap: 6px;
}

.dpad button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.dpad button:hover { color: var(--accent); }
.dpad button:active { transform: scale(.95); }
.dpad button[data-dir="up"] { grid-area: 1 / 2; }
.dpad button[data-dir="left"] { grid-area: 2 / 1; }
.dpad button[data-dir="right"] { grid-area: 2 / 3; }
.dpad button[data-dir="down"] { grid-area: 3 / 2; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, .7);
}

.modal[hidden] {
    display: none;
}

.modal-card {
    width: min(900px, 90vw);
    max-height: 90vh;
    padding: 24px;
    overflow-y: auto;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-head h2 {
    color: var(--accent);
    font-size: 14px;
}

.modal-head button {
    border: 0;
    background: none;
    color: rgba(255, 255, 255, .7);
    font-size: 11px;
    cursor: pointer;
}

.modal-head button:hover {
    color: #fff;
}

/* Conteúdo Sobre Mim */
.about-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.about-header {
    text-align: center;
}

.about-header h2 {
    margin-bottom: 20px;
    font-size: 54px;
    line-height: .9;
}

.job {
    margin-bottom: 18px;
    color: var(--accent);
    font-size: 18px;
    letter-spacing: 1px;
}

.desc {
    max-width: 560px;
    margin: 0 auto;
    color: rgba(255, 255, 255, .9);
    font-size: 24px;
    line-height: 1.7;
}

.about-columns {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 23px auto;
}

.about-box {
    min-height: 320px;
    padding: 22px;
}

.about-box h3 {
    margin-bottom: 20px;
    color: var(--accent);
}

.about-box ul {
    list-style: none;
}

.about-box li,
.about-box p {
    margin-bottom: 14px;
    font-size: 22px;
}

.cv {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--accent);
    font-size: 10px;
    text-align: center;
    text-decoration: none;
}

.cv:hover { color: #fff; }

.socials {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 12px 0;
}

.socials a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    color: var(--text);
    font-size: 20px;
    text-decoration: none;
    transition: transform .2s ease;
}

.socials a:hover { transform: translateY(-3px); }

.about-quote {
    max-width: 500px;
    margin: 10px auto 0;
    text-align: center;
}

/* Tablet */
@media (max-width: 1024px) {
    .map { aspect-ratio: 4 / 3; }
    .greeting h1 { font-size: 20px; }
    .greeting p { font-size: 16px; }
    .controls { width: 200px; padding: 12px; }
    .mini-inner { width: 160px; }
}

/* Telemóvel */
@media (max-width: 768px) {
    .map {
        aspect-ratio: 3 / 4;
        border-radius: 8px;
        /* Preserva a proporção da imagem; não estica o mapa. */
        background-position: center;
        background-size: cover;
    }

    .greeting {
        top: 10px;
        right: 150px;
        left: 10px;
    }

    .greeting h1 { font-size: 16px; line-height: 1.3; }
    .greeting p { font-size: 14px; }

    .top-buttons { top: 10px; right: 10px; gap: 6px; }
    .btn-icon { min-width: 40px; height: 40px; padding: 0 8px; font-size: 10px; }

    .minimap { display: none; }

    .controls {
        top: auto;
        bottom: 12px;
        left: 12px;
        z-index: 30;
        display: block;
        width: min(190px, calc(100% - 180px));
        padding: 10px;
        transform: none;
    }

    .controls .label {
        margin-bottom: 8px;
        font-size: 8px;
    }

    .controls .row {
        gap: 5px;
        margin-bottom: 5px;
        font-size: 14px;
    }

    .controls .keys {
        gap: 2px;
    }

    .controls .key {
        min-width: 21px;
        padding: 3px 5px;
        font-size: 7px;
    }

    .controls .hint {
        margin-top: 7px;
        font-size: 12px;
    }

    .dpad {
        position: fixed;
        right: 12px;
        bottom: 12px;
        z-index: 40;
        display: grid;
    }

    .coin {
        width: clamp(34px, 7vw, 44px);
        height: auto;
        aspect-ratio: 1;
        border-width: clamp(2px, .45vw, 3px);
    }

    .coin::before {
        font-size: clamp(14px, 2.8vw, 18px);
    }

    .coin .bubble {
        bottom: calc(100% + clamp(7px, 1.5vw, 10px));
        padding: clamp(4px, .8vw, 6px) clamp(6px, 1.2vw, 8px);
        font-size: clamp(7px, 1.35vw, 9px);
    }

    /* Posições próprias para o enquadramento vertical do telemóvel. */
    .coin[data-id="branding"] {
        top: 28% !important;
        left: 27% !important;
    }

    .coin[data-id="contacto"] {
        top: 28% !important;
        left: 73% !important;
    }

    .coin[data-id="sobre"] {
        top: 68% !important;
        left: 27% !important;
    }

    .coin[data-id="ux"] {
        top: 68% !important;
        left: 73% !important;
    }
    .sprite { width: 72px; height: 72px; }

    .modal-card { width: 94vw; padding: 18px; }
    .about-header h2 { font-size: 28px; line-height: 1.2; }
    .desc { font-size: 20px; }
    .about-columns { flex-direction: column; margin: 12px auto; }
    .about-box { min-height: 0; }
}

@media (max-width: 380px) {
    .greeting h1 { font-size: 14px; }
    .sprite { width: 60px; height: 60px; }

    .controls {
        width: 150px;
    }

    .controls .hint {
        display: none;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .map { aspect-ratio: 16 / 9; }

    .controls {
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }
}

/* RESPONSIVO */


/* Reset básico */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Arial, sans-serif;
  line-height: 1.5;
}

/* Imagens, vídeos e elementos incorporados */
img,
picture,
video,
canvas,
svg,
iframe {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Container central responsivo */
.container {
  width: min(100% - 2rem, 1200px);
  margin-inline: auto;
}

/* Textos que se adaptam ao tamanho da tela */
h1 {
  font-size: clamp(2rem, 5vw, 4rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

p {
  font-size: clamp(1rem, 2vw, 1.125rem);
}

/* Layout flexível */
.flex {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.flex > * {
  flex: 1 1 280px;
}

/* Grade responsiva automática */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1.5rem;
}

/* Formulários */
input,
select,
textarea,
button {
  max-width: 100%;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
}

/* Tabelas largas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* Menu */
nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Celulares */
@media (max-width: 768px) {
  .container {
    width: min(100% - 1.25rem, 1200px);
  }

  nav ul {
    flex-direction: column;
  }

  .hide-mobile {
    display: none !important;
  }
}

/* Deve permanecer no fim: evita que o bloco responsivo genérico altere a Home. */
body {
  font-family: "VT323", monospace;
  line-height: normal;
}

h1,
h2,
h3,
.label,
.key,
.btn-icon,
.coin .bubble,
.hint-bubble,
.dpad button,
.cv,
.modal-head button,
.socials a {
  font-family: "Press Start 2P", monospace;
}

@media (max-width: 768px) {
  .stage {
    width: 100%;
    margin: 14px auto 24px;
    padding: 0 10px;
  }

  .greeting h1 { font-size: 16px; }
  .greeting p { font-size: 14px; }

  .dpad {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 30;
    grid-template: repeat(3, 38px) / repeat(3, 38px);
    gap: 4px;
  }

  .dpad button {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .controls { max-width: calc(100% - 150px); }
}

@media (max-width: 380px) {
  .greeting h1 { font-size: 14px; }
  .controls { width: 160px; }
}
