:root{
  --glass: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.18);
  --neon1:#6cf;
  --neon2:#c6f;
}

body{
  margin:0;
  font-family:sans-serif;
  background:radial-gradient(circle at top,#1b1f3b,#0b0d1a);
  color:#fff;
  overflow-x:hidden;
}

/* ===== Header ===== */
.header{
  position:relative;
  height:220px;
  text-align:center;
  overflow:hidden;
}

#p5-header{
  position:absolute;
  inset:0;
}

.header h1{
  position:relative;
  z-index:2;
  padding-top:80px;
  font-size:30px;
}

/* ===== Grid ===== */
.container{
  padding:24px;
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:20px;
}

.box.selected{
  outline:2px solid #4fc3ff;
  background:rgba(79,195,255,0.2);
}

.canvas-panel{
  position: relative;
}

.reset-btn{
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  margin-top: 230px;
  margin-right: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  backdrop-filter: blur(4px);

  transition: all 0.2s ease;
}

.reset-btn:hover{
  background: rgba(255,80,80,0.85);
  transform: scale(1.05);
}


@media(max-width:1024px){
  .container{grid-template-columns:repeat(2,1fr)}
}

@media(max-width:640px){
  .container{grid-template-columns:1fr}
}

/* ===== Card ===== */
.exercise.expanded {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  width: 90% !important;
  max-width: 960px !important;
  height: auto !important;
  max-height: 90vh !important;
  margin-right: 15% !important; 
  margin-top: -45vh !important;   /* نصف ارتفاع فعلی به بالا - دینامیک و دقیق */
  z-index: 1001 !important;
  background: rgba(8, 10, 25, 0.98) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  border-radius: 18px !important;
  padding: 28px !important;
  box-sizing: border-box !important;
}

/* ===== Card - جدا شدن بهتر از پس‌زمینه حتی بدون hover ===== */
.exercise {
  position: relative;
  background: rgba(255, 255, 255, 0.08) !important;  /* همان شیشه‌ای قبلی */
  border: 1px solid rgba(255, 255, 255, 0.25) !important;  /* بوردر روشن‌تر و قوی‌تر برای جداسازی */
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(16px) !important;  /* مات کردن قوی‌تر پس‌زمینه پشت کارت */
  box-shadow: 
    0 8px 25px rgba(32, 7, 123, 0.4),           /* سایه عمیق‌تر در حالت عادی */
    0 0 15px rgba(245, 7, 209, 0.15) !important;  /* گلو نئونی آبی ملایم دور کارت */
  cursor: pointer;
  transition: all 0.3s ease !important;
}

/* وقتی hover می‌کنی، قوی‌تر بشه (مثل الان اما بهتر) */
.exercise:hover {
  transform: translateY(-10px) !important;  /* بلند شدن بیشتر */
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.6),
    0 0 25px rgba(244, 2, 204, 0.4) !important;  /* گلو نئونی قوی‌تر */
  border-color: rgba(241, 6, 217, 0.5) !important;
  background: rgba(255, 255, 255, 0.12) !important;  /* کمی روشن‌تر در hover */
}

.exercise.expanded .content-box,
.exercise.expanded .instruction,
.exercise.expanded .answer,
.exercise.expanded .result-panel,
.exercise.expanded h2{
  font-size:16px;
  margin-bottom:12px;
}

exercise.expanded {
  font-size:18px;
}

.exercise.expanded h2 {
  font-size:28px;
  text-align:center;
  margin-bottom:20px;
}

.exercise.expanded .content-box {
  font-size:19px;
  padding:20px;
  height:auto;
  min-height:150px;
}

.exercise.expanded .instruction {
  font-size:17px;
}

.exercise.expanded .answer {
  font-size:17px;
  padding:15px;
  background:rgba(0,0,0,0.3);
  border-radius:10px;
}

/* برای تمرین 1 که ساختار متفاوتی دارد (باکس‌ها و canvas) */
.exercise.expanded .main-panel {
  direction:rtl;
}

.exercise.expanded .boxes-panel .box {
  font-size:16px;
}

.content-box{
  height:120px;
  border-radius:14px;
  background:rgba(0,0,0,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  color:#aaa;
  margin-bottom:12px;
}

.answer-btn{
  width:100%;
  padding:10px;
  border-radius:14px;
  border:none;
  background:linear-gradient(135deg,var(--neon1),var(--neon2));
  color:#000;
  font-weight:bold;
}

.answer{display:none;margin-top:10px}

/* ===== Expanded ===== */
.exercise.expanded{
  position:fixed;
  inset:40px;
  z-index:1001;
  transform:none;
  background:rgba(15,18,40,.95);
  overflow:auto;
}

.overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.6);
  backdrop-filter:blur(4px);
  z-index:1000;
  display:none;
}

.overlay.active{display:block}

.close-btn{
  position:sticky;
  top:0;
  margin-bottom:12px;
  width:36px;
  height:36px;
  border-radius:50%;
  border:none;
  background:rgba(255,255,255,.15);
  color:#fff;
  font-size:18px;
  cursor:pointer;
  display:none;
}

.instruction{
  background:rgba(0,0,0,.3);
  border-radius:10px;
  padding:12px;
  margin-bottom:12px;
  color:#cfe8ff;
  font-size:14px;
}

.main-panel{
  display:flex;
  gap:20px;
  margin-bottom:12px;
}

.canvas-panel{
  flex:1.4;
  background:rgba(0,0,0,.35);
  border-radius:14px;
  padding:12px;
}

.boxes-panel{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.box{
  flex:1;
  border:2px dashed #88a;
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#ccd;
  font-size:14px;
}

.result-panel{
  margin-top:12px;
}


.exercise.expanded .close-btn{display:block}
