:root {
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-border: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;

  --color-sst: #0284c7;
  --color-saude: #16a34a;
  --color-ma: #d97706;
  --color-danger: #dc2626;
  --color-success: #16a34a;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-body);
}

#app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100vh;
  padding: 10px 14px;
  max-width: 900px;
  margin: 0 auto;
}

/* Glass Panels */
.glass-header {
  width: 100%;
  height: 54px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.glass-card-heavy {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
}

/* HUD Components */
.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: #0f172a;
}

.badge-cat {
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}

.badge-cat.sst { background: var(--color-sst); }
.badge-cat.saude { background: var(--color-saude); }
.badge-cat.ma { background: var(--color-ma); }

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.88rem;
  border: 1px solid #e2e8f0;
}

.pill-label {
  color: var(--text-muted);
  font-weight: 600;
}

.pill-val {
  font-family: var(--font-heading);
  font-weight: 800;
  color: #0f172a;
}

.icon-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: #e2e8f0;
  transform: translateY(-2px);
}

/* Main Layout */
#game-main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0;
}

.game-stage {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  align-items: stretch;
}

/* Gallows Canvas Card */
.canvas-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: #ffffff;
}

.error-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--color-danger);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 12px;
}

#gallows-canvas {
  width: 100%;
  height: 100%;
  max-height: 240px;
  display: block;
}

/* Clue Question Card */
.clue-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #ffffff;
}

.clue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-sst);
}

.clue-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
}

.clue-question {
  font-size: 0.98rem;
  line-height: 1.45;
  color: #1e293b;
  font-weight: 500;
  margin: 10px 0;
}

/* Word Slots */
.word-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 8px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
}

.letter-slot {
  width: 36px;
  height: 44px;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.3rem;
  color: #0f172a;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.letter-slot.filled {
  border-color: var(--color-sst);
  background: #f0f9ff;
  color: var(--color-sst);
  animation: pop-slot 0.25s ease;
}

.letter-space {
  width: 14px;
}

@keyframes pop-slot {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Virtual Keyboard Section */
.keyboard-section {
  padding: 12px;
  background: #ffffff;
}

.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 6px;
}

.key-btn {
  height: 44px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: #0f172a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.key-btn:hover:not(:disabled) {
  background: #e2e8f0;
  transform: translateY(-2px);
}

.key-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.key-btn.correct {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.key-btn.wrong {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* Modals */
.overlay-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 94vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card.center-menu {
  text-align: center;
  align-items: center;
}

.modal-badge-status {
  align-self: flex-start;
  padding: 5px 14px;
  border-radius: 20px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.82rem;
}

.modal-badge-status.danger {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

.modal-badge-status.success {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

.modal-card h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
}

.explanation-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.exp-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px 14px;
  border-radius: 14px;
}

.exp-section h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.exp-section p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.correct-word-box {
  background: #f0f9ff;
  border-color: #bae6fd;
  display: flex;
  align-items: center;
  gap: 10px;
}

.exp-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.highlight-word {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--color-sst);
  letter-spacing: 1px;
}

.btn-primary {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  border: none;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: 14px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.3);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.4);
}

.menu-header .hero-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 6px;
}

.menu-header h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 900;
  color: #0f172a;
}

.menu-header .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.menu-intro-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  width: 100%;
}

.menu-intro-box h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin-bottom: 10px;
  color: #0f172a;
}

.menu-intro-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-intro-box li {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 680px) {
  .game-stage {
    grid-template-columns: 1fr;
  }
  .canvas-card {
    max-height: 180px;
  }
  #gallows-canvas {
    max-height: 160px;
  }
  .keyboard-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  .key-btn {
    height: 40px;
    font-size: 1rem;
  }
  .letter-slot {
    width: 30px;
    height: 38px;
    font-size: 1.1rem;
  }
}
