/* ═══════════════════════════════════════════════════════════
   İNGİLİZCE ÇARPRAZ BULMACA — style.css
═══════════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --paper:       #f7f3ea;
  --paper-dark:  #ede7d4;
  --paper-aged:  #e8dfc8;
  --ink:         #1a1208;
  --ink-light:   #4a3a28;
  --ink-faint:   #8a7a68;
  --line:        rgba(100, 130, 180, .15);
  --red-pen:     #b83232;
  --blue-pen:    #1a3f88;
  --shadow:      rgba(60, 40, 20, .2);

  /* Grid cell size — overridden by JS */
  --cs: 38px;
  --gc: 13;

  /* Cell square style */
  --cell-bg:     #fffef9;
  --cell-border: rgba(100, 80, 50, .22);
  --cell-found:  #d4f0d4;
}

html, body { height: 100%; }

body {
  font-family: 'Patrick Hand', cursive;
  background: var(--paper)
    repeating-linear-gradient(transparent, transparent 27px, var(--line) 27px, var(--line) 28px);
  color: var(--ink);
  overflow-x: hidden;
  user-select: none;
}

/* ── CANVASES ── */
#bgCanvas { display: none; }
#fxCanvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 100;
}

/* ── SCREENS ── */
.screen {
  position: relative; z-index: 10;
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px;
}
.screen.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════
   INTRO
══════════════════════════════════════════════════════════ */
.logo-wrap {
  text-align: center;
  margin-bottom: 6px;
  position: relative;
}
.logo-en {
  font-family: 'Caveat', cursive;
  font-size: clamp(2.8rem, 8vw, 5.2rem);
  font-weight: 700; line-height: 1.1;
  color: var(--ink);
  text-shadow: 2px 2px 0 rgba(255,255,255,.7);
  display: inline-block;
  transform: rotate(-1.5deg);
}
.logo-sub {
  font-family: 'Caveat', cursive;
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 700; color: var(--red-pen);
  display: block; transform: rotate(1deg);
  position: relative; margin-top: -4px;
}
.logo-sub::after {
  content: '';
  position: absolute; bottom: -4px; left: 2px; right: 2px; height: 3px;
  background: var(--red-pen); border-radius: 2px; opacity: .45;
}
.logo-pencil-line {
  margin: 14px auto 0;
  width: 75%; height: 2px;
  background: linear-gradient(to right, transparent, #2c2018 20%, #2c2018 80%, transparent);
  opacity: .18; border-radius: 2px;
}
.intro-sub {
  color: var(--ink-faint);
  font-size: clamp(.78rem, 2vw, .95rem);
  font-family: 'Patrick Hand', cursive;
  letter-spacing: 3px; text-transform: uppercase;
  margin: 18px 0 36px; text-align: center;
  border-top: 1px dashed rgba(120,95,60,.22);
  border-bottom: 1px dashed rgba(120,95,60,.22);
  padding: 8px 0;
}

/* ── CATEGORY GRID ── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 900px; width: 100%;
  margin-bottom: 36px;
}
.cat-card {
  background: var(--cc-bg);
  border: 1.5px solid var(--cc-border);
  border-radius: 4px;
  padding: 24px 14px 20px;
  cursor: pointer; text-align: center;
  position: relative; overflow: visible;
  box-shadow: 4px 6px 14px rgba(80,60,30,.18), 1px 1px 0 rgba(255,255,255,.55) inset;
  transition: transform .35s cubic-bezier(.175,.885,.32,1.275), box-shadow .3s;
}
/* tape strip */
.cat-card::before {
  content: '';
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 48px; height: 18px;
  background: rgba(200,190,160,.5);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
/* folded corner */
.cat-card::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 0; height: 0; border-style: solid;
  border-width: 0 0 16px 16px;
  border-color: transparent transparent rgba(0,0,0,.08) transparent;
}
.cat-card:hover { transform: translateY(-7px) rotate(.8deg); box-shadow: 6px 14px 26px rgba(80,60,30,.26), 1px 1px 0 rgba(255,255,255,.55) inset; }
.cat-card.sel {
  outline: 3px solid var(--cc-border);
  outline-offset: 3px;
  box-shadow: 5px 10px 22px rgba(80,60,30,.24), 1px 1px 0 rgba(255,255,255,.55) inset;
}

/* Sticky note colors per category */
.cat-card[data-cat=animals]   { --cc-bg:#fff9c4; --cc-border:#f5d700; }
.cat-card[data-cat=colors]    { --cc-bg:#e8d5f7; --cc-border:#b39ddb; }
.cat-card[data-cat=food]      { --cc-bg:#ffe0b2; --cc-border:#ffb74d; }
.cat-card[data-cat=nature]    { --cc-bg:#dcedc8; --cc-border:#aed581; }
.cat-card[data-cat=body]      { --cc-bg:#fce4ec; --cc-border:#f48fb1; }
.cat-card[data-cat=family]    { --cc-bg:#b3e5fc; --cc-border:#4fc3f7; }
.cat-card[data-cat=sports]    { --cc-bg:#ffe0e0; --cc-border:#ef9a9a; }
.cat-card[data-cat=transport] { --cc-bg:#e0f2f1; --cc-border:#80cbc4; }

.ci { font-size: 2.4rem; margin-bottom: 8px; display: block; }
.cn { font-family: 'Caveat', cursive; font-size: .9rem; font-weight: 700; color: var(--blue-pen); letter-spacing: 1px; margin-bottom: 2px; }
.ct { font-family: 'Caveat', cursive; font-size: 1.2rem; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.ck { font-family: 'Patrick Hand', cursive; font-size: .75rem; color: var(--ink-faint); }

/* ── START BUTTON ── */
.btn-main {
  font-family: 'Caveat', cursive;
  font-size: 1.35rem; font-weight: 700; letter-spacing: 2px;
  padding: 13px 56px;
  background: #1a1208; color: #f7f3ea;
  border: 2.5px solid #1a1208; border-radius: 4px;
  cursor: pointer; position: relative;
  box-shadow: 4px 5px 0 rgba(60,40,20,.35);
  transition: transform .2s, box-shadow .2s;
}
.btn-main:hover  { transform: translate(-2px,-2px); box-shadow: 6px 8px 0 rgba(60,40,20,.35); }
.btn-main:active { transform: translate(2px,2px);   box-shadow: 1px 2px 0 rgba(60,40,20,.3); }
.btn-main:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; transform: none; }

/* ══════════════════════════════════════════════════════════
   GAME SCREEN
══════════════════════════════════════════════════════════ */
#gameScreen {
  justify-content: flex-start;
  padding: 12px 12px 28px; gap: 10px;
  background: var(--paper)
    repeating-linear-gradient(transparent, transparent 27px, var(--line) 27px, var(--line) 28px);
}
#gameScreen::before {
  content: '';
  position: fixed; left: 52px; top: 0; bottom: 0; width: 2px;
  background: rgba(200, 90, 70, .18);
  pointer-events: none; z-index: 0;
}

/* ── GAME HEADER ── */
.g-hdr {
  width: 100%; max-width: 980px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: #faf6ee;
  border: 1.5px solid rgba(120,95,60,.22);
  border-radius: 4px; padding: 9px 18px;
  box-shadow: 2px 3px 8px var(--shadow);
  position: relative; z-index: 10;
}
.g-left { display: flex; align-items: center; gap: 10px; }
.back-btn {
  background: #faf6ee;
  border: 1.5px solid rgba(120,95,60,.28); border-radius: 3px;
  padding: 5px 12px; cursor: pointer; color: var(--ink-light);
  font-size: 1.05rem; font-family: 'Caveat', cursive; font-weight: 700;
  box-shadow: 2px 2px 0 rgba(80,60,30,.15); transition: all .15s;
}
.back-btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(80,60,30,.2); }
.hcat  { display: flex; align-items: center; gap: 6px; }
.hcat-icon { font-size: 1.4rem; }
.hcat-name {
  font-family: 'Caveat', cursive; font-size: 1.05rem; font-weight: 700;
  color: var(--blue-pen);
}
.g-stats { display: flex; gap: 14px; align-items: center; }
.gst { text-align: center; }
.gst-v {
  font-family: 'Caveat', cursive; font-size: 1.45rem; font-weight: 700;
  color: var(--red-pen); display: block; line-height: 1;
}
.gst-l { font-size: .6rem; color: var(--ink-faint); font-family: 'Patrick Hand', cursive; letter-spacing: 1px; }

/* Timer circle */
.tmr { position: relative; width: 50px; height: 50px; flex-shrink: 0; }
.tmr svg { transform: rotate(-90deg); }
.tc-bg { fill: none; stroke: rgba(120,95,60,.12); stroke-width: 4px; }
.tc    { fill: none; stroke: #1a1208; stroke-width: 3px; stroke-linecap: round; transition: stroke-dashoffset .6s linear; }
.tmr-txt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Caveat', cursive; font-size: .82rem; font-weight: 700;
  color: var(--ink);
}

/* ── LAYOUT ── */
.g-layout {
  width: 100%; max-width: 980px;
  display: flex; flex-wrap: wrap;
  gap: 12px; align-items: start;
  justify-content: flex-start;
  position: relative; z-index: 10;
}

/* ── GRID WRAPPER ── */
.grid-wrap {
  background: #f5f1e6;
  border: 2px solid rgba(100,80,50,.28);
  border-radius: 6px;
  padding: 0;
  box-shadow: 3px 4px 14px var(--shadow);
  position: relative; overflow: hidden;
  /* Tam hücre sayısı × hücre boyutu = kutunun genişliği */
  width:  calc(var(--gc) * var(--cs));
  height: calc(var(--gc) * var(--cs));
  flex-shrink: 0;
  align-self: flex-start;
}

/* grid-wrap'ta ::before graph paper overlay yok,
   hücre sınırları zaten ızgara çizgileri oluşturuyor */

/* ── WORD GRID ── */
#wordGrid {
  display: grid;
  grid-template-columns: repeat(var(--gc), var(--cs));
  gap: 0;
  touch-action: none;
  position: relative; z-index: 1;
}

/* ── CELL — each letter sits in a visible square ── */
.gc {
  width: var(--cs); height: var(--cs);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Kalam', cursive;
  font-size:   calc(var(--cs) * .46);
  font-weight: 700;
  color: var(--ink);
  /* Visible square with borders forming grid lines */
  background: var(--cell-bg);
  border-right:  1px solid var(--cell-border);
  border-bottom: 1px solid var(--cell-border);
  border-left: none;
  border-top: none;
  cursor: crosshair;
  transition: background .12s, color .12s;
  position: relative;
  box-sizing: border-box;
}
.gc:hover:not(.found) {
  background: rgba(255, 235, 59, .38);
  border-color: rgba(200,170,50,.5);
  transform: scale(1.06);
}
/* Dragging highlight */
.gc.hi {
  background: rgba(255, 235, 59, .70);
  border-color: rgba(220,190,30,.7);
  color: var(--ink);
  transform: scale(1.04);
}
/* Found word cells */
.gc.found {
  pointer-events: none;
  font-weight: 700;
  border-width: 2px;
}
@keyframes cellPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* selection canvas sits on top of grid */
#selCanvas {
  position: absolute; inset: 0;
  pointer-events: none; border-radius: 6px; z-index: 2;
}

/* ── WORD PANEL ── */
.wp {
  background: #fafaf5;
  border: 1.5px solid rgba(120,95,60,.2);
  border-radius: 4px; padding: 14px;
  box-shadow: 3px 4px 10px var(--shadow);
  width: 190px; min-width: 170px;
  background-image: repeating-linear-gradient(
    transparent, transparent 31px,
    rgba(100,130,180,.14) 31px, rgba(100,130,180,.14) 32px
  );
  background-position: 0 40px;
}
.wp-t {
  font-family: 'Caveat', cursive; font-size: 1rem; font-weight: 700;
  color: var(--blue-pen); text-align: center; margin-bottom: 10px;
  border-bottom: 2px solid rgba(100,130,180,.22); padding-bottom: 5px;
}
.w-list { display: flex; flex-direction: column; gap: 5px; }

/* Word items */
.wi {
  border-radius: 2px; padding: 4px 7px;
  border-left: 3px solid rgba(120,95,60,.12);
  transition: all .4s; position: relative;
}
.wi.fw { border-left-color: #2e7d32; }
@keyframes wPop { 0%{transform:scale(1)} 35%{transform:scale(1.05)} 100%{transform:scale(1)} }
.wi.fw { animation: wPop .5s cubic-bezier(.175,.885,.32,1.275); }
.wi-en {
  font-family: 'Kalam', cursive; font-size: .88rem; font-weight: 700;
  color: var(--ink); display: flex; align-items: center; gap: 4px;
}
.fw .wi-en { color: #2e7d32; text-decoration: line-through; text-decoration-thickness: 2px; }
.wi-tr {
  font-family: 'Patrick Hand', cursive; font-size: .76rem;
  color: var(--blue-pen); max-height: 0; overflow: hidden;
  transition: max-height .4s, opacity .3s; opacity: 0; margin-top: 1px;
}
.fw .wi-tr { max-height: 28px; opacity: 1; }
.wi-chk { opacity: 0; transition: opacity .3s; font-size: .88rem; }
.fw .wi-chk { opacity: 1; }

/* Progress */
.prog-wrap { margin-top: 12px; }
.prog-bg {
  background: rgba(120,95,60,.1);
  border-radius: 2px; height: 6px; overflow: hidden;
  border: 1px solid rgba(120,95,60,.18);
}
.prog-fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, #1a1208 0px, #1a1208 4px, #4a3a28 4px, #4a3a28 8px);
  border-radius: 1px; width: 0%; transition: width .55s ease;
}

/* ══════════════════════════════════════════════════════════
   WIN SCREEN
══════════════════════════════════════════════════════════ */
#winScreen { text-align: center; gap: 0; }
.win-badge {
  font-size: 7rem; display: block; margin-bottom: 14px;
  animation: badgePop .8s cubic-bezier(.175,.885,.32,1.275) forwards; opacity: 0;
}
@keyframes badgePop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg);  opacity: 1; }
  100% { transform: scale(1) rotate(0);        opacity: 1; }
}
.win-title {
  font-family: 'Caveat', cursive;
  font-size: clamp(2.4rem,7vw,5rem); font-weight: 700;
  color: var(--ink); margin-bottom: 5px;
  text-shadow: 2px 3px 0 rgba(80,60,30,.1);
  transform: rotate(-1deg); display: inline-block;
}
.win-sub { color: var(--ink-light); font-size: 1rem; margin-bottom: 32px; font-family: 'Patrick Hand', cursive; }
.win-stats { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-bottom: 32px; }
.wst {
  background: #fff9c4; border: 1.5px solid #f5d700;
  border-radius: 3px; padding: 18px 22px; min-width: 120px;
  box-shadow: 3px 4px 10px rgba(80,60,30,.18);
  animation: fadeUp .5s ease forwards; opacity: 0;
}
.wst:nth-child(1) { animation-delay: .2s; }
.wst:nth-child(2) { animation-delay: .35s; }
.wst:nth-child(3) { animation-delay: .5s; }
@keyframes fadeUp { from{ opacity:0;transform:translateY(16px); } to{ opacity:1;transform:translateY(0); } }
.wst-v { font-family: 'Caveat', cursive; font-size: 2.1rem; font-weight: 700; color: var(--red-pen); display: block; }
.wst-l { font-size: .7rem; color: var(--ink-faint); font-family: 'Patrick Hand', cursive; letter-spacing: 1px; }
.win-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn-out {
  font-family: 'Caveat', cursive; font-size: 1.05rem; font-weight: 700;
  padding: 11px 28px; background: transparent; color: var(--blue-pen);
  border: 2px solid var(--blue-pen); border-radius: 3px; cursor: pointer;
  box-shadow: 2px 3px 0 rgba(26,74,138,.18); transition: all .2s;
}
.btn-out:hover { transform: translate(-1px,-1px); box-shadow: 4px 5px 0 rgba(26,74,138,.2); background: rgba(26,74,138,.05); }

/* ══════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════ */
#toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #faf6ee; border: 2px solid #1a1208;
  border-radius: 3px; padding: 10px 24px;
  font-family: 'Caveat', cursive; font-size: 1.02rem; font-weight: 700;
  color: var(--ink); z-index: 500;
  transition: transform .4s cubic-bezier(.175,.885,.32,1.275), opacity .4s;
  opacity: 0; white-space: nowrap;
  box-shadow: 3px 4px 0 rgba(80,60,30,.22);
  pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.err  { border-color: var(--red-pen); color: var(--red-pen); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
══════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  /* Oyun ızgarasını ekranın tam ortasına hizalayıp kelime listesini altına atar */
  .g-layout { 
    display: flex !important; 
    flex-direction: column; 
    align-items: center; 
  }
  .grid-wrap { align-self: center; }
  .wp { width: 100%; min-width: unset; }
  .w-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
  #gameScreen::before { display: none; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (max-width: 420px) {
  .screen { padding: 10px 4px; } /* Yanlardaki ölü boşlukları sildik */
  .g-hdr { padding: 7px 6px; }
  .g-stats { gap: 6px; }
  .gst-v { font-size: 1.1rem; }
  .logo-en { font-size: 2.6rem; }
  .logo-sub { font-size: 1.5rem; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
