/* ===== Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;800;900&display=swap');

:root{
  --bg: #f6f7fb;
  --surface: rgba(255, 255, 255, 0.90);
  --surface-strong: #F5F5F5;

  --text: #111827;
  --muted: rgba(17, 24, 39, 0.72);
  --muted-2: rgba(17, 24, 39, 0.55);

  --brand: #04AA6D;
  --danger: #e11d48;

  --border: rgba(17, 24, 39, 0.12);
  --shadow-sm: 0 4px 14px rgba(17, 24, 39, 0.10);
  --shadow-md: 0 10px 28px rgba(17, 24, 39, 0.16);

  --r-lg: 16px;
  --r-xl: 20px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --container-max: 760px;
  
  --modal-secondary: #063a51;
}

/* ===== Reset ===== */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body{
  font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  margin: 0;
  padding: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 15% 0%, rgba(4,170,109,0.10), transparent 55%),
    radial-gradient(900px 600px at 100% 20%, rgba(17,24,39,0.08), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, optgroup, select, textarea {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

@media (prefers-reduced-motion: reduce){
  *{
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Layout ===== */
.main-container{
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(14px + var(--safe-top)) 12px calc(18px + var(--safe-bottom));
}

#instruction,
#canvas-container{
  width: 100%;
  max-width: var(--container-max);
}


#instruction p{ 
  margin: 10px 0; 
  text-align: center;
}

/* ===== Instruction image (bigger) ===== */
#imagen{
  width: min(680px, 96%);
  max-width: 96%;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.75);
  margin: 0 auto;
}

/* ===== Text output ===== */
#msg, #log{
  font-size: 18px;
  font-weight: 800;
  color: rgb(18, 145, 60);
  text-align: center;
  margin-top: 6px;
  letter-spacing: 0.2px;
}

#log{
  color: rgba(17, 24, 39, 0.82);
  font-weight: 700;
}

/* ===== Buttons ===== */
.btn-styles{
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(180deg, rgba(4,170,109,1), rgba(3,150,96,1));
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 14px 28px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  /* Aseguramos la fuente aquí también explícitamente */
  font-family: 'Poppins', sans-serif;
  font-size: 15px;
  font-weight: 700; /* Ajustado para Poppins (900 es muy grueso, 700/800 suele verse mejor) */
  letter-spacing: 0.4px;
  
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 30px rgba(4,170,109,0.25), 0 4px 12px rgba(17,24,39,0.14);
  text-decoration: none;
}

.btn-styles:hover{
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.btn-styles:active{
  transform: translateY(0) scale(0.99);
}

#modal-controls button[style*="background-color: red"]{
  background: linear-gradient(180deg, rgba(225,29,72,1), rgba(190,18,60,1)) !important;
  box-shadow: 0 8px 20px rgba(225,29,72,0.20), 0 4px 10px rgba(17,24,39,0.12);
}

/* ===== Canvas ===== */
.canvas-wrapper{
  position: relative;
  width: 360px;
  max-width: 100%;
  margin: 0 auto;
  border-radius: var(--r-xl);
}

#mycanvas{
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  display: block;
  background: rgba(17,24,39,0.04);
  border: 1px solid rgba(17,24,39,0.10);
}

/* ===== Overlay cards ===== */
.overlay-container{
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 10;
  pointer-events: none;
  transition: top 0.35s ease, bottom 0.35s ease, opacity 0.2s ease, transform 0.2s ease;
}

.overlay-container.hidden{ display: none; }

.pos-top{ top: 14px; bottom: auto; }
.pos-bottom{ top: auto; bottom: 84px; }

.ui-msg{
  display: none;
  background: var(--surface-strong);
  border: 1px solid rgba(17,24,39,0.12);
  border-radius: 18px;
  padding: 16px 16px 14px;
  text-align: center;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateZ(0);
}

.ui-msg.active{ display: block; }

.card-header{
  color: rgba(17, 24, 39, 0.92);
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.card-body{
  color: rgba(17, 24, 39, 0.78);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.card-footer{
  color: rgba(17, 24, 39, 0.52);
  font-weight: 700;
  font-size: 12px;
}

/* ===== Snackbar ===== */
.snackbar,
#snackbar{
  visibility: hidden;
  min-width: 260px;
  max-width: min(92vw, 520px);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  text-align: center;
  border-radius: 14px;
  padding: 12px 16px;
  position: fixed;
  z-index: 2147483647;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 14px 36px rgba(0,0,0,0.28);
  font-size: 14px;
  line-height: 1.3;
  border: 1px solid rgba(255,255,255,0.16);
  will-change: transform, opacity;
}

.snackbar.show,
#snackbar.show{
  visibility: visible;
  animation: 
    fadein 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
    fadeout 0.5s cubic-bezier(0.16, 1, 0.3, 1) 3.9s forwards;
}

/* ===== Controls (removed) ===== */

@media (min-width: 768px){
  #imagen{ width: min(760px, 92%); }
  .main-container{
    padding: calc(18px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  }
}

@media (max-width: 767px){
  #imagen{ width: 96%; }
  .pos-bottom{ bottom: 84px; }
}

/* ===== Animations ===== */
@keyframes fadein{
  from { transform: translateX(-50%) translateY(24px) scale(0.95); opacity: 0; }
  to { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

@keyframes fadeout{
  from { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  to { transform: translateX(-50%) translateY(12px) scale(0.95); opacity: 0; }
}


.custom-modal-overlay {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.custom-modal-content {
    background-color: #fefefe;
    padding: 30px;
    border-radius: 25px;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    animation: modalSlideDown 0.3s ease-out;
}

@keyframes modalSlideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.custom-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}

.center-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    width: 100%;
}

.mt-20 {
    margin-top: 20px;
}


.resultado-tabla {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 1rem;
    color: var(--text);
    border: 1px solid #ddd;
}

.resultado-tabla td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.resultado-tabla tr:last-child td {
    border-bottom: none;
}

.resultado-tabla .label {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--modal-secondary);
    text-align: left;
    background-color: #f9f9f9;
    width: 50%;
}

.resultado-tabla .valor {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    text-align: right;
    width: 50%;
}