:root {
  --color-correct: #2e7d32;
  --color-present: #d9a014;
  --color-absent: #757575;
  --color-bg: #ffffff;
  --color-card-bg: #ffffff;
  --color-text: #212121;
  --color-border: #d3d6da;
  --color-key-bg: #e2e8f0;
  --color-key-text: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.app-container {
  width: 100%;
  max-width: 520px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Estilo Hashtag para el Título */
.hashtag-title {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  max-width: fit-content;
}

.hashtag-symbol {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--color-correct);
  line-height: 1;
}

.hashtag-title h1 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.3px;
  color: #0f172a;
  text-transform: none;
  white-space: nowrap;
}

.menu-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:hover {
  background-color: #f1f5f9;
}

.mode-selector {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mode-btn {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  border-radius: 6px;
  font-weight: bold;
}

.mode-btn.active {
  background: var(--color-correct);
  color: #fff;
  border-color: var(--color-correct);
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.free-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
}

.word-badge {
  background: #f1f5f9;
  color: #334155;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  font-weight: bold;
  border: 1px solid #cbd5e1;
}

.completed-banner {
  background-color: #3b82f6;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 12px;
  text-align: center;
  width: 100%;
}

/* Botón de Pistas */
.hint-container {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 12px;
}

.hint-btn {
  background-color: #d97706;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color 0.2s, opacity 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hint-btn:hover:not(:disabled) {
  background-color: #b45309;
}

.hint-btn:disabled {
  background-color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

#game-board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
  align-items: center;
}

.board-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.tile {
  flex: 1;
  max-width: 52px;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--color-border);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.1rem, 4vw, 1.7rem);
  font-weight: bold;
  text-transform: uppercase;
  border-radius: 4px;
  user-select: none;
  background-color: #fff;
  color: var(--color-text);
  perspective: 1000px;
  transition: border-color 0.2s ease, transform 0.15s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.tile.selectable {
  cursor: pointer;
}

.tile.selected {
  border: 4px solid #0284c7 !important;
  background-color: #e0f2fe !important;
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.5);
  z-index: 2;
}

@keyframes flipTile {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.tile.flip {
  animation: flipTile 0.5s ease forwards;
}

.tile.filled { border-color: #878a8c; }
.tile.correct { background-color: var(--color-correct); border-color: var(--color-correct); color: #fff; }
.tile.present { background-color: var(--color-present); border-color: var(--color-present); color: #fff; }
.tile.absent { background-color: var(--color-absent); border-color: var(--color-absent); color: #fff; }

.tile.ghost-green {
  border-color: var(--color-correct);
  color: var(--color-correct);
  background-color: rgba(46, 125, 50, 0.1);
}

.main-actions-container {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  width: 100%;
}

#keyboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.key {
  background-color: var(--color-key-bg);
  color: var(--color-key-text);
  border: none;
  border-radius: 4px;
  font-weight: bold;
  height: 52px;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
  transition: background-color 0.3s ease;
}

.key.wide-key {
  flex: 1.5;
  font-size: 0.75rem;
}

.key.correct { background-color: var(--color-correct); color: #fff; }
.key.present { background-color: var(--color-present); color: #fff; }
.key.absent { background-color: var(--color-absent); color: #fff; }

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 16px;
  box-sizing: border-box;
}

.modal-content {
  background: var(--color-card-bg);
  padding: 24px;
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  border: 1px solid #e2e8f0;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
}

.tutorial-divider {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 16px 0;
}

.tutorial-example {
  text-align: left;
  margin-bottom: 12px;
}

.tutorial-example .row {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.tile-sample {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
}

.tile-sample.correct { background: var(--color-correct); border-color: var(--color-correct); color: #fff; }
.tile-sample.present { background: var(--color-present); border-color: var(--color-present); color: #fff; }
.tile-sample.absent { background: var(--color-absent); border-color: var(--color-absent); color: #fff; }

.dont-show-container {
  margin: 16px 0;
  font-size: 0.9rem;
  color: #475569;
}

.action-btn, .action-btn-secondary {
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.action-btn {
  background-color: var(--color-correct);
  color: #fff;
}

.action-btn-secondary {
  background-color: #64748b;
  color: #fff;
}

.feedback-banner {
  padding: 14px;
  border-radius: 6px;
  font-weight: bold;
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.feedback-banner.win { background-color: var(--color-correct); color: #fff; }
/* Estética unificada y amigable (verde claro/suave) en lugar del rojo agresivo */
.feedback-banner.lose { 
  background-color: #e8f5e9; 
  color: #2e7d32; 
  border: 2px solid #a5d6a7; 
}

.countdown-box {
  margin: 16px 0;
  font-size: 0.9rem;
  color: #475569;
}

.timer-digits {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--color-correct);
  margin-top: 6px;
}

.stats-tab-menu {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
}

.stats-tab-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #64748b;
  cursor: pointer;
  border-radius: 4px;
}

.stats-tab-btn.active {
  background-color: var(--color-correct);
  color: #fff;
}

.stats-summary {
  display: flex;
  justify-content: space-around;
  margin: 16px 0;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: bold;
  color: #0f172a;
}

.stat-label {
  font-size: 0.75rem;
  color: #64748b;
}

.stat-time-record-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  margin: 12px 0;
  text-align: center;
  width: 100%;
}

.stat-time-value {
  font-size: 1.4rem;
  font-weight: bold;
  color: #d97706;
  margin-top: 4px;
}

.stat-time-title {
  font-size: 0.8rem;
  color: #475569;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.distribution-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dist-num {
  font-weight: bold;
  width: 18px;
  color: #334155;
  text-align: right;
}

.dist-bar-bg {
  flex: 1;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
}

.dist-bar-fill {
  background-color: var(--color-correct);
  color: #fff;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: right;
  padding: 2px 8px;
  box-sizing: border-box;
  min-width: 28px;
  white-space: nowrap;
}

.definition-box {
  background: #f8fafc;
  border-left: 4px solid var(--color-correct);
  padding: 12px;
  text-align: left;
  margin: 16px 0;
  border-radius: 0 4px 4px 0;
  color: #334155;
  border-top: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.alert-modal-content {
  max-width: 380px;
  padding: 20px;
}

.alert-modal-title {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.1rem;
  color: var(--color-correct);
}

.alert-modal-text {
  font-size: 0.95rem;
  color: #334155;
  line-height: 1.4;
  white-space: pre-line;
  margin-bottom: 18px;
}

.dict-counter {
  font-weight: bold;
  margin: 10px 0;
  text-align: center;
  color: #4a5568;
  font-size: 0.9rem;
}

#dict-search-input {
  width: 100%;
  padding: 10px;
  border: 2px solid #cbd5e0;
  border-radius: 8px;
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
  outline: none;
}

#dict-search-input:focus {
  border-color: var(--color-correct);
}

.dictionary-list {
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  margin-top: 10px;
}

.dict-card {
  background-color: #f7fafc;
  border-left: 5px solid var(--color-correct);
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: left;
}

.dict-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.dict-word {
  font-size: 1.05rem;
  font-weight: bold;
  color: #2d3748;
  text-transform: uppercase;
}

.dict-definition {
  font-size: 0.9rem;
  color: #4a5568;
  line-height: 1.4;
}

.dict-empty-msg {
  text-align: center;
  color: #a0aec0;
  padding: 24px 10px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
  margin-top: 10px;
  box-sizing: border-box;
}

.badge-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}

.badge-card.unlocked {
  background: #f0fdf4;
  border-color: var(--color-correct);
  box-shadow: 0 2px 4px rgba(46, 125, 50, 0.15);
}

.badge-card.locked {
  opacity: 0.55;
  filter: grayscale(80%);
}

.badge-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.badge-title {
  font-size: 0.75rem;
  font-weight: bold;
  color: #1e293b;
  margin-bottom: 2px;
  line-height: 1.2;
}

.badge-desc {
  font-size: 0.65rem;
  color: #64748b;
  line-height: 1.2;
}

.badge-status {
  font-size: 0.6rem;
  font-weight: bold;
  margin-top: 6px;
  padding: 2px 6px;
  border-radius: 10px;
}

.badge-card.unlocked .badge-status {
  background-color: var(--color-correct);
  color: #fff;
}

.badge-card.locked .badge-status {
  background-color: #cbd5e1;
  color: #475569;
}
