
/* ==========================================================================
   Ebru — UI/UX Rebirth: "Karagöz Night Workshop"
   Art Direction: Backlit Light-Table & Ottoman Shadow Theatre Craft
   Palette: Karanlık (#120D0A), Walnut (#241812), Kilim Red (#3E1F0F/#A8321D),
            Lamp Amber (#E8912D), Oiled Paper (#F2D8A7), Zinc (#8FA3B5),
            Ox-gall Green (#5C6B4F).
   Typography: OFL Google Fonts (Georgia + Avenir).
   ========================================================================== */
:root {
  --bg: #120D0A;
  --karanlik: #120D0A;
  --walnut: #241812;
  --walnut-deep: #18100B;
  --walnut-mid: #2F1E16;
  --walnut-light: #3D291F;
  --walnut-border: rgba(232, 145, 45, 0.28);
  --walnut-border-faint: rgba(232, 145, 45, 0.14);
  --walnut-rule: rgba(42, 28, 18, 0.35);

  --amber: #E8912D;
  --amber-bright: #F5A642;
  --amber-gold: #D9A441;
  --amber-glow: rgba(232, 145, 45, 0.45);
  --amber-soft: rgba(232, 145, 45, 0.14);
  --amber-faint: rgba(232, 145, 45, 0.07);

  --paper: #F2D8A7;
  --paper-bright: #FDF4E2;
  --paper-dark: #DEC18C;
  --paper2: #E8CCA0;
  --ink: #18100A;
  --ink2: #3E2C1E;
  --ink3: #634C38;
  --rule: rgba(36, 24, 18, 0.24);

  --blue: #1E6FB8;
  --blue2: #16568F;
  --zinc: #8FA3B5;
  --zinc-dark: #4A5E70;
  --green: #5C6B4F;
  --green-bright: #6F855F;
  --red: #3E1F0F;
  --wax: #A8321D;
  --wax-glow: rgba(168, 50, 29, 0.4);
  --brass: #C9A227;

  --font-display: 'Georgia', 'Cinzel', Georgia, serif;
  --font-body: 'Avenir', 'Segoe UI', system-ui, sans-serif;

  --ease-craft: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.2, 0.8, 0.3, 1);

  --marble: none;
  --marble2: none;
  --wood: none;

  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--karanlik);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}
[hidden] { display: none !important; }
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}
::selection {
  background: var(--amber);
  color: var(--karanlik);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--walnut-deep); }
::-webkit-scrollbar-thumb {
  background: var(--walnut-mid);
  border-radius: 4px;
  border: 1px solid var(--walnut-border);
}
::-webkit-scrollbar-thumb:hover { background: var(--amber); }
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
svg { display: block; }
i[data-icon] {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
}
i[data-icon] svg { width: 100%; height: 100%; }
.serif { font-family: var(--font-display); }

/* The sheet of paper: genuine oiled paper on walnut shadow backing with punched perforation stitch */
.glass {
  background: linear-gradient(135deg, rgba(242, 216, 167, 0.96), rgba(232, 204, 155, 0.94)), var(--marble) center/cover, var(--paper);
  border: 1.5px solid var(--walnut);
  border-radius: 8px;
  color: var(--ink);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 0 0 1px rgba(232, 145, 45, 0.15),
    0 16px 44px rgba(0, 0, 0, 0.75),
    0 4px 12px rgba(0, 0, 0, 0.5);
  position: relative;
}
.panel {
  padding: 24px 28px;
  width: min(94vw, 500px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 2px solid var(--walnut);
  box-shadow:
    0 0 0 1px rgba(232, 145, 45, 0.25),
    0 24px 60px rgba(0, 0, 0, 0.85),
    0 6px 18px rgba(0, 0, 0, 0.6);
}
.panel.wide { width: min(96vw, 820px); }
.panel h2, .title h1, .coach h3, .chc h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--ink);
}
.flourish, .panel h2:not(.rhead h2), .title h1 {
  position: relative;
  padding-bottom: 12px;
}
.panel h2:not(.rhead h2)::after, .title h1::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 170px;
  height: 10px;
  transform: translateX(-50%);
  background: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 170 10'%3E%3Cpath d='M2 5 Q 40 1 85 5 T 168 5' fill='none' stroke='%23241812' stroke-width='1.4' stroke-linecap='round' opacity='.75'/%3E%3Ccircle cx='85' cy='5' r='3.2' fill='%23A8321D'/%3E%3Ccircle cx='70' cy='5' r='1.8' fill='%23E8912D'/%3E%3Ccircle cx='100' cy='5' r='1.8' fill='%23E8912D'/%3E%3C/svg%3E") center/contain no-repeat;
}
.panel h2:not(.rhead h2) {
  text-align: center;
  font-size: 27px;
  margin: 0 0 14px;
}

/* ==========================================================================
   TOPBAR / HUD
   ========================================================================== */
.topbar {
  position: fixed;
  top: calc(8px + var(--sa-t));
  left: 10px;
  right: 10px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  z-index: 20;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(36, 24, 18, 0.95), rgba(22, 14, 10, 0.97));
  border: 1px solid var(--walnut-border);
  border-bottom: 2px solid var(--amber);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  color: var(--paper-bright);
  white-space: nowrap;
}
.brand .logo-s {
  width: 32px;
  height: 32px;
  display: inline-flex;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.brand span {
  font-size: 22px;
  letter-spacing: 0.05em;
  color: #FFECC7;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.stats {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  font-size: 14.5px;
  color: #D6C2A1;
  min-width: 0;
}
.stats b {
  color: #FFF;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stats .lsn {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--walnut);
  padding: 3px 10px;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.mwrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 13, 10, 0.65);
  border: 1px solid var(--walnut-border);
  padding: 4px 10px;
  border-radius: 5px;
}
.mbar {
  display: inline-block;
  width: 80px;
  height: 10px;
  border-radius: 3px;
  background: rgba(14, 10, 7, 0.85);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(232, 145, 45, 0.3);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
.mbar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, #E8912D, #F5B041);
  box-shadow: 0 0 8px var(--amber-glow);
  transition: width 0.25s var(--ease-craft);
}
.mbar em {
  position: absolute;
  left: 80%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #FFF;
  box-shadow: 0 0 4px #FFF;
  z-index: 2;
}
.mwrap.ok b {
  color: var(--amber-bright);
  text-shadow: 0 0 8px var(--amber-glow);
}
.acts {
  display: flex;
  gap: 5px;
  align-items: center;
}
.ibtn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid var(--walnut-border);
  background: linear-gradient(180deg, #332116, #22150E);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  font-weight: 700;
  font-size: 13.5px;
  position: relative;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}
.ibtn:hover:not(:disabled) {
  background: linear-gradient(180deg, #422B1E, #2B1A12);
  border-color: var(--amber);
  color: #FFF;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 8px var(--amber-soft);
}
.ibtn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}
.ibtn.on {
  background: var(--amber);
  border-color: var(--amber-bright);
  color: var(--karanlik);
  box-shadow: 0 0 12px var(--amber-glow);
}
.ibtn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}
.ibtn i[data-icon] { width: 22px; height: 22px; }
.ibtn.pulse {
  animation: amber-lantern-pulse 1.2s ease-in-out infinite;
  border-color: var(--amber-bright);
}
.stars { display: inline-flex; gap: 3px; vertical-align: middle; }
.stars svg { width: 20px; height: 20px; }
.stars svg, .bigstars svg {
  fill: transparent;
  stroke: rgba(232, 145, 45, 0.45);
  stroke-width: 1.4;
  transition: fill 0.25s, stroke 0.25s, filter 0.25s;
}
.stars svg.on, .bigstars svg.on {
  fill: var(--amber);
  stroke: var(--amber-bright);
  filter: drop-shadow(0 0 4px var(--amber-glow));
}

/* ==========================================================================
   TARGET PREVIEW (Master's Hanging Pattern Sheet)
   ========================================================================== */
.preview {
  position: fixed;
  right: 12px;
  top: calc(78px + var(--sa-t));
  width: min(28vw, 220px);
  padding: 8px 8px 10px;
  z-index: 17;
  pointer-events: none;
  background: linear-gradient(180deg, #2E1D14, #1B110B);
  border: 1.5px solid var(--walnut-border);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.7), 0 2px 6px rgba(0,0,0,0.4);
}
.preview::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFE082, #B8860B);
  box-shadow: 0 2px 4px rgba(0,0,0,0.6);
  border: 1px solid #75501B;
}
.preview span {
  display: block;
  font-size: 12px;
  color: var(--paper-bright);
  margin: 0 0 6px 2px;
  font-family: var(--font-display);
  font-style: italic;
  letter-spacing: 0.05em;
  text-align: center;
}
.preview canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px #241812, 0 4px 8px rgba(0,0,0,0.5);
}

/* ==========================================================================
   TOOL TRAY (Walnut Workshop Box)
   ========================================================================== */
.tray {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + var(--sa-b));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  z-index: 20;
  max-width: calc(100vw - 20px);
  flex-wrap: wrap;
  justify-content: center;
  background: linear-gradient(180deg, #2E1D14, #18100A);
  border: 1.5px solid var(--walnut-border);
  border-top: 2px solid var(--amber);
  border-radius: 10px;
  color: var(--paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 16px 48px rgba(0, 0, 0, 0.85),
    0 4px 12px rgba(0, 0, 0, 0.5);
}
.tray .grp {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.tray .sep {
  width: 1px;
  align-self: stretch;
  background: rgba(232, 145, 45, 0.25);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.5);
  margin: 0 2px;
}
.tbtn {
  min-width: 52px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid var(--walnut-border);
  background: linear-gradient(180deg, #382418, #261810);
  padding: 2px 4px;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.tbtn i[data-icon] { width: 30px; height: 30px; }
.tbtn small {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  font-family: var(--font-body);
}
.tbtn:hover:not(:disabled) {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #442C1E, #2D1D13);
  border-color: var(--amber);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 10px var(--amber-soft);
}
.tbtn.sel {
  border-color: var(--amber);
  background: linear-gradient(180deg, #4F3221, #321F14);
  box-shadow: 0 0 16px var(--amber-glow), inset 0 0 12px rgba(232, 145, 45, 0.35);
  color: #FFF;
}
.tbtn:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
}
.tbtn.pulse {
  animation: amber-lantern-pulse 1.2s ease-in-out infinite;
  border-color: var(--amber-bright);
}
.sw {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.65);
  padding: 0;
  position: relative;
  box-shadow:
    inset 0 -5px 8px rgba(0,0,0,0.45),
    inset 0 3px 5px rgba(255,255,255,0.35),
    0 3px 6px rgba(0,0,0,0.5);
  transition: transform 0.15s var(--ease-craft), box-shadow 0.15s;
}
.sw::after {
  content: "";
  position: absolute;
  left: 20%;
  top: 14%;
  width: 30%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255,255,255,0.65);
  filter: blur(1px);
}
.sw:hover:not(:disabled) {
  transform: scale(1.12);
  box-shadow: 0 0 12px var(--amber-glow);
}
.sw.sel {
  border-color: #FFF;
  box-shadow:
    0 0 0 3px var(--amber),
    0 0 16px var(--amber-glow),
    inset 0 -5px 8px rgba(0,0,0,0.45);
  transform: scale(1.12);
}
.sw.pulse { animation: amber-lantern-pulse 1.2s ease-in-out infinite; }
.sw:disabled { opacity: 0.25; cursor: default; transform: none; }

.cbtn {
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  border-radius: 6px;
  border: 1px solid var(--walnut-border);
  background: linear-gradient(180deg, #332116, #22150E);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.cbtn:hover:not(:disabled) {
  background: linear-gradient(180deg, #422B1E, #2B1A12);
  border-color: var(--amber);
  color: #FFF;
  transform: translateY(-1px);
}
.cbtn i[data-icon] { width: 22px; height: 22px; }
.cbtn:disabled { opacity: 0.3; cursor: default; }
.cbtn.pulse { animation: amber-lantern-pulse 1.2s ease-in-out infinite; border-color: var(--amber-bright); }

/* The Hero CTA: Lay the Paper */
.lay {
  min-height: 56px;
  padding: 0 22px;
  border-radius: 6px;
  border: 1.5px solid #FFC988;
  background: linear-gradient(180deg, #E8912D, #B86716);
  color: #120D0A;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 4px 16px rgba(232, 145, 45, 0.45),
    0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s var(--ease-craft), filter 0.15s, box-shadow 0.15s;
}
.lay:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 6px 22px rgba(232, 145, 45, 0.65),
    0 3px 6px rgba(0, 0, 0, 0.4);
}
.lay:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
}
.lay i[data-icon] { width: 22px; height: 22px; }
.lay.pulse {
  animation: amber-lantern-pulse 1.2s ease-in-out infinite;
  border-color: #FFF;
}
.tray .seg {
  align-self: center;
  border: 1.5px solid var(--walnut-border);
  border-radius: 5px;
  background: rgba(18, 13, 10, 0.85);
  overflow: hidden;
}
.tray .seg button {
  min-width: 48px;
  min-height: 46px;
  padding: 0 10px;
  font-size: 13.5px;
  font-weight: 600;
  background: transparent;
  color: var(--paper);
  border: 0;
  transition: background 0.15s, color 0.15s;
}
.tray .seg button.on {
  background: var(--amber);
  color: var(--karanlik);
  font-weight: 700;
}

/* ==========================================================================
   TOASTS (Oiled Paper Slips)
   ========================================================================== */
.toasts {
  position: fixed;
  top: calc(78px + var(--sa-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 25;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  padding: 10px 18px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 15px;
  animation: tin 0.25s var(--ease-craft);
  border-left: 4px solid var(--amber);
  box-shadow: 0 8px 24px rgba(0,0,0,0.65);
}
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--wax); }
.toast.out {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s var(--ease-craft);
}
@keyframes tin {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   OVERLAYS, PANELS, AND BUTTONS
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 9, 6, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 30;
  padding: 16px;
  overflow: auto;
}
.overlay.clear {
  background: rgba(14, 9, 6, 0.25);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.col { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.btn {
  min-height: 46px;
  padding: 0 20px;
  border-radius: 6px;
  border: 1.5px solid var(--walnut);
  background: linear-gradient(180deg, #FDF5E6, #EBD7B3);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #FFF9F0, #F2E3C6);
  border-color: var(--amber);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25), 0 0 10px var(--amber-soft);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.btn.primary {
  background: linear-gradient(180deg, #E8912D, #C26F18);
  border-color: #FFC988;
  color: #120D0A;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 4px 14px rgba(232, 145, 45, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.3);
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 6px 20px rgba(232, 145, 45, 0.6),
    0 3px 6px rgba(0, 0, 0, 0.35);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}
.btn.w { width: 100%; }
.btn i[data-icon] { width: 20px; height: 20px; }
label.sl { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--ink2); font-weight: 500; }
label.sl span { width: 100px; }
input[type=range] {
  flex: 1;
  accent-color: var(--amber);
  height: 44px;
  margin: 0;
  cursor: pointer;
}
.seg {
  display: inline-flex;
  border: 1.5px solid var(--walnut);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.4);
}
.seg button {
  min-height: 44px;
  min-width: 68px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.15s, color 0.15s;
}
.seg button.on {
  background: var(--amber);
  color: var(--karanlik);
  font-weight: 700;
}
.lbl { width: 100px; font-size: 15px; color: var(--ink2); font-weight: 500; }
.footer {
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink3);
  text-align: center;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}
.footer a {
  color: #12558F;
  text-decoration: none;
  font-weight: 500;
}
.footer a:hover { text-decoration: underline; color: #0C3E6B; }

/* ==========================================================================
   TITLE SCREEN
   ========================================================================== */
.title {
  text-align: center;
  width: min(94vw, 540px);
  padding: 28px 32px;
}
.title .logo {
  width: 124px;
  height: 124px;
  margin: 0 auto 6px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.6));
}
.title .logo svg { width: 100%; height: 100%; }
.title h1 {
  margin: 0 auto 6px;
  font-size: 64px;
  letter-spacing: 0.08em;
  line-height: 1.05;
  width: max-content;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.title .sub {
  margin: 6px 0 12px;
  color: var(--ink2);
  font-size: 16.5px;
  font-family: var(--font-display);
  font-style: italic;
}
.title .how {
  font-size: 14.5px;
  color: var(--ink3);
  margin: 0 0 14px;
  line-height: 1.5;
}
.title .best {
  font-size: 15px;
  margin: 14px 0 0;
  color: var(--ink);
  font-weight: 600;
}
#loadmsg {
  color: var(--ink2);
  font-size: 14.5px;
  margin: 8px 0;
  font-style: italic;
}

/* ==========================================================================
   CHAPTER MAP (Manuscript Album)
   ========================================================================== */
.chcards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
@media (max-width: 760px) { .chcards { grid-template-columns: 1fr; } }
.chc {
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.chc::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--amber), var(--wax));
}
.chc h3 { margin: 6px 0 0; font-size: 18px; }
.chc p { margin: 4px 0 10px; font-size: 13.5px; color: var(--ink2); line-height: 1.4; min-height: 34px; }
.chc.locked { opacity: 0.55; }
.lsn6 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lsn6 button {
  min-height: 64px;
  border-radius: 4px;
  border: 1.5px solid var(--rule);
  background: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 3px;
  line-height: 1.15;
  position: relative;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.lsn6 button:hover:not(:disabled) {
  background: #FFF;
  border-color: var(--amber);
  transform: translateY(-1px);
}
.lsn6 button .stars svg { width: 12px; height: 12px; }
.lsn6 button:disabled { opacity: 0.4; cursor: default; }
.lsn6 button.done {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green) inset;
}
.lsn6 button.next {
  border-color: var(--amber);
  background: rgba(232, 145, 45, 0.15);
  box-shadow: 0 0 0 1px var(--amber) inset, 0 0 8px var(--amber-soft);
}
.lsn6 button small {
  font-size: 10.5px;
  color: var(--ink3);
  font-weight: 600;
  font-family: var(--font-body);
}

/* ==========================================================================
   RESULT & GALLERY
   ========================================================================== */
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } }
.sheetimg {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 3px;
  background: #E9E2CF;
  display: block;
  box-shadow:
    0 0 0 6px var(--paper),
    0 0 0 7px var(--walnut),
    0 12px 28px rgba(0,0,0,0.45);
}
.cap {
  font-size: 13.5px;
  color: var(--ink2);
  margin: 10px 0 0;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
}
.note {
  background: rgba(255, 255, 255, 0.45);
  border-left: 3.5px solid var(--wax);
  padding: 8px 14px;
  border-radius: 0 4px 4px 0;
  font-size: 14.5px;
  line-height: 1.45;
}
.note b { color: var(--wax); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink2);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--rule);
  font-weight: 500;
}
.chip i[data-icon] { width: 16px; height: 16px; }
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.3);
}
.rhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1.5px solid var(--rule);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.rhead h2 { margin: 0; font-size: 26px; }
.bigstars { display: flex; gap: 8px; }
.bigstars svg { width: 34px; height: 34px; }
.kv {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.kv div {
  padding: 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
  text-align: center;
  border: 1px solid var(--rule);
}
.kv b {
  display: block;
  font-size: 26px;
  color: var(--amber);
  font-family: var(--font-display);
}
.kv span { font-size: 13px; color: var(--ink2); font-weight: 500; }
.rec {
  color: var(--green);
  font-weight: 700;
  text-align: center;
  margin: 6px 0;
  font-size: 15px;
}
.galgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 640px) {
  .galgrid { grid-template-columns: repeat(2, 1fr); }
  .galgrid button { width: 44px; height: 44px; }
}
.galgrid figure {
  margin: 0;
  position: relative;
  padding: 6px 6px 12px;
  background: #FBF7EE;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transform: rotate(-0.6deg);
  border: 1px solid var(--rule);
}
.galgrid figure:nth-child(2n) { transform: rotate(0.7deg); }
.galgrid img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 2px;
  display: block;
  background: #E9E2CF;
}
.galgrid button {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  border: 0;
  background: rgba(36, 24, 18, 0.85);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.galgrid button i[data-icon] { width: 18px; height: 18px; }
.galgrid button.bind {
  right: auto;
  left: 8px;
  background: rgba(168, 50, 29, 0.85);
}
.galgrid button.bind.on { background: var(--wax); box-shadow: 0 0 10px var(--wax-glow); }
.empty {
  color: var(--ink2);
  font-size: 15px;
  text-align: center;
  padding: 24px 0;
  font-style: italic;
}

/* ==========================================================================
   COACH & CRITIQUE
   ========================================================================== */
.coach {
  position: fixed;
  left: 12px;
  top: calc(78px + var(--sa-t));
  width: min(38vw, 360px);
  padding: 14px 16px;
  z-index: 18;
  border-radius: 8px;
  transition: opacity 0.4s var(--ease-craft), transform 0.4s var(--ease-craft);
}
.coach.out {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}
.coach h3 {
  margin: 0 0 8px;
  font-size: 19px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
}
.coach .note {
  background: rgba(255, 255, 255, 0.5);
  border-left: 3.5px solid var(--wax);
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 10px;
}
.coach .note b { color: var(--wax); }
.coach .chips { margin-bottom: 10px; }
.coach .tip {
  font-size: 13.5px;
  color: var(--ink2);
  margin: 0 0 10px;
  line-height: 1.4;
}
.coach .btn { min-height: 44px; font-size: 14.5px; padding: 0 16px; }

.crit {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(86px + var(--sa-b));
  padding: 8px 18px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  z-index: 19;
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
  background: linear-gradient(180deg, rgba(36, 24, 18, 0.94), rgba(22, 14, 10, 0.96));
  border: 1px solid var(--walnut-border);
  border-left: 4px solid var(--amber);
  color: var(--paper-bright);
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crit.good {
  border-left-color: var(--green-bright);
  color: #DCF0D0;
}
.crit[hidden] { display: none; }

/* ==========================================================================
   RIM GLOW & SEALS
   ========================================================================== */
.rim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  box-shadow: inset 0 0 100px 20px rgba(232, 145, 45, 0.6);
  transition: opacity 0.35s;
}
.rim.on { opacity: 1; }
.seal {
  display: inline-flex;
  width: 24px;
  height: 24px;
  vertical-align: middle;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}
.seal svg { width: 100%; height: 100%; }
.lsn6 button .seal {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 18px;
  height: 18px;
}
.rankline {
  font-size: 14.5px;
  margin: 10px 0 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}
.fact {
  font-size: 13.5px;
  color: var(--ink2);
  line-height: 1.45;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px dashed var(--rule);
}
.fact b { color: var(--wax); }
#result .two { max-width: 660px; margin: 0 auto; }
#result .kv { margin: 10px 0; }
.sealchip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(168, 50, 29, 0.12);
  border: 1px solid rgba(168, 50, 29, 0.5);
}
.sealchip.off {
  opacity: 0.65;
  background: rgba(255, 255, 255, 0.3);
  border-color: var(--rule);
}
.sealchip:not(.off) .seal {
  width: 32px;
  height: 32px;
  animation: stamp 0.5s var(--ease-snap) both;
}
@keyframes stamp {
  from { transform: scale(2.2) rotate(-18deg); opacity: 0; }
  60% { opacity: 1; }
  to { transform: none; opacity: 1; }
}
.rhead img.cat {
  width: 76px;
  height: 76px;
  object-fit: contain;
  margin-left: auto;
}
.title .logo.cat { width: 96px; height: 96px; }
#dbg {
  position: fixed;
  left: 8px;
  bottom: calc(8px + var(--sa-b));
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  color: #9F9;
  background: rgba(18, 13, 10, 0.85);
  border: 1px solid var(--walnut-border);
  padding: 6px 10px;
  white-space: pre;
  pointer-events: none;
  z-index: 60;
  border-radius: 6px;
  max-width: 92vw;
  overflow: hidden;
}
#dbg .err { color: #F66; }

/* ==========================================================================
   ANIMATIONS & RESPONSIVENESS
   ========================================================================== */
@keyframes amber-lantern-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(232, 145, 45, 0), 0 4px 16px rgba(232, 145, 45, 0.3);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(232, 145, 45, 0.45), 0 6px 24px rgba(232, 145, 45, 0.7);
  }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 145, 45, 0); }
  50% { box-shadow: 0 0 0 6px rgba(232, 145, 45, 0.45); }
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 8px;
    min-height: auto;
  }
  .brand span { display: none; }
  .stats {
    gap: 8px;
    font-size: 13.5px;
    order: 3;
    flex-basis: 100%;
    justify-content: space-around;
    padding-top: 4px;
    border-top: 1px solid rgba(232, 145, 45, 0.15);
  }
  .stats .lsn { display: none; }
  .acts { margin-left: auto; }
  .mbar { width: 56px; }
  .preview {
    top: calc(118px + var(--sa-t));
    width: 32vw;
    padding: 6px;
  }
  .preview canvas { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px #241812; }
  .tray {
    left: 8px;
    right: 8px;
    transform: none;
    max-width: none;
    padding: 8px 8px;
    gap: 8px;
    border-radius: 8px;
  }
  .tray .grp { gap: 4px; }
  .tray .sep { display: none; }
  #swatches {
    order: 3;
    flex-basis: 100%;
    justify-content: center;
    padding-top: 4px;
    border-top: 1px solid rgba(232, 145, 45, 0.15);
  }
  .tbtn { min-width: 48px; height: 50px; }
  .tbtn i[data-icon] { width: 26px; height: 26px; }
  .sw { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .lay { min-height: 50px; padding: 0 14px; font-size: 14.5px; }
  .coach {
    left: 8px;
    right: calc(32vw + 16px);
    width: auto;
    top: calc(118px + var(--sa-t));
    max-height: 42vh;
    overflow: auto;
    padding: 10px 12px;
  }
  .coach .chips { display: none; }
  .crit {
    bottom: calc(126px + var(--sa-b));
    font-size: 13px;
    padding: 6px 12px;
  }
  .toasts { top: calc(122px + var(--sa-t)); }
}

/* ==========================================================================
   TEK NEFES (one breath): HUD clock, the pressed print, the gallery wall
   ========================================================================== */
.stats .nefes { display: inline-flex; align-items: center; gap: 6px; }
.stats .nefes b { min-width: 2.2em; text-align: right; }
.stats .nefes b.low { color: #FF9A7A; text-shadow: 0 0 8px var(--wax-glow); }
.stats .nefes i[data-icon] { width: 16px; height: 16px; opacity: 0.3; transition: opacity 0.2s; }
.stats .nefes i[data-icon].on { opacity: 1; color: var(--amber-bright); }
.pressbox { position: relative; max-width: 560px; margin: 4px auto 10px; }
.pressbox .sheetimg { width: 100%; }
.pressbox .sheetimg.reveal { animation: press-peel 1.3s var(--ease-craft) both; }
.pressbox .pstamp {
  position: absolute; right: 4%; bottom: 6%; width: 64px; height: 64px;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.45));
}
.pressbox .pstamp svg { width: 100%; height: 100%; }
.pressbox .pstamp.reveal { animation: press-stamp 0.5s 1.1s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes press-peel {
  0% { clip-path: inset(0 100% 0 0); filter: brightness(1.25) saturate(0.6); transform: translateY(6px); }
  70% { filter: brightness(1.05) saturate(1); }
  100% { clip-path: inset(0 0 0 0); filter: none; transform: none; }
}
@keyframes press-stamp {
  from { opacity: 0; transform: scale(1.8) rotate(-18deg); }
  to { opacity: 0.92; transform: scale(1) rotate(-8deg); }
}
.galgrid figcaption { font-size: 12.5px; color: var(--ink2); text-align: center; margin-top: 6px; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .sealchip:not(.off) .seal, .pulse, .lay.pulse, .tbtn.pulse, .sw.pulse, .ibtn.pulse, .cbtn.pulse,
  .pressbox .sheetimg.reveal, .pressbox .pstamp.reveal {
    animation: none !important;
  }
}
