/* Μυστικοί Πράκτορες (Cipher Kids) - High-Tech Spy Theme */
:root {
  --bg-main: #090D16;
  --bg-card: #0F172A;
  --bg-card-light: #1E293B;
  --primary: #38BDF8;
  --primary-hover: #0284C7;
  --accent-gold: #FACC15;
  --accent-emerald: #10B981;
  --accent-rose: #F43F5E;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --border-card: #334155;
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.25);
  --shadow-gold: 0 0 25px rgba(250, 204, 21, 0.3);
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* SpeedGuard Anti-Tamper Red Banner */
.speed-guard-banner {
  background: #DC2626;
  color: #FFF;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.5);
  z-index: 1000;
}
.speed-guard-banner.hidden { display: none !important; }
.sg-icon { font-size: 20px; }
.sg-text { display: flex; flex-direction: column; }
.sg-text span { font-size: 11px; opacity: 0.9; font-weight: normal; }

/* Main App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Top Global Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
}

.hub-link {
  color: var(--accent-gold);
  text-decoration: none;
  font-weight: 700;
  transition: opacity 0.2s;
}
.hub-link:hover { opacity: 0.8; }
.header-sep { color: var(--border-card); }
.brand-title { color: var(--text-main); }

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.pill-btn {
  background: var(--bg-card-light);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  padding: 8px 16px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pill-btn:hover {
  background: #334155;
  border-color: var(--primary);
  color: #FFF;
}
.pill-btn:active { transform: scale(0.97); }

.action-btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-btn {
  background: linear-gradient(135deg, #0284C7 0%, #38BDF8 100%);
  color: #041026;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.4);
}
.primary-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.6);
}
.secondary-btn {
  background: var(--bg-card-light);
  color: var(--text-main);
  border: 1px solid var(--border-card);
}
.secondary-btn:hover {
  background: #334155;
  border-color: var(--primary);
}

/* Screens Common */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.screen.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 1. Home Screen */
.home-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.home-hero {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mascot-wrapper {
  position: relative;
  margin-bottom: 24px;
}
.hero-mascot {
  width: 180px;
  height: 180px;
  filter: drop-shadow(0 8px 24px rgba(56, 189, 248, 0.3));
}
.mascot-speech-bubble {
  position: absolute;
  top: -20px;
  right: -130px;
  background: var(--bg-card-light);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  max-width: 200px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.mascot-speech-bubble::after {
  content: '';
  position: absolute;
  bottom: 12px;
  left: -8px;
  border-width: 6px 8px 6px 0;
  border-style: solid;
  border-color: transparent var(--accent-gold) transparent transparent;
}
.hero-title {
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(135deg, #F8FAFC 0%, #38BDF8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.hero-subtitle {
  font-size: 18px;
  color: var(--accent-gold);
  font-weight: 700;
  margin-bottom: 28px;
}
.hero-actions {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.badge-item {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-card);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 2. Map Screen */
.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.header-center-info {
  text-align: center;
  flex: 1;
  padding: 0 16px;
}
.screen-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}
.screen-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.map-stars-summary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  align-self: center;
}
.stars-counter {
  color: var(--accent-gold);
  font-weight: 900;
  font-size: 16px;
}
.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  width: 100%;
}
.level-card {
  background: var(--bg-card);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.level-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.level-card.locked:hover {
  transform: none;
  border-color: var(--border-card);
  box-shadow: none;
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-num {
  font-size: 12px;
  font-weight: 900;
  background: var(--bg-card-light);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 9999px;
}
.card-stars {
  color: var(--accent-gold);
  font-size: 14px;
}
.card-title {
  font-size: 16px;
  font-weight: 800;
}
.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 3. Game Screen */
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 12px;
}
.mission-info {
  text-align: center;
}
.mission-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
}
.mission-desc {
  font-size: 12px;
  color: var(--text-muted);
}
.game-top-actions {
  display: flex;
  gap: 8px;
}

/* Mascot Tip Bar */
.mascot-tip-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.95);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 12px;
  animation: fadeIn 0.2s ease;
}
.tip-mascot-icon {
  width: 40px;
  height: 40px;
}
.tip-text {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-gold);
}
.close-tip-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}

/* Cipher Workspace */
.cipher-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
}
@media (max-width: 840px) {
  .cipher-workspace {
    grid-template-columns: 1fr;
  }
}

.cipher-tool-area, .cipher-action-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Caesar Wheel */
.tool-view {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tool-view.hidden { display: none !important; }

.wheel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.shift-btn {
  background: var(--bg-card-light);
  border: 1px solid var(--border-card);
  color: var(--primary);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.shift-btn:hover {
  background: var(--primary);
  color: #041026;
}
.shift-indicator {
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.shift-badge {
  background: #0284C7;
  color: #FFF;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 14px;
}
.wheel-container {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.caesar-svg {
  width: 100%;
  height: 100%;
}

/* Morse Tool */
.morse-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.morse-play-btn {
  background: #F59E0B;
  color: #041026;
}
.morse-play-btn:hover {
  background: #FBBF24;
}
.morse-status {
  font-size: 13px;
  color: var(--text-muted);
}
.morse-symbols-box {
  background: #020617;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: monospace;
  font-size: 24px;
  color: var(--accent-gold);
  letter-spacing: 4px;
  text-align: center;
  width: 100%;
  word-break: break-all;
}

/* Pigpen Tool */
.pigpen-header {
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.pigpen-symbols-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #020617;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px;
  justify-content: center;
  width: 100%;
}
.pigpen-symbol {
  width: 50px;
  height: 50px;
}

/* Action Area & Cards */
.message-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.secret-card {
  border-color: #0284C7;
  box-shadow: 0 0 15px rgba(2, 132, 199, 0.2);
}
.card-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}
.encrypted-text-tokens {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--primary);
  text-align: center;
  padding: 8px 0;
  word-break: break-all;
}

.input-row {
  display: flex;
  gap: 8px;
}
.cipher-input {
  flex: 1;
  background: #020617;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 800;
  color: #FFF;
  text-transform: uppercase;
  letter-spacing: 3px;
  outline: none;
  transition: border-color 0.2s;
}
.cipher-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}
.clear-btn {
  background: var(--bg-card-light);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  font-size: 18px;
  cursor: pointer;
}
.clear-btn:hover { color: #FFF; background: #334155; }
.submit-row {
  display: flex;
}
.check-btn {
  width: 100%;
}

/* Spy Virtual Keyboard */
.spy-keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 12px;
  justify-content: center;
}
.key-btn {
  background: var(--bg-card-light);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 800;
  width: 36px;
  height: 42px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}
.key-btn:hover {
  background: var(--primary);
  color: #041026;
  transform: translateY(-2px);
}
.key-btn:active {
  transform: scale(0.95);
}

/* 4. Spy Laboratory (Sandbox) */
.sandbox-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
}
@media (max-width: 800px) {
  .sandbox-container { grid-template-columns: 1fr; }
}
.sandbox-controls, .sandbox-results {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sandbox-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}
.cipher-select-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cipher-tab {
  background: var(--bg-card-light);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.cipher-tab.active {
  background: var(--primary);
  color: #041026;
  border-color: var(--primary);
}
.sandbox-shift-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sandbox-shift-row input[type="range"] {
  flex: 1;
}
.sandbox-output-display {
  background: #020617;
  border: 2px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 4px;
  text-align: center;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-all;
}

/* 5. Diploma Screen */
.diploma-wrapper {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}
.diploma-card {
  width: 100%;
  max-width: 680px;
  background: #0F172A;
  border: 4px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.diploma-border {
  border: 2px dashed #475569;
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.diploma-seal { font-size: 54px; }
.diploma-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 2px;
}
.diploma-badge {
  background: #0284C7;
  color: #FFF;
  padding: 6px 16px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 3px;
  align-self: center;
}
.diploma-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}
.diploma-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 340px;
  margin: 0 auto;
}
.diploma-input {
  background: #020617;
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 18px;
  font-weight: 800;
  color: #FFF;
  text-align: center;
}
.diploma-meta {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--border-card);
  padding-top: 16px;
  font-size: 13px;
}
.meta-label { color: var(--text-muted); margin-right: 4px; }
.meta-value { color: var(--accent-gold); font-weight: 700; }
.diploma-signature {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.sig-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.sig-mascot { width: 50px; height: 50px; }
.sig-title { font-weight: 800; font-size: 13px; color: var(--primary); }
.sig-sub { font-size: 11px; color: var(--text-muted); }
.sig-seal-mark {
  border: 2px solid #EF4444;
  color: #EF4444;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  transform: rotate(-10deg);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 24, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal.hidden { display: none !important; }
.modal-card {
  background: var(--bg-card);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,0.8);
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.modal-icon { font-size: 56px; margin-bottom: 8px; }
.modal-title { font-size: 24px; font-weight: 900; color: #FFF; margin-bottom: 6px; }
.modal-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.modal-stars { font-size: 32px; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* Confetti particles */
.confetti-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  animation: popOut 1.2s forwards cubic-bezier(0.1, 0.8, 0.3, 1);
}
@keyframes popOut {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

/* Print Styles */
@media print {
  body { background: #FFF; color: #000; }
  .app-header, .screen-header, .speed-guard-banner { display: none !important; }
  .screen:not(.diploma-screen) { display: none !important; }
  .diploma-screen { display: block !important; padding: 0; }
  .diploma-card { border-color: #000; max-width: 100%; box-shadow: none; background: #FFF; }
  .diploma-border { border-color: #000; }
  .diploma-title { color: #000; }
  .diploma-input { border-bottom: 2px solid #000; color: #000; background: transparent; }
}
/* Γενικό κρύψιμο (η μπάρα συμβουλών και το κουτί βοήθειας δεν είχαν δικό τους κανόνα) */
.hidden { display: none !important; }

/* Πίνακες-κλειδιά (Μορς, Pigpen, Atbash, αριθμοί) */
.key-title { font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.key-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.key-cell {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 46px; padding: 4px 6px; border-radius: 8px;
  background: #020617; border: 1px solid var(--border-card);
}
.key-cell b { font-size: 15px; color: #F8FAFC; }
.key-cell code { font-size: 13px; color: var(--accent-gold); letter-spacing: 1px; }
.key-cell .pigpen-symbol { width: 30px; height: 30px; }

/* Κινητά: οι στήλες δεν πρέπει να φαρδαίνουν από τον τροχό/τους πίνακες (οριζόντια κύλιση) */
.cipher-workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 840px) {
  .cipher-workspace { grid-template-columns: minmax(0, 1fr); }
}
.cipher-tool-area, .cipher-action-area, .tool-view { min-width: 0; }
.morse-top { flex-wrap: wrap; justify-content: center; }
@media (max-width: 600px) {
  .game-topbar { flex-wrap: wrap; justify-content: space-between; gap: 10px; }
  .game-topbar .mission-info { order: -1; flex: 1 1 100%; }
  .game-top-actions { display: flex; gap: 8px; }
}
