* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:root {
  --primary: #1a2639;
  --secondary: #6b1c1c;
  --bg: #0a101e;
  --text: #d4d7e0;
  --accent: #5a6a9a;
  --gold: #b89c5b;
  --progress-bg: #2d3748;
  --progress-fill: #4f9be8;
  --error: #e63946;
  --success: #2a9d8f;
  --font-main: 'Roboto', sans-serif;
  --font-title: 'Cinzel', serif;
  --transition: all 0.3s ease;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  margin: 12px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.container {
  max-width: 1000px;
  margin: 1rem auto;
  padding: 1rem;
  min-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen {
  width: 100%;
  max-width: 600px;
  background: linear-gradient(180deg, rgba(26,38,57,0.9), rgba(10,16,30,0.9));
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  text-align: center;
}
.screen.hidden {
  display: none;
}

h1, h2, h3 {
  font-family: var(--font-title);
  color: var(--gold);
  text-align: center;
  margin: 0.8rem 0;
}
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); }
h3 { font-size: clamp(1rem, 2.5vw, 1.3rem); color: var(--accent); }

input[type="text"] {
  padding: 0.7rem;
  font-size: 0.9rem;
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  width: 100%;
  max-width: 350px;
  margin: 0.5rem 0.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: var(--transition);
}
input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 5px rgba(184,156,91,0.5);
}

button {
  padding: 0.7rem 1.2rem;
  font-size: 0.9rem;
  color: var(--text);
  background: linear-gradient(45deg, var(--primary), var(--accent));
  border: 1px solid var(--gold);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
}
button:hover {
  background: linear-gradient(45deg, var(--secondary), var(--gold));
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(184,156,91,0.4);
}

#media-reactions button {
  width: 100%;
  margin: 0.5rem 0;
  background: linear-gradient(45deg, var(--secondary), var(--accent));
  border: 1px solid var(--error);
}
#media-reactions button:hover {
  background: linear-gradient(45deg, var(--error), var(--gold));
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(230,57,70,0.4);
}

.error-message {
  color: var(--error);
  font-size: 0.8rem;
  margin: 0.4rem 0;
  text-align: center;
}

.reputation {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
  width: 100%;
  max-width: 800px;
  padding: 0.8rem;
  background: rgba(10,16,30,0.8);
  border-radius: 6px;
  border: 1px solid var(--accent);
}
.reputation p {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
progress {
  width: 100%;
  height: 12px;
  border-radius: 4px;
  background: var(--progress-bg);
  border: 1px solid var(--accent);
}
progress::-webkit-progress-bar {
  background: var(--progress-bg);
}
progress::-webkit-progress-value {
  background: var(--progress-fill);
}
progress::-moz-progress-bar {
  background: var(--progress-fill);
}

/* backdrop-filter com fallback Safari */
#player-hud, #tutorial-overlay, #hud-history-panel, #hud-career-panel {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.case-content {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 900px;
  padding: 0.8rem;
  background: rgba(10,16,30,0.8);
  border-radius: 6px;
  border: 1px solid var(--accent);
}
.case-details {
  flex: 2 1 500px;
}
.case-details p,
#case-evidences,
#investigation-options,
#decision-options {
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
  padding: 0.8rem;
  background: rgba(30,41,59,0.8);
  border-radius: 4px;
}
#case-evidences ul {
  list-style: disc;
  padding-left: 1.2rem;
}
#investigation-options button,
#decision-options button {
  width: 100%;
  margin: 0.3rem 0;
}

img {
  width: 100%;
  max-width: 400px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  margin: 0.5rem auto;
  display: block;
}

#media-screen .container {
  max-width: 700px;
  padding: 1rem;
}
#media-headline {
  color: var(--gold);
  font-size: clamp(1.3rem, 3vw, 1.5rem);
}
#media-reactions {
  font-style: italic;
  color: var(--accent);
  font-size: 0.85rem;
}

#diplomacy-screen .container {
  max-width: 600px;
}
.diplomacy-description,
.action-description {
  font-size: 0.85rem;
  text-align: center;
  margin: 0.5rem 0;
}
.action-description {
  color: var(--accent);
}

.notification {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--success);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s;
  max-width: 80%;
  font-size: 0.8rem;
  z-index: 1000;
}
.notification.show {
  opacity: 1;
}

.fade-in {
  opacity: 0;
  animation: fadeInSimple 0.5s ease-in forwards;
}
@keyframes fadeInSimple {
  to { opacity: 1; }
}

.metric-increase {
  color: var(--success);
  animation: pulse 0.5s ease-in-out;
}
.metric-decrease {
  color: var(--error);
  animation: pulse 0.5s ease-in-out;
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@media (max-width: 1024px) {
  .case-content {
    flex-direction: column;
  }
  .reputation {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container,
  .screen {
    margin: 0.5rem auto;
    padding: 0.5rem;
  }
  h1 { font-size: clamp(1.4rem, 3.5vw, 1.8rem); }
  button { width: 100%; padding: 0.6rem 1rem; }
  .notification { left: 0.5rem; right: 0.5rem; }
  #media-reactions button {
    font-size: 0.8rem;
    padding: 0.6rem;
  }
}

@media (max-width: 480px) {
  h1 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
  .case-details p,
  #case-evidences li {
    font-size: 0.8rem;
  }
  img { max-width: 100%; }
  .reputation p {
    font-size: 0.8rem;
  }
  #media-reactions {
    font-size: 0.8rem;
  }
}
.hidden {
    display: none !important;
}
.game-description {
    font-size: 0.85rem;
    color: var(--accent);
    text-align: center;
    margin: 0.5rem 0;
    line-height: 1.6;
}
.crisis-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}
.disclaimer {
    font-size: 0.75rem;
    color: #666;
    text-align: center;
    margin: 1rem 0;
    padding: 0.5rem;
    border-top: 1px solid #333;
}



#achievements-container h3 {
    font-size: 12px;
    margin: 4px 0;
    text-align: right;
}

.case-report h4 {
    color: #b89c5b;
    margin-bottom: 8px;
}

.case-report p {
    font-size: 12px;
    margin: 4px 0;
}

/* ===== DIMENSÕES QUÂNTICAS ===== */
.metricas-dimensionais {
    background: #111827;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
}
.metricas-dimensionais h3 {
    font-size: 14px;
    color: #b89c5b;
    margin-bottom: 8px;
    border-bottom: 1px solid #2d3748;
    padding-bottom: 6px;
}
.metricas-dimensionais p {
    font-size: 12px;
    margin: 4px 0;
    display: flex;
    justify-content: space-between;
}
.dim-bar {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #2d3748;
    margin-bottom: 8px;
}
.dim-bar::-webkit-progress-value { border-radius: 4px; }
.dim-bar::-moz-progress-bar { border-radius: 4px; }
.dim-bar[value]:not([value="0"])::-webkit-progress-value { background: linear-gradient(90deg, #ff0040, #b89c5b, #00ff66); }
.dim-bar[value]:not([value="0"])::-moz-progress-bar { background: linear-gradient(90deg, #ff0040, #b89c5b, #00ff66); }

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0;
}

.dimensao-card {
    animation: fadeIn 0.6s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.dimensao-final-box {
    margin: 12px 0;
}

/* Skills */
#skills-screen {
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}
#skills-screen h2 {
    font-family: var(--font-title);
    color: var(--gold);
    text-align: center;
    margin-bottom: 16px;
}
#skills-points {
    text-align: center;
    font-size: 18px;
    color: var(--gold);
    margin-bottom: 20px;
}
#skills-points span {
    font-weight: bold;
    font-size: 22px;
    color: #2a9d8f;
}
.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.skill-column {
    background: #111827;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 12px;
}
.skill-column h4 {
    text-align: center;
    border-bottom: 1px solid #2d3748;
    padding-bottom: 8px;
    margin-bottom: 8px;
}
.skill-buy-btn:hover {
    opacity: 0.85;
}
@media (max-width: 600px) {
    .skills-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes slideInRight {
    from { transform: translateX(60px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeInUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== TRANSIÇÃO ORBITAL E CRISE TENSORIAL ===== */
#transition-screen {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}
#transition-screen h2 {
    font-family: var(--font-title);
    color: var(--gold);
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
}
.transition-content {
    background: #111827;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.orbital-map {
    background: #0a0a1a;
    border: 1px solid #2d3748;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    overflow-x: auto;
}
.orbital-ponto { color: #ff4444; font-weight: bold; }
.orbital-centro { color: #666; }
.orbital-vazio { color: #2d3748; }

.singularity-alert, .crisis-alert {
    margin-top: 12px;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}
.singularity-alert {
    background: #2d0000;
    border: 1px solid #ff4444;
}
.crisis-alert {
    background: #1a1a00;
    border: 1px solid #ffaa00;
}

/* Tela de Singularidade (Game Over) */
#singularity-screen {
    padding: 40px 20px;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}
#singularity-screen h2 {
    font-family: var(--font-title);
    color: #ff4444;
    font-size: 24px;
    margin-bottom: 20px;
}
#singularity-text {
    font-size: 16px;
    color: #ccc;
    margin-bottom: 30px;
    padding: 20px;
    background: #1a0000;
    border: 1px solid #ff4444;
    border-radius: 8px;
}
#singularityRestartBtn {
    padding: 12px 30px;
    background: #6b1c1c;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

/* Tela de Crise Tensorial */
#crisis-tensor-screen {
    padding: 20px;
    max-width: 700px;
    margin: 0 auto;
}
#crisis-tensor-screen h2 {
    font-family: var(--font-title);
    color: #ffaa00;
    text-align: center;
    margin-bottom: 16px;
}
#crisis-tensor-desc {
    background: #111827;
    border: 1px solid #2d3748;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}
.crisis-opt-btn:hover {
    background: #2a2a4e !important;
    border-color: #b89c5b !important;
}

/* ===== v4.0 — GLITCH EFFECTS ===== */
@keyframes glitch-text {
    0% { transform: translate(0); filter: hue-rotate(0deg); }
    20% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
    40% { transform: translate(2px, -1px); filter: hue-rotate(180deg); }
    60% { transform: translate(-1px, -2px); filter: hue-rotate(270deg); }
    80% { transform: translate(1px, 2px); filter: hue-rotate(360deg); }
    100% { transform: translate(0); filter: hue-rotate(0deg); }
}

.glitch-ativo #case-description {
    animation: glitch-text 0.3s infinite;
    color: #00ffcc;
    text-shadow: 2px 0 #ff0044, -2px 0 #00ccff;
}

.glitch-ativo #case-title {
    color: #ff00aa;
    text-shadow: 0 0 10px #ff00aa;
}

@keyframes glitch-bg {
    0% { background-color: #0a0a1a; }
    50% { background-color: #1a0a0a; }
    100% { background-color: #0a0a1a; }
}

.glitch-ativo {
    animation: glitch-bg 2s infinite;
}

/* ===== v4.0 — GEOPOLITICAL PANEL ===== */
#geopolitical-panel {
    margin: 8px 0;
    padding: 6px;
    background: #0d0d1a;
    border: 1px solid #2d3748;
    border-radius: 6px;
    font-size: 12px;
}

/* ===== v4.0 — SINGULARIDADE ASI ===== */
.singularidade-asi h2 {
    text-shadow: 0 0 20px currentColor;
    margin-bottom: 12px;
}

.singularidade-asi p {
    border-left: 3px solid currentColor;
    padding-left: 12px;
}

.singularidade-asi .fas {
    filter: drop-shadow(0 0 8px currentColor);
}

/* ===== v4.0 — ACONTECIMENTO MODAL ===== */
#acontecimento-modal button:hover {
    background: #2a2a4e !important;
    border-color: #b89c5b !important;
}

/* ===== v4.0 — SINGULARITY SCREEN OVERRIDE ===== */
#singularity-screen {
    background: #050510;
}

#singularity-screen h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.5em;
}

#singularity-buttons {
    margin-top: 16px;
    text-align: center;
}

/* ===== v4.0 — ASI AGENT WHISPERS & BOTS ===== */
.agent-whisper {
    font-size: 0.85em;
    font-style: italic;
    opacity: 0.8;
    padding: 6px 12px;
    margin: 8px 0;
    border-radius: 4px;
    background: rgba(0,0,0,0.3);
    animation: whisperFadeIn 0.6s ease-out;
    transition: opacity 1s;
}

@keyframes whisperFadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 0.8; transform: translateX(0); }
}

.bot-message {
    font-size: 0.85em;
    padding: 4px 10px;
    margin: 4px 0;
    border-radius: 3px;
    background: rgba(0,0,0,0.2);
}

#agent-bots {
    margin-top: 8px;
    animation: botAppear 0.5s ease-out;
}

@keyframes botAppear {
    from { opacity: 0; max-height: 0; }
    to   { opacity: 1; max-height: 200px; }
}

#agent-revelation {
    animation: revelationGlitch 1.5s ease-out;
}

@keyframes revelationGlitch {
    0%   { opacity: 0; filter: hue-rotate(0deg); }
    30%  { opacity: 1; filter: hue-rotate(180deg); }
    60%  { filter: hue-rotate(-90deg); }
    100% { opacity: 1; filter: hue-rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    .agent-whisper, #agent-bots, #agent-revelation {
        animation: none !important;
    }
}

/* === Responsivo === */
@media (max-width: 768px) {
    #player-hud {
        font-size: 9px !important;
        padding: 3px 6px !important;
        gap: 6px !important;
    }
    #player-hud span {
        font-size: 9px !important;
    }
    #player-hud span:not(#hud-skill-points):not(#hud-tutorial-btn) {
        white-space: nowrap;
    }
    #hud-career-info, #hud-agent-info, #hud-dimensao-indicator {
        display: none !important;
    }
    .screen {
        padding: 60px 10px 20px !important;
    }
    .screen h2 {
        font-size: 18px !important;
    }
    .screen p, .screen div:not([class]) {
        font-size: 13px !important;
    }
    button {
        font-size: 13px !important;
        padding: 10px 16px !important;
    }
    #case-image {
        height: 120px !important;
        object-fit: cover;
    }
    #decision-options button {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
    #skills-trees {
        flex-direction: column !important;
    }
    #skills-trees > div {
        width: 100% !important;
    }
    #entrevista-resposta {
        min-height: 80px !important;
        font-size: 13px !important;
    }
    #tutorial-overlay > div {
        max-width: 95% !important;
        padding: 16px !important;
    }
    #tutorial-overlay #tutorial-body {
        font-size: 12px !important;
        min-height: 150px !important;
    }
    #hud-history-panel, #hud-career-panel {
        width: 90vw !important;
        max-width: 90vw !important;
        left: 5vw !important;
        right: 5vw !important;
        bottom: 50px !important;
    }
    #hud-career-panel {
        right: 5vw !important;
    }
}

@media (max-width: 480px) {
    #player-hud {
        font-size: 8px !important;
        gap: 4px !important;
        padding: 2px 4px !important;
    }
    #player-hud span {
        font-size: 8px !important;
    }
    #hud-name {
        font-size: 10px !important;
    }
    .screen h2 {
        font-size: 15px !important;
    }
    #case-title {
        font-size: 16px !important;
    }
    .notification {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
    .dimensao-card {
        font-size: 12px !important;
    }
    .dimensao-card h3 {
        font-size: 1.1em !important;
    }
}
