*{box-sizing:border-box}html,body{margin:0;font-family:Arial,sans-serif;background:#f4f6fa;color:#18212b}header{padding:18px 26px;background:linear-gradient(100deg,#fff3e9,#eef5ff)}.brand{font-size:32px}.brand small{display:block;font-size:13px;font-weight:normal;margin-top:3px}nav{padding:10px 24px;background:linear-gradient(90deg,#7038ee,#d52d77,#ff7a18)}nav a{color:#fff;text-decoration:none;font-weight:bold;margin-right:22px}main{max-width:1280px;margin:18px auto;padding:0 14px}section,article,.panel{background:#fff;border-radius:18px;padding:20px;margin-bottom:16px;box-shadow:0 5px 18px #00000012}.hero{text-align:center}.cols{display:grid;grid-template-columns:1fr 1fr;gap:18px}.ico{font-size:44px}.login{max-width:520px;margin:55px auto}.gridform{display:grid;grid-template-columns:repeat(2,1fr);gap:12px 16px}.section-head{display:flex;justify-content:space-between;align-items:center;gap:20px}.check{display:flex;align-items:center;gap:8px}.check input{width:auto}label{font-weight:bold}input,select,textarea{width:100%;padding:9px 10px;border:1px solid #cbd3dc;border-radius:8px;margin-top:4px;background:#fff}button,.btn{display:inline-block;border:0;border-radius:9px;padding:10px 15px;background:#7138eb;color:#fff;font-weight:bold;text-decoration:none;cursor:pointer}.dark{background:#50545a}.danger{background:#c92d3d}.start{font-size:19px;background:#d11f3d}.flash{background:#fff1c9;padding:11px;border-radius:9px;margin-bottom:11px}table{width:100%;border-collapse:collapse}th,td{padding:9px;border-bottom:1px solid #e5e7eb;text-align:left}.actions{display:flex;gap:8px;flex-wrap:wrap}.actions form{margin:0}.inline-create{display:flex;gap:10px}.inline-create input{margin:0}.pair-table{border:1px solid #e2e5e9;border-radius:12px;overflow:hidden}.pair-row{display:grid;grid-template-columns:42px minmax(180px,1fr) 32px minmax(180px,1fr) 80px minmax(130px,.8fr);gap:7px;align-items:center;padding:7px;border-bottom:1px solid #eceef1}.pair-row:last-child{border-bottom:0}.pair-head{background:#f5f0ff}.pair-row input,.pair-row select{margin:2px 0;padding:7px}.arrow{text-align:center;font-size:20px;font-weight:bold}.thumb{max-width:72px;max-height:48px;object-fit:contain;border:1px solid #ddd;border-radius:6px;margin-top:4px}.image-input{font-size:12px}.save-all{margin-top:14px;background:#147a45}.setup-cols{grid-template-columns:minmax(280px,.7fr) minmax(600px,1.6fr)}.people-list{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}.people-list span{background:#edf0f5;padding:6px 9px;border-radius:999px}.hint{font-size:13px;color:#59636f}.compact-pairs{max-height:570px;overflow:auto}.start-wrap{display:flex;align-items:center;gap:16px;margin-top:14px}.start-wrap p{margin:0;color:#59636f}
.game-page{height:100vh;overflow:hidden}.game-page header{padding:9px 20px}.game-page .brand{font-size:25px}.game-page .brand small{font-size:11px}.game-page nav{padding:7px 20px}.game-page main{height:calc(100vh - 93px);margin:8px auto;padding:0 10px;max-width:1500px}.presentation main{height:calc(100vh - 54px);margin:6px auto}.game-panel{height:100%;margin:0;padding:10px 14px;display:flex;flex-direction:column;overflow:hidden}.gamehead{display:flex;justify-content:space-between;align-items:center;min-height:48px}.gamehead h1{margin:0;font-size:22px}.gamehead p{margin:2px 0;font-size:12px}.turnbox{text-align:right}#turn{font-size:20px}#timer{font-size:27px;font-weight:bold;color:#c51f38}.board{flex:1;min-height:0;display:grid;grid-template-columns:repeat(6,1fr);grid-template-rows:repeat(5,1fr);gap:7px;margin:7px 0}.tile{min-height:0;border-radius:12px;background:linear-gradient(145deg,#6e38e8,#d82b75);color:#fff;display:flex;align-items:center;justify-content:center;text-align:center;padding:6px;font-size:clamp(20px,3vh,31px);font-weight:bold;cursor:pointer;box-shadow:0 3px 7px #0002;overflow:hidden}.tile.open{background:#fff;color:#18212b;border:3px solid #ffac1c;font-size:clamp(12px,1.65vh,18px)}.tile.matched{background:#d9f5df;color:#17652d;border:3px solid #49a862;font-size:clamp(12px,1.65vh,18px)}.tile.special{background:linear-gradient(145deg,#ffb000,#ff6b00);color:#fff;border:3px solid #ffe19c;font-size:clamp(14px,2vh,21px)}.tile img{width:100%;height:100%;object-fit:contain;max-height:100%;border-radius:7px}.msg{height:31px;min-height:31px;text-align:center;font-size:18px;font-weight:bold;color:#b51d37;display:flex;align-items:center;justify-content:center}.scorebar{display:flex;justify-content:space-between;align-items:center;gap:10px;min-height:42px}.scores{display:flex;gap:5px;flex-wrap:wrap;max-height:42px;overflow:auto}.score{display:inline-block;background:#e9edf2;border-radius:8px;padding:5px 8px;font-size:12px}.presentation .scores{justify-content:center}.presentation .game-panel{padding:8px 12px}
@media(max-width:900px){.cols,.gridform,.setup-cols{grid-template-columns:1fr}.pair-row{grid-template-columns:34px 1fr 26px 1fr 64px 100px}.game-page{overflow:auto;height:auto}.game-page main,.presentation main{height:auto}.game-panel{height:auto}.board{grid-template-columns:repeat(5,1fr);grid-template-rows:auto}.tile{min-height:80px}.compact-pairs{max-height:none}}

.environment-cards a.env-card{display:block;background:#fff;border-radius:18px;padding:26px;color:#18212b;text-decoration:none;box-shadow:0 5px 18px #00000010;transition:.18s transform,.18s box-shadow;border:2px solid transparent}
.environment-cards a.env-card:hover{transform:translateY(-3px);box-shadow:0 10px 24px #00000018}
.environment-cards a.env-card.empresa{border-color:#ffb4bd}
.environment-cards a.env-card.familia{border-color:#9bd7ff}
.environment-cards .enter{display:inline-block;margin-top:12px;font-weight:800;color:#6e38e8}
.environment-selected{max-width:760px;margin:45px auto;text-align:center}
.environment-selected .ico{font-size:64px}
.env-actions{display:flex;gap:14px;justify-content:center;align-items:center;flex-wrap:wrap;margin-top:24px}
.big-btn{display:inline-block;padding:14px 20px;border-radius:10px;background:#6e38e8;color:#fff;text-decoration:none;font-weight:800}
.big-btn.secondary{background:#4d5156}
.text-link{display:inline-block;padding:12px;color:#4b5563;text-decoration:none;font-weight:700}
.mode-badge{padding:11px 12px;margin-top:6px;border-radius:8px;background:#eef1f5;font-weight:800}

/* V1.2 - administración más compacta */
body:not(.game-page) header{padding:11px 22px}body:not(.game-page) .brand{font-size:27px}body:not(.game-page) nav{padding:8px 20px}body:not(.game-page) main{margin:10px auto}body:not(.game-page) section,body:not(.game-page) article,body:not(.game-page) .panel{padding:14px 16px;margin-bottom:10px}body:not(.game-page) h1{margin:5px 0 8px;font-size:25px}body:not(.game-page) h2{margin:5px 0 8px}body:not(.game-page) p{margin:5px 0 9px}body:not(.game-page) input,body:not(.game-page) select,body:not(.game-page) textarea{padding:6px 8px}body:not(.game-page) button,body:not(.game-page) .btn{padding:7px 11px}.pair-row{padding:4px 6px;gap:5px}.pair-row input,.pair-row select{padding:5px 6px;margin:1px 0}.pair-table{font-size:14px}.thumb{max-height:38px}.save-all{position:sticky;bottom:8px;z-index:3;box-shadow:0 3px 12px #0003}.compact-pairs{max-height:490px}
.final-overlay{display:none;position:fixed;inset:0;background:#111827b8;z-index:1000;align-items:center;justify-content:center;padding:20px}.final-overlay.show{display:flex}.final-card{width:min(560px,92vw);max-height:88vh;overflow:auto;background:#fff;border-radius:22px;padding:22px;text-align:center;box-shadow:0 20px 60px #0007;border:4px solid #f5b51b}.final-card h2{font-size:28px;margin:8px 0 15px;color:#a71935}.confetti{font-size:34px}.final-ranking{display:grid;gap:6px;margin:10px auto 16px;max-width:430px}.rank-row{display:flex;justify-content:space-between;gap:15px;background:#f1f4f8;border-radius:9px;padding:8px 11px}.rank-row:first-child{background:#fff0b8;font-size:18px}

/* V1.3 - Identidad Cristacryl, seguridad y estadísticas */
.brand-wrap{display:flex;align-items:center;justify-content:space-between;gap:20px}.company-logo{height:62px;max-width:280px;object-fit:contain}.env-logo{height:76px;max-width:300px;object-fit:contain;margin-bottom:6px}.mode-empresa header{background:#fff}.mode-empresa nav{background:linear-gradient(90deg,#111 0%,#111 34%,#bd1622 68%,#e42b37 100%)}.mode-empresa nav a{color:#fff}.mode-empresa .btn,.mode-empresa button,.mode-empresa .big-btn{background:#bd1622}.mode-empresa .dark,.mode-empresa .big-btn.secondary{background:#171717}.mode-empresa .env-card.empresa{border-color:#bd1622}.mode-empresa .enter{color:#bd1622}.mode-empresa .tile{background:linear-gradient(145deg,#171717,#bd1622)}.mode-empresa .tile.special{background:linear-gradient(145deg,#e6a500,#f56d00)}.mode-empresa .final-card{border-color:#bd1622}.mode-empresa .final-card h2{color:#bd1622}.mode-empresa .stats-btn{background:#171717}.nav-right{float:right;margin-right:0!important;font-size:13px;opacity:.95}.login:before{content:'🔒 Acceso protegido';display:inline-block;background:#e7f5ec;color:#11613b;padding:5px 9px;border-radius:999px;font-weight:700;margin-bottom:8px}.stats-head{display:flex;justify-content:space-between;align-items:end;gap:18px}.mode-filter{min-width:190px}.stats-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:9px;margin-bottom:10px}.stats-grid>div{background:#eef1f5;border-radius:10px;padding:10px 12px;display:flex;justify-content:space-between;gap:10px;align-items:center}.stats-grid b{font-size:21px}.mini{padding:5px 8px;font-size:12px}.protected{font-size:12px;color:#996b00;background:#fff1c4;padding:5px 8px;border-radius:999px}.mode-empresa .stats-grid>div{border-left:4px solid #bd1622}.mode-empresa .rank-row:first-child{background:#ffe6e8}.game-page .company-logo{height:48px}.game-page.mode-empresa header{padding:7px 20px}.game-page.mode-empresa main{height:calc(100vh - 88px)}
@media(max-width:1000px){.stats-grid{grid-template-columns:repeat(3,1fr)}.company-logo{height:48px;max-width:210px}.stats-head{align-items:flex-start}}
@media(max-width:650px){.stats-grid{grid-template-columns:1fr 1fr}.brand-wrap{align-items:flex-start}.company-logo{height:38px;max-width:150px}.nav-right{float:none}.stats-head{display:block}}


/* V1.4 - mejoras de visualizacion y cierre de partida */
.environment-cards .env-logo{height:118px;max-width:390px;margin:0 0 8px}
.environment-selected .env-logo{height:128px;max-width:430px;margin:0 auto 8px}
.mode-empresa .company-logo{height:78px;max-width:340px}
.game-page.mode-empresa .company-logo{height:58px;max-width:260px}

.setup-panel{padding-top:10px!important}
.setup-top{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:8px;border-bottom:1px solid #e7e9ed;padding-bottom:8px}
.setup-top h1{margin:0!important}.setup-top p{margin:3px 0 0!important}
.setup-actions{display:flex;align-items:center;gap:9px;flex-wrap:wrap}.setup-actions form{margin:0}.setup-actions button{white-space:nowrap}
.save-top{background:#147a45!important}.setup-cols{align-items:start}.setup-cols textarea{max-height:118px}.setup-cols h2{font-size:20px!important}
.compact-pairs{max-height:455px}.save-all{margin-top:8px}.start-note{font-size:12px;color:#59636f;text-align:right;margin-top:5px}

/* Categorias mas compactas */
body:not(.game-page) .section-head{gap:10px}.section-head h1{margin-bottom:2px!important}.section-head p{font-size:13px;margin:2px 0!important}
.inline-create{margin-top:6px}.inline-create input{height:36px}.inline-create button{padding:5px 11px!important}
body:not(.game-page) table th,body:not(.game-page) table td{padding:5px 8px}
body:not(.game-page) .actions{gap:5px}.actions .btn,.actions button{padding:5px 9px!important;font-size:13px}

/* Celebracion final */
.final-overlay{background:radial-gradient(circle at center,#1c2434dd,#05070beF)}
.final-card{position:relative;overflow:hidden;width:min(650px,94vw);padding:28px 28px 24px;border-width:5px;animation:celebratePop .45s ease-out}
.final-card:before,.final-card:after{content:'🎊  ✨  🎉  ✨  🎊';position:absolute;left:0;right:0;font-size:25px;letter-spacing:12px;animation:confettiFloat 2.2s ease-in-out infinite;pointer-events:none}
.final-card:before{top:8px}.final-card:after{bottom:8px;transform:rotate(180deg)}
.final-card .confetti{font-size:46px;margin-top:14px;animation:trophyPulse 1s ease-in-out infinite alternate}
.final-card h2{font-size:32px;text-transform:uppercase;margin:10px 0 16px}
.final-ranking{position:relative;z-index:1}.rank-row{font-size:16px}.rank-row:first-child{font-size:21px;font-weight:800;border:2px solid #e1b21e}
.final-actions{position:relative;z-index:2;display:flex;justify-content:center;gap:9px;flex-wrap:wrap;margin-top:18px}
.final-actions .btn,.final-actions button{padding:10px 14px}.celebration-new{background:#16864a!important}
@keyframes celebratePop{from{opacity:0;transform:scale(.82) translateY(18px)}to{opacity:1;transform:scale(1) translateY(0)}}
@keyframes trophyPulse{from{transform:scale(1)}to{transform:scale(1.12)}}
@keyframes confettiFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(7px)}}

@media(max-width:900px){.setup-top{align-items:flex-start;flex-direction:column}.setup-actions{width:100%}.environment-cards .env-logo,.environment-selected .env-logo{height:92px;max-width:300px}}

/* V1.5 - Seguridad, celebracion sonora y responsive movil */
.security-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-top:12px}.security-card{background:#f8fafc;border:1px solid #dde3ea;border-radius:14px;padding:16px}.security-card h2{margin:0 0 4px}.security-card p{font-size:13px;color:#5d6672;margin:4px 0 10px}.security-card button{width:100%;margin-top:4px}
@media(max-width:760px){
  html,body{max-width:100%;overflow-x:hidden}
  body:not(.game-page) header{padding:8px 12px}.brand-wrap{gap:8px;align-items:center}.brand{font-size:23px!important;line-height:1.05}.brand small{font-size:11px}.company-logo{height:42px!important;max-width:145px!important}
  nav{display:flex;gap:4px;overflow-x:auto;white-space:nowrap;padding:7px 9px!important;-webkit-overflow-scrolling:touch}nav a{margin:0!important;padding:6px 8px;border-radius:7px;font-size:12px;flex:0 0 auto}.nav-right{float:none!important}
  main{width:100%;padding:0 8px!important;margin:7px auto!important}section,article,.panel{border-radius:12px!important;padding:11px!important}
  .environment-cards{grid-template-columns:1fr!important;gap:10px!important}.environment-cards a.env-card{padding:14px!important}.environment-cards .env-logo,.environment-selected .env-logo{height:78px!important;max-width:240px!important}
  .cols,.gridform,.setup-cols,.security-grid{grid-template-columns:1fr!important;gap:9px!important}.setup-top{gap:7px}.setup-actions{display:grid!important;grid-template-columns:1fr 1fr;width:100%}.setup-actions form,.setup-actions button,.setup-actions .btn{width:100%}.start-note{text-align:left}
  .pair-row{grid-template-columns:28px 1fr 22px 1fr!important;gap:4px!important}.pair-row .points,.pair-row .prize,.pair-row input[type=file]{grid-column:2/5}.compact-pairs{max-height:none!important}
  table{font-size:12px;min-width:620px}section.panel{overflow-x:auto}.actions{flex-wrap:wrap}
  .stats-grid{grid-template-columns:1fr 1fr!important}.stats-head{display:block!important}.mode-filter{min-width:0;width:100%}
  .game-page header{padding:5px 8px!important}.game-page .brand{font-size:19px!important}.game-page .company-logo{height:34px!important;max-width:120px!important}.game-page nav{display:none}.game-page main,.presentation main{height:auto!important;min-height:calc(100vh - 58px);padding:4px 6px!important;margin:0 auto!important}.game-panel{height:auto!important;padding:7px!important;overflow:visible!important}.gamehead{gap:6px}.gamehead h1{font-size:17px!important;margin:0}.gamehead p{font-size:11px}.turnbox{max-width:48%}#turn{font-size:14px!important}#timer{font-size:21px!important}
  .board{grid-template-columns:repeat(5,1fr)!important;grid-template-rows:none!important;gap:5px!important;margin:5px 0!important}.tile{min-height:60px!important;aspect-ratio:1/1;font-size:clamp(16px,5vw,23px)!important;border-radius:9px!important;padding:3px!important}.tile.open,.tile.matched{font-size:clamp(9px,2.9vw,13px)!important}.tile.special{font-size:clamp(10px,3vw,14px)!important}.tile img{object-fit:contain}
  .msg{height:auto!important;min-height:27px!important;font-size:14px!important;padding:3px}.scorebar{flex-direction:column;align-items:stretch;gap:5px}.scorebar>.btn{width:100%;text-align:center}.scores{max-height:none!important;gap:3px}.score{font-size:10px!important;padding:4px 6px!important}
  .final-overlay{padding:8px}.final-card{width:98vw!important;max-height:94vh!important;padding:18px 12px!important;border-radius:15px!important}.final-card h2{font-size:23px!important}.final-card .confetti{font-size:34px!important}.rank-row{font-size:13px!important;padding:6px 8px!important}.rank-row:first-child{font-size:16px!important}.final-actions{display:grid!important;grid-template-columns:1fr 1fr}.final-actions>*{width:100%;text-align:center}
  .security-card{padding:12px}.security-card input{font-size:16px}
}
@media(max-width:390px){.board{grid-template-columns:repeat(5,1fr)!important}.tile{min-height:54px!important}.stats-grid{grid-template-columns:1fr!important}.setup-actions{grid-template-columns:1fr!important}.final-actions{grid-template-columns:1fr!important}.company-logo{max-width:115px!important}}

/* V1.5.1 - contraste reforzado en tarjetas reveladas */
.tile.open{background:#8f1622!important;color:#fff!important;border-color:#ffac1c!important;font-weight:800;text-shadow:0 1px 2px #0008}
.tile.open span{color:#fff!important}
.tile.matched{background:#d9f5df!important;color:#145b29!important;font-weight:800;text-shadow:none}
.tile.matched span{color:#145b29!important}
.mode-empresa .tile.open{background:linear-gradient(145deg,#6f1019,#bd1622)!important;color:#fff!important}
.mode-empresa .tile.open span{color:#fff!important}
.presentation .tile.open{color:#fff!important}
@media(max-width:900px){.tile.open{font-weight:800!important;color:#fff!important}.tile.open span{color:#fff!important}}


/* V1.5.2 - logo Cristacryl visible y contraste definitivo */
.mode-empresa .company-logo{
  width:290px!important;
  height:72px!important;
  max-width:290px!important;
  object-fit:cover!important;
  object-position:center!important;
}
.environment-cards .env-logo{
  width:260px!important;
  height:90px!important;
  max-width:260px!important;
  object-fit:cover!important;
  object-position:center!important;
}
.environment-selected .env-logo{
  width:330px!important;
  height:104px!important;
  max-width:330px!important;
  object-fit:cover!important;
  object-position:center!important;
}
.game-page.mode-empresa .company-logo{
  width:235px!important;
  height:58px!important;
  max-width:235px!important;
  object-fit:cover!important;
  object-position:center!important;
}
.tile.open,.mode-empresa .tile.open,.mode-familia .tile.open,.presentation .tile.open{
  background:#861620!important;
  color:#fff!important;
  border:3px solid #ffb11b!important;
  font-weight:900!important;
  text-shadow:0 1px 2px rgba(0,0,0,.65)!important;
}
.tile.open span,.mode-empresa .tile.open span,.mode-familia .tile.open span,.presentation .tile.open span{
  color:#fff!important;
  font-weight:900!important;
}
@media(max-width:900px){
  .mode-empresa .company-logo{width:190px!important;height:50px!important;max-width:190px!important}
  .game-page.mode-empresa .company-logo{width:155px!important;height:42px!important;max-width:155px!important}
  .environment-cards .env-logo{width:230px!important;height:78px!important;max-width:230px!important}
  .environment-selected .env-logo{width:260px!important;height:86px!important;max-width:260px!important}
}
@media(max-width:390px){
  .mode-empresa .company-logo{width:150px!important;height:42px!important;max-width:150px!important}
  .game-page.mode-empresa .company-logo{width:125px!important;height:36px!important;max-width:125px!important}
}


/* V1.5.4 - margen inferior seguro para controles del juego */
.game-page .scorebar{
  margin-bottom:16px!important;
  padding-bottom:2px!important;
  flex:0 0 auto!important;
}
.game-page .board{
  margin-bottom:5px!important;
}
.game-page .msg{
  flex:0 0 auto!important;
}
@media(max-height:820px) and (min-width:901px){
  .game-page .scorebar{margin-bottom:18px!important}
  .game-page .board{gap:6px!important;margin-top:5px!important;margin-bottom:4px!important}
}
@media(max-width:900px){
  .game-page .scorebar{margin-bottom:12px!important;padding-bottom:4px!important}
}
