
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&family=Patrick+Hand&display=swap');

:root {
  --bg: #fbf3d4;
  --panel: #fffdf7;
  --panel-border: #171717;
  --text: #151515;
  --text-muted: #5c574f;
  --accent: #ff6f61;
  --accent-hover: #f24c40;
  --accent-2: #60c78d;
  --accent-3: #67a9d8;
  --accent-4: #f2ce5d;
  --danger: #e84b42;
  --success: #39a96b;
  --radius: 18px 11px 20px 13px / 13px 21px 12px 18px;
  --border-width: 3px;
  --shadow-color: rgba(25, 22, 18, 0.88);
  --sketch-shadow: 5px 6px 0 rgba(25, 22, 18, 0.85), 8px 9px 0 rgba(25, 22, 18, 0.16);
  --page-pad: clamp(1rem, 4vw, 3rem);
  --card-min: clamp(150px, 28vw, 220px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Patrick Hand', 'Comic Neue', 'Comic Sans MS', 'Chalkboard SE', 'Marker Felt', sans-serif;
  background-color: #ddd6c5;
  background-image: none;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  background:
    repeating-linear-gradient(87deg, transparent 0 42px, rgba(0,0,0,.018) 43px 44px, transparent 45px 88px),
    linear-gradient(96deg, transparent 0 12%, rgba(23,23,23,.05) 12.2%, transparent 12.6% 55%, rgba(23,23,23,.04) 55.3%, transparent 55.8%),
    repeating-linear-gradient(-7deg, transparent 0 90px, rgba(23,23,23,.028) 91px 92px, transparent 93px 190px);
  mix-blend-mode: multiply;
}

body::after {
  content: "";
  position: fixed;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 22px;
  pointer-events: none;
  z-index: 301;
  background:
    repeating-linear-gradient(180deg, transparent 0 38px, rgba(23,23,23,.23) 39px 41px, transparent 42px 76px),
    linear-gradient(90deg, rgba(205, 75, 73, .42), rgba(205, 75, 73, .12) 35%, transparent);
  opacity: .45;
  transform: rotate(.25deg);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 14px; }
::-webkit-scrollbar-track { background: var(--bg); border-left: var(--border-width) solid var(--panel-border); }
::-webkit-scrollbar-thumb { background: var(--accent-3); border: var(--border-width) solid var(--panel-border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Top Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: linear-gradient(2deg, #fffaf0, #fffef8 58%, #f7edcf);
  border-bottom: var(--border-width) solid var(--panel-border);
  z-index: 50;
  box-shadow: 0 4px 0 var(--shadow-color), 0 8px 0 rgba(25, 22, 18, 0.12);
  position: relative;
  transform: rotate(-0.25deg);
}

.main-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 11px;
  background-image: linear-gradient(135deg, transparent 0 8px, var(--panel-border) 9px 11px, transparent 12px);
  background-size: 26px 11px;
  opacity: .45;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo h1 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text);
  text-shadow: 2px 2px 0 rgba(103, 169, 216, .8), -1px 1px 0 rgba(255,255,255,.8);
  letter-spacing: 1px;
  transform: rotate(-1deg);
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.icon-btn {
  background: #fffdf7;
  border: var(--border-width) solid var(--panel-border);
  color: var(--text);
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.4rem;
  box-shadow: var(--sketch-shadow);
  transition: all 0.15s ease;
}
.icon-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow-color), 4px 5px 0 rgba(25, 22, 18, 0.14);
  background: var(--accent-4);
}
.icon-btn:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* Main Content: Games Grid */
.main-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--page-pad);
  display: flex;
  flex-direction: column;
}

.main-content::before {
  content: "PLAY NOW!";
  display: block;
  font-size: 3.5rem;
  font-weight: 800;
  color: #fffdf7;
  text-align: left;
  margin-bottom: 2rem;
  margin-left: auto;
  margin-right: auto;
  max-width: 1400px;
  width: 100%;
  text-shadow: 
    -2px -2px 0 #171717,
    2px -2px 0 #171717,
    -2px 2px 0 #171717,
    2px 2px 0 #171717,
    5px 6px 0 var(--accent-3),
    7px 8px 0 rgba(23,23,23,.2);
  letter-spacing: 1px;
  text-transform: uppercase;
  transform: rotate(-2.5deg);
  transition: transform .25s ease, text-shadow .25s ease;
}

.main-content:hover::before {
  transform: rotate(-1.6deg) translateY(-3px);
  text-shadow: 
    -2px -2px 0 #171717,
    2px -2px 0 #171717,
    -2px 2px 0 #171717,
    2px 2px 0 #171717,
    4px 5px 0 var(--accent),
    7px 8px 0 var(--accent-3),
    9px 10px 0 rgba(23,23,23,.18);
}

.apps-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: clamp(1rem, 3vw, 1.5rem);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

#apps-list {
  position: relative;
}

#apps-list::before {
  content: "";
  position: absolute;
  inset: -18px -12px;
  pointer-events: none;
  background:
    linear-gradient(108deg, transparent 0 20%, rgba(23,23,23,.05) 20.3%, transparent 20.8%),
    linear-gradient(-8deg, transparent 0 62%, rgba(103,169,216,.16) 62.2%, transparent 62.8%);
  opacity: .55;
}

/* My Projects specific tweaking */
#my-projects-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  grid-template-columns: none; /* override grid */
  margin-top: .25rem;
}

/* App Cards (Retro Solid Layout) */
.app-card {
  --icon-color: var(--accent-3);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.7), transparent 42%),
    var(--panel);
  border-radius: var(--radius);
  border: var(--border-width) solid var(--panel-border);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  text-align: center;
  gap: 0;
  overflow: visible; /* changed from hidden to allow rough borders */
  box-shadow: var(--sketch-shadow);
  cursor: pointer;
  isolation: isolate;
  animation: cardPop .42s cubic-bezier(.2, .9, .2, 1.2) both;
}
.app-card::after {
  content: "";
}
.app-card::before {
  content: "";
  position: absolute;
  top: -5px; left: -4px; right: -5px; bottom: -6px;
  border: 2px solid rgba(23, 23, 23, .72);
  border-radius: 21px 13px 19px 10px / 10px 19px 12px 23px;
  pointer-events: none;
  z-index: 10;
  transform: rotate(.7deg);
  transition: inset .18s ease, border-color .18s ease, transform .18s ease;
}
.app-card:active {
  transform: translate(6px, 6px) rotate(0deg);
  box-shadow: 0px 0px 0px var(--shadow-color);
}

.squircle-icon {
  width: 100%;
  height: 140px;
  background:
    linear-gradient(133deg, rgba(255,255,255,.32) 0 18%, transparent 19%),
    repeating-linear-gradient(-12deg, transparent 0 12px, rgba(255,255,255,.12) 13px 15px),
    var(--icon-color);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 4rem;
  transition: transform .18s ease, filter .18s ease;
  position: relative;
  border-bottom: var(--border-width) solid var(--panel-border);
  border-radius: 15px 11px 0 0 / 12px 18px 0 0;
  overflow: hidden;
}
.squircle-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 34%, rgba(255,255,255,.32) 35% 37%, transparent 38%),
    repeating-linear-gradient(172deg, transparent 0 17px, rgba(23,23,23,.05) 18px 19px);
  mix-blend-mode: multiply;
  opacity: .75;
  transition: opacity .18s ease, transform .18s ease;
  background-size: auto, 100% 18px;
}
.app-card:hover .squircle-icon {
  transform: scale(1.035);
  filter: saturate(1.08) contrast(1.05);
}

.app-card:hover .squircle-icon::after {
  opacity: 1;
  transform: translateX(8px) rotate(.6deg);
  animation: pencilShade .55s ease both;
}

.preview-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #ffffff;
  pointer-events: none;
}

.app-preview {
  width: 500%;
  height: 500%;
  border: 0;
  background: #ffffff;
  pointer-events: none;
  transform: scale(0.2);
  transform-origin: top left;
  transition: transform .25s ease, filter .25s ease;
}

.app-card:hover .app-preview {
  filter: saturate(1.12) contrast(1.04);
  transform: scale(0.205);
}

.icon-text {
  position: relative;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

/* Alternate colors based on nth-child logic applied via css random look */
.app-card:nth-child(1n) { transform: rotate(-1.8deg); }
.app-card:nth-child(2n) { transform: rotate(2.4deg); }
.app-card:nth-child(3n) { transform: rotate(-2.8deg); }
.app-card:nth-child(4n) { transform: rotate(1.3deg); }
.app-card:nth-child(5n) { transform: rotate(.6deg) translateY(7px); }
.app-card:nth-child(2n) { animation-delay: .04s; }
.app-card:nth-child(3n) { animation-delay: .08s; }
.app-card:nth-child(4n) { animation-delay: .12s; }
.app-card:nth-child(5n) { animation-delay: .16s; }

.app-card:nth-child(2n) { --icon-color: var(--accent); }
.app-card:nth-child(3n) { --icon-color: var(--accent-2); }
.app-card:nth-child(4n) { --icon-color: var(--accent-4); }

.app-card:hover {
  transform: translate(2px, -4px) rotate(-.4deg);
  box-shadow: 6px 8px 0 var(--shadow-color), 10px 12px 0 rgba(25, 22, 18, 0.13);
  z-index: 10;
}

.app-card:nth-child(2n):hover { transform: translate(2px, -4px) rotate(.5deg); }
.app-card:nth-child(3n):hover { transform: translate(2px, -4px) rotate(-.8deg); }
.app-card:nth-child(4n):hover { transform: translate(2px, -4px) rotate(.25deg); }

.app-card:hover::before {
  top: -7px;
  left: -6px;
  right: -7px;
  bottom: -8px;
  border-color: rgba(23, 23, 23, .9);
  transform: rotate(-.45deg);
}

.app-info { 
  flex-grow: 1; 
  width: 100%; 
  padding: 1rem;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
  transition: background .18s ease;
}

.app-card:hover .app-info {
  background:
    linear-gradient(rgba(75, 111, 166, 0.1) 1px, transparent 1px),
    #fffdf7;
  background-size: 100% 22px;
}
#apps-list .app-info::before {
  content: "";
  position: absolute;
  width: 62px;
  height: 18px;
  top: -154px;
  left: 24px;
  background: rgba(255, 232, 145, .72);
  border: 1px solid rgba(120, 98, 44, .35);
  box-shadow: 1px 1px 0 rgba(0,0,0,.08);
  transform: rotate(-4deg);
  pointer-events: none;
}
#apps-list .app-card:nth-child(even) .app-info::before {
  left: auto;
  right: 22px;
  transform: rotate(5deg);
}
#apps-list .app-card:hover .app-info::before {
  animation: tapeTwitch .42s ease both;
}
.app-title { margin: 0 0 0.5rem 0; font-size: 1.25rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); transition: transform .18s ease, text-shadow .18s ease; }
.app-card:hover .app-title {
  transform: rotate(-1deg);
  text-shadow: 2px 2px 0 rgba(242, 206, 93, .8);
}
.app-description { margin: 0; font-size: 0.85rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; font-weight: 600;}

/* Play button on hover */
#apps-list .app-card::after {
  content: "PLAY";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8) rotate(-5deg);
  background: var(--text);
  color: white;
  padding: 10px 24px;
  border-radius: var(--radius);
  border: var(--border-width) solid var(--panel-border);
  box-shadow: 4px 4px 0px var(--accent-4);
  font-weight: 800;
  font-size: 1.2rem;
  opacity: 0;
  transition: all 0.15s ease;
  pointer-events: none;
  z-index: 5;
}
#apps-list .app-card:hover::after {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1) rotate(0deg);
}

.app-actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  justify-content: center;
  margin-top: auto;
}

#my-projects-list .my-project-card {
  padding: 0.85rem 0.9rem;
  border-radius: 12px 18px 11px 16px / 16px 10px 17px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  min-height: auto;
  gap: 0.85rem;
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), transparent 70%),
    linear-gradient(rgba(75, 111, 166, 0.12) 1px, transparent 1px),
    #fffaf0;
  background-size: auto, 100% 24px, auto;
  box-shadow: 3px 4px 0 rgba(25, 22, 18, 0.82), 6px 7px 0 rgba(25, 22, 18, 0.12);
  transform: rotate(-0.8deg);
}

#my-projects-list .my-project-card:hover {
  transform: translate(1px, -2px) rotate(-.25deg);
}

#my-projects-list .my-project-card:nth-child(even) {
  transform: rotate(0.8deg);
}

#my-projects-list .my-project-card:nth-child(even):hover {
  transform: translate(1px, -2px) rotate(.25deg);
}

#my-projects-list .my-project-card::before,
#my-projects-list .my-project-card::after {
  content: none;
}

#my-projects-list .my-project-info {
  flex-grow: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  background: transparent;
}

#my-projects-list .my-project-title {
  margin: 0;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  text-decoration: underline;
  text-decoration-color: rgba(103, 169, 216, .75);
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

#my-projects-list .my-project-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin: 0;
  width: auto;
  flex-shrink: 0;
}

/* Modals & Slide-outs */
.options-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.options-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.options-sidebar {
  width: min(450px, 100vw);
  max-width: 100vw;
  background:
    linear-gradient(rgba(75, 111, 166, 0.13) 1px, transparent 1px),
    var(--bg);
  background-size: 100% 31px;
  height: 100%;
  border-left: var(--border-width) solid var(--panel-border);
  box-shadow: -7px 0 0 var(--shadow-color), -11px 0 0 rgba(25, 22, 18, .16);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease-out;
  overflow-y: auto;
}
.options-overlay.hidden .options-sidebar {
  transform: translateX(100%);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: var(--border-width) solid var(--panel-border);
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-header h2 { margin: 0; font-size: 1.5rem; font-weight: 800; }
.close-sidebar {
  background: none; border: none; color: var(--text); font-size: 2rem; cursor: pointer; line-height: 1; font-weight: bold;
  transition: transform 0.15s;
}
.close-sidebar:hover { transform: scale(1.2) rotate(10deg); color: var(--accent); }

.panels {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Panel styling */
.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,.66), transparent 54%),
    var(--panel);
  border: var(--border-width) solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--sketch-shadow);
  position: relative;
  transform: rotate(1deg);
  transition: transform .18s ease, box-shadow .18s ease;
}
.panel:nth-child(even) {
  transform: rotate(-1deg);
}
.panel:hover {
  transform: rotate(.25deg) translateY(-2px);
  box-shadow: 6px 7px 0 rgba(25, 22, 18, 0.86), 10px 11px 0 rgba(25, 22, 18, 0.14);
}
.panel:nth-child(even):hover {
  transform: rotate(-.25deg) translateY(-2px);
}
.panel::before {
  content: "";
  position: absolute;
  top: -3px; left: -1px; right: -2px; bottom: -2px;
  border: 1px solid rgba(0,0,0,0.5);
  border-radius: 20px 12px 18px 11px / 12px 20px 10px 18px;
  pointer-events: none;
}
.panel::after {
  content: "";
  position: absolute;
  top: -12px;
  right: 24px;
  width: 62px;
  height: 17px;
  background: rgba(255, 232, 145, .72);
  border: 1px solid rgba(120, 98, 44, .35);
  box-shadow: 1px 1px 0 rgba(0,0,0,.08);
  transform: rotate(3deg);
  pointer-events: none;
}
.panel:hover::after {
  animation: tapeTwitch .45s ease both;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem;
}
.panel-head h2 { margin: 0; font-size: 1.2rem; font-weight: 800; color: var(--text); }

.badge { 
  background: var(--accent-3); 
  color: white; 
  padding: 6px 12px; 
  border-radius: var(--radius); 
  font-size: 0.8rem; 
  font-weight: 800; 
  border: 2px solid var(--panel-border);
  box-shadow: 2px 2px 0 var(--shadow-color), 4px 4px 0 rgba(25, 22, 18, 0.14);
  transform: rotate(2deg);
  transition: transform .14s ease, box-shadow .14s ease;
}
.panel:hover .badge {
  transform: rotate(-2deg) translateY(-1px);
}

.publish-form { display: flex; flex-direction: column; gap: 1.25rem; }
.publish-form label { font-size: 1rem; color: var(--text); display: flex; flex-direction: column; gap: 0.5rem; font-weight: 700; }
.publish-form input, .publish-form textarea {
  padding: 0.85rem 1rem; 
  border-radius: var(--radius); 
  border: var(--border-width) solid var(--panel-border); 
  background:
    linear-gradient(rgba(75, 111, 166, 0.11) 1px, transparent 1px),
    #fffef9;
  background-size: 100% 28px;
  color: var(--text); 
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.15s ease;
  box-shadow: inset 2px 3px 0 rgba(0,0,0,0.04);
}
.publish-form input:focus, .publish-form textarea:focus {
  outline: none;
  background: var(--bg);
  box-shadow: inset 0px 0px 0px rgba(0,0,0,0.0), 0 0 0 4px var(--accent-4);
  transform: rotate(-.2deg);
}
.publish-form input:disabled, .publish-form textarea:disabled { opacity: 0.6; cursor: not-allowed; background: #e5e7eb; }
/* Drop Zone Styling */
.drop-zone-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.drop-zone {
  position: relative;
  border: var(--border-width) dashed var(--panel-border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 16px 16px, rgba(0,0,0,.12) 0 1px, transparent 2px),
    #fffef9;
  background-size: 18px 18px, auto;
  padding: 2rem 1rem;
  text-align: center;
  transition: all 0.15s ease;
  cursor: pointer;
  overflow: hidden;
}
.drop-zone::after {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 76px;
  height: 18px;
  background: rgba(255, 232, 145, .72);
  border: 1px solid rgba(120, 98, 44, .35);
  box-shadow: 1px 1px 0 rgba(0,0,0,.08);
  transform: translateX(-50%) rotate(-2deg);
  pointer-events: none;
}
.drop-zone:hover, .drop-zone.drag-over {
  background: var(--accent-4);
  transform: rotate(-.35deg) scale(1.012);
}
.drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
.drop-icon {
  font-size: 3rem;
  transform-origin: center bottom;
}
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  animation: jump .72s infinite alternate cubic-bezier(0.5, 0.05, 1, 0.5);
}
@keyframes jump {
  0% { transform: scale(1.2, 0.8); }
  20% { transform: scale(0.9, 1.1) translateY(-15px); }
  100% { transform: scale(1, 1) translateY(0); }
}
.drop-zone p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}
.drop-zone small {
  color: var(--text-muted);
  font-weight: 600;
}
.drop-zone input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

textarea { min-height: 120px; resize: vertical; }

.actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

.btn { 
  background: #fffdf7; 
  color: var(--text); 
  border: var(--border-width) solid var(--panel-border); 
  padding: 0.75rem 1.25rem; 
  border-radius: var(--radius); 
  cursor: pointer; 
  font-weight: 800; 
  font-size: 1rem;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
  font-family: inherit;
  display: inline-flex; justify-content: center; align-items: center;
  box-shadow: var(--sketch-shadow);
  transform: rotate(-.4deg);
}
.btn:hover { background: #f3f4f6; transform: translate(2px, -1px) rotate(.6deg); box-shadow: 4px 5px 0 var(--shadow-color), 7px 8px 0 rgba(25, 22, 18, 0.14); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0px 0px 0px var(--shadow-color); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0px var(--shadow-color); }

.btn-primary { 
  background: var(--accent); 
  color: white;
}
.btn-primary:hover { 
  background: var(--accent-hover); 
}

.btn-secondary {
  background: var(--accent-2);
  color: #000;
}
.btn-secondary:hover { background: #55efc4; }

.btn-danger { 
  background: var(--danger); 
  color: white;
}
.btn-danger:hover { background: #ff6b81; }

.btn-small { padding: 0.5rem 1rem; font-size: 0.9rem; border-radius: 8px; }

.result { margin-top: 0.75rem; font-size: 0.9rem; font-weight: 500; }
.result.true { color: var(--success); }
.result.false { color: var(--danger); }

/* Publish Actions (stacked buttons) */
.publish-actions {
  flex-direction: column;
  gap: 0.75rem;
}

/* Edit Mode Banner */
.edit-mode-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  background:
    linear-gradient(135deg, rgba(242, 206, 93, 0.35), rgba(255, 111, 97, 0.2)),
    #fffef9;
  border: var(--border-width) solid var(--panel-border);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  box-shadow: 3px 4px 0 rgba(25, 22, 18, 0.7);
  animation: editPulse 2s ease-in-out infinite alternate;
}

.edit-mode-banner.hidden {
  display: none;
}

.edit-mode-icon {
  font-size: 1.4rem;
  animation: editWiggle 1.5s ease-in-out infinite;
}

@keyframes editPulse {
  0% {
    box-shadow: 3px 4px 0 rgba(25, 22, 18, 0.7);
    transform: rotate(-0.3deg);
  }
  100% {
    box-shadow: 4px 5px 0 rgba(25, 22, 18, 0.8), 0 0 0 3px rgba(242, 206, 93, 0.4);
    transform: rotate(0.3deg);
  }
}

@keyframes editWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

/* Panel in edit mode visual hint (applied via JS class) */
#publish-panel .edit-mode-banner + .publish-form {
  border-left: 4px solid var(--accent-4);
  padding-left: 1rem;
  margin-left: -4px;
}

/* Game Viewer Fullscreen Overlay */
.viewer-content {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(75, 111, 166, 0.16) 1px, transparent 1px),
    radial-gradient(rgba(17, 24, 39, 0.1) 2px, transparent 2px);
  background-size: 100% 31px, 30px 30px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
  padding: 1rem 3rem 3rem 3rem;
}
.viewer-content.hidden { display: none; }

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.viewer-header {
  background: transparent;
  color: var(--text);
  padding: 0 0 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
}
.viewer-header h2 { margin: 0; font-size: 2rem; font-weight: 800; color: var(--text); text-shadow: 3px 3px 0px var(--accent-2); transform: rotate(-1deg); }

#app-iframe {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  border: var(--border-width) solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--sketch-shadow);
  background: #ffffff;
  overflow: hidden;
}

@keyframes cardPop {
  from {
    opacity: 0;
    scale: .96;
    translate: 0 10px;
  }
  to {
    opacity: 1;
    scale: 1;
    translate: 0 0;
  }
}

@keyframes pencilShade {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 14px 0, 0 6px; }
}

@keyframes tapeTwitch {
  0%, 100% { translate: 0 0; }
  35% { translate: 1px -1px; }
  65% { translate: -1px 1px; }
}

@media (hover: none) {
  .app-card:hover,
  .app-card:hover .squircle-icon,
  .btn:hover,
  .icon-btn:hover {
    transform: none;
  }

  #apps-list .app-card:hover::after {
    opacity: 0;
  }
}

@media (max-width: 900px) {
  :root {
    --card-min: clamp(145px, 38vw, 190px);
  }

  .main-header {
    padding: 0.85rem 1.1rem;
    gap: 1rem;
  }

  .logo h1 {
    font-size: clamp(1.65rem, 6vw, 2.2rem);
    line-height: 1;
  }

  .main-content::before {
    font-size: clamp(2.2rem, 11vw, 3rem);
    margin-bottom: 1.35rem;
  }

  .options-sidebar {
    border-left-width: 0;
    box-shadow: -4px 0 0 var(--shadow-color);
  }

  .panels {
    padding: 1rem;
    gap: 1.25rem;
  }

  .panel {
    padding: 1.1rem;
  }

  .viewer-content {
    padding: 0.75rem 1rem 1rem 1rem;
  }

  .viewer-header h2 {
    font-size: clamp(1.3rem, 5vw, 1.8rem);
  }
}

@media (max-width: 600px) {
  body::after {
    left: 6px;
    width: 13px;
    opacity: .32;
  }

  .main-header {
    transform: none;
    animation: none;
  }

  .header-actions {
    gap: .5rem;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
    box-shadow: 3px 4px 0 rgba(25, 22, 18, 0.85), 5px 6px 0 rgba(25, 22, 18, 0.12);
  }

  .main-content {
    padding: 1.25rem 0.85rem 1.75rem 1.15rem;
  }

  .main-content::before {
    text-align: center;
    text-shadow:
      -1px -1px 0 #171717,
      1px -1px 0 #171717,
      -1px 1px 0 #171717,
      1px 1px 0 #171717,
      3px 4px 0 var(--accent-3);
  }

  .apps-list {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 138px), 1fr));
    gap: 1rem;
    padding: 0;
  }

  .app-card {
    border-width: 2px;
    box-shadow: 3px 4px 0 rgba(25, 22, 18, 0.85), 5px 6px 0 rgba(25, 22, 18, 0.12);
  }

  .viewer-content { padding: 0; }
  #app-iframe { border-radius: 0; border: none; border-top: var(--border-width) solid var(--panel-border); box-shadow: none; }
  .viewer-header {
    padding: .75rem;
    background: var(--panel);
    border-bottom: var(--border-width) solid var(--panel-border);
    gap: .75rem;
  }

  .viewer-header h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .squircle-icon {
    height: 100px;
    font-size: 3rem;
  }

  .app-title {
    font-size: 1.1rem;
  }

  .app-description {
    display: none;
  }

  #apps-list .app-info::before {
    top: -112px;
    left: 14px;
    width: 50px;
    height: 14px;
  }

  #apps-list .app-card::after {
    padding: 7px 16px;
    font-size: 1rem;
  }

  .options-sidebar {
    width: 100vw;
  }

  .sidebar-header {
    padding: 1rem;
  }

  .sidebar-header h2 {
    font-size: 1.3rem;
  }

  .panel-head {
    align-items: flex-start;
    gap: .75rem;
  }

  .badge {
    padding: 4px 8px;
    font-size: .72rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    min-height: 42px;
    padding: .65rem .9rem;
  }

  #my-projects-list .my-project-card {
    flex-wrap: wrap;
    align-items: stretch;
    gap: .75rem;
  }

  #my-projects-list .my-project-info,
  #my-projects-list .my-project-actions {
    width: 100%;
  }

  #my-projects-list .my-project-actions {
    justify-content: stretch;
  }

  #my-projects-list .my-project-actions .btn {
    flex: 1;
  }
}

@media (max-width: 380px) {
  .apps-list {
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
  }

  .app-info {
    padding: .75rem;
  }

  .app-title {
    font-size: 1rem;
  }

  .btn-small {
    font-size: .82rem;
    padding: .45rem .55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

/* Layout and studio refinements */
html {
  min-height: 100%;
  background: #ddd6c5;
}

body.studio-open {
  overflow: hidden;
}

.main-header,
.main-content,
.code-studio {
  position: relative;
}

.main-header,
.main-content {
  z-index: 1;
}

.main-content {
  flex-grow: 0;
  overflow: visible;
  min-height: calc(100vh - 88px);
}

.main-header {
  position: sticky;
  top: 0;
}

.logo h1::before {
  content: "ZAP!";
  display: inline-block;
  margin-right: .75rem;
  padding: .08rem .45rem;
  color: #171717;
  background: var(--accent-4);
  border: 3px solid var(--panel-border);
  box-shadow: 3px 3px 0 var(--accent);
  transform: rotate(-8deg);
  font-size: .55em;
  vertical-align: middle;
}

.icon-btn {
  width: auto;
  min-width: 64px;
  padding: 0 .8rem;
  font-size: 1rem;
}

.app-card,
.panel,
.drop-zone,
.btn,
.viewer-content,
.code-studio {
  background-blend-mode: multiply, normal;
}

.btn-editor {
  background: #171717;
  color: #fffdf7;
}

.btn-editor:hover {
  background: #303030;
}

/* Code Studio */
.code-studio {
  position: fixed;
  inset: clamp(.5rem, 2vw, 1.25rem);
  z-index: 240;
  display: flex;
  flex-direction: column;
  color: var(--text);
  border: 4px solid var(--panel-border);
  border-radius: 10px;
  background:
    linear-gradient(116deg, rgba(255,255,255,.38), transparent 26%, rgba(23,23,23,.08) 26.4% 27%, transparent 27.4%),
    linear-gradient(22deg, transparent 0 56%, rgba(255,255,255,.24) 56.4% 57.2%, rgba(23,23,23,.09) 57.6% 58.1%, transparent 58.5%),
    #d7ceb8;
  box-shadow: 11px 13px 0 rgba(25,22,18,.9), 0 0 0 9999px rgba(15,13,10,.56);
  overflow: hidden;
}

.code-studio.hidden {
  display: none;
}

.studio-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  border-bottom: 4px solid var(--panel-border);
  background:
    repeating-linear-gradient(-10deg, transparent 0 11px, rgba(255,255,255,.16) 12px 14px),
    #fff8e8;
}

.studio-title {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-width: 0;
}

.studio-title h2,
.studio-title p {
  margin: 0;
}

.studio-title h2 {
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1;
  text-shadow: 2px 2px 0 var(--accent-3);
}

.studio-title p {
  color: var(--text-muted);
  font-weight: 800;
}

.burst {
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  color: #171717;
  font-size: 1rem;
  font-weight: 900;
  background: var(--accent-4);
  border: 4px solid var(--panel-border);
  clip-path: polygon(50% 0,61% 28%,91% 15%,75% 43%,100% 55%,70% 61%,82% 91%,55% 73%,39% 100%,34% 68%,5% 84%,23% 55%,0 39%,31% 35%);
  filter: drop-shadow(4px 5px 0 rgba(25,22,18,.78));
}

.studio-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.studio-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, .92fr);
  gap: 1rem;
  min-height: 0;
  flex: 1;
  padding: 1rem;
}

.code-studio.preview-hidden .studio-shell {
  grid-template-columns: 1fr;
}

.code-studio.preview-hidden .preview-pane {
  display: none;
}

.editor-pane,
.preview-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 4px solid var(--panel-border);
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: 5px 6px 0 rgba(25,22,18,.84);
  overflow: hidden;
}

.pane-top {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  border-bottom: 4px solid var(--panel-border);
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.08) 0 1px, transparent 1px 12px),
    #f2ce5d;
}

.window-dots {
  display: flex;
  gap: .35rem;
}

.window-dots span {
  width: 14px;
  height: 14px;
  border: 2px solid var(--panel-border);
  border-radius: 50%;
  background: var(--accent);
}

.window-dots span:nth-child(2) {
  background: var(--accent-4);
}

.window-dots span:nth-child(3) {
  background: var(--accent-2);
}

.editor-frame {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  background: #171717;
  overflow: hidden;
}

.line-numbers {
  margin: 0;
  padding: 1rem .75rem 1rem 1rem;
  min-width: 54px;
  color: #f2ce5d;
  background: #0f0f0f;
  border-right: 3px solid #323232;
  text-align: right;
  font: 600 14px/1.55 Consolas, "Courier New", monospace;
  user-select: none;
  overflow: hidden;
}

#studio-code {
  width: 100%;
  height: 100%;
  min-height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 1rem;
  color: #f9f1d1;
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    #171717;
  background-size: 100% 24.8px;
  font: 600 14px/1.55 Consolas, "Courier New", monospace;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

.preview-top {
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background:
    repeating-radial-gradient(circle at 10px 10px, rgba(23,23,23,.12) 0 2px, transparent 2px 10px),
    #67a9d8;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  font-weight: 900;
}

.preview-controls label {
  display: flex;
  align-items: center;
  gap: .5rem;
}

#preview-width-range {
  width: min(220px, 30vw);
  accent-color: #ff6f61;
}

#preview-width-output {
  min-width: 58px;
  text-align: right;
  font-weight: 900;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 1rem;
  background:
    linear-gradient(45deg, #d8d8d8 25%, transparent 25% 75%, #d8d8d8 75%),
    linear-gradient(45deg, #d8d8d8 25%, #ececec 25% 75%, #d8d8d8 75%);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

#studio-preview {
  width: min(900px, 100%);
  min-width: 320px;
  height: 100%;
  border: 4px solid var(--panel-border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 7px 8px 0 rgba(25,22,18,.72);
}

@media (max-width: 900px) {
  .studio-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 1fr) minmax(260px, .75fr);
  }

  .studio-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .studio-actions {
    width: 100%;
    justify-content: stretch;
  }

  .studio-actions .btn {
    flex: 1;
  }

  #preview-width-range {
    width: min(190px, 48vw);
  }
}

@media (max-width: 560px) {
  .code-studio {
    inset: 0;
    border-width: 0;
    border-radius: 0;
  }

  .studio-shell {
    padding: .65rem;
    gap: .65rem;
  }

  .burst {
    display: none;
  }

  .studio-title p {
    display: none;
  }

  .editor-pane,
  .preview-pane {
    border-width: 3px;
  }

  .line-numbers,
  #studio-code {
    font-size: 12px;
  }
}

/* Light gridded paper background */
body {
  position: relative;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #f3eee2;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 920 620' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='920' height='620' fill='none'/%3E%3Cg stroke='%23a8d4dd' stroke-linecap='round' stroke-linejoin='round' opacity='.45'%3E%3Ccircle cx='104' cy='506' r='3.2' fill='%23a8d4dd' stroke='none'/%3E%3Ccircle cx='338' cy='173' r='3' fill='%23a8d4dd' stroke='none'/%3E%3Ccircle cx='480' cy='157' r='1.7' fill='%23a8d4dd' stroke='none'/%3E%3Ccircle cx='628' cy='297' r='2.1' fill='%23a8d4dd' stroke='none'/%3E%3Ccircle cx='704' cy='302' r='1.8' fill='%23a8d4dd' stroke='none'/%3E%3Ccircle cx='744' cy='386' r='3.4' fill='%23a8d4dd' stroke='none'/%3E%3Cpath d='M628 297l76 5 40 84' stroke-width='1.15' opacity='.48'/%3E%3Ccircle cx='690' cy='7' r='1.8' fill='%23a8d4dd' stroke='none'/%3E%3Ccircle cx='806' cy='8' r='2.2' fill='%23a8d4dd' stroke='none'/%3E%3Cpath d='M690 7l116 1' stroke-width='1' opacity='.35'/%3E%3Ccircle cx='777' cy='536' r='1.5' fill='%23a8d4dd' stroke='none'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(101deg, rgba(141,135,120,.055) 0 1px, transparent 1px 55px),
    linear-gradient(11deg, rgba(158,150,132,.035) 0 1px, transparent 1px 78px),
    linear-gradient(102deg, transparent 0 18%, rgba(171,161,141,.09) 18.08% 18.22%, rgba(255,255,255,.22) 18.42% 18.58%, transparent 18.82% 61%, rgba(178,168,148,.07) 61.08% 61.22%, transparent 61.46%),
    linear-gradient(67deg, transparent 0 27%, rgba(255,255,255,.24) 27.08% 27.24%, rgba(170,160,140,.08) 27.42% 27.62%, transparent 27.86% 74%, rgba(168,158,139,.06) 74.08% 74.2%, transparent 74.42%),
    radial-gradient(ellipse at 24% 32%, rgba(174,164,144,.12), transparent 18%),
    radial-gradient(ellipse at 31% 38%, rgba(255,255,255,.22), transparent 17%),
    radial-gradient(ellipse at 50% 18%, rgba(178,169,149,.08), transparent 24%),
    radial-gradient(ellipse at 78% 12%, rgba(255,255,255,.26), transparent 24%),
    radial-gradient(ellipse at 62% 66%, rgba(176,166,146,.08), transparent 25%),
    linear-gradient(180deg, #faf7ee, #eee8da 52%, #f6f1e6);
  background-size: 920px 620px, 55px 100%, 100% 78px, 100% 100%, 100% 100%, 520px 360px, 560px 380px, 820px 520px, 760px 500px, 820px 520px, 100% 100%;
  background-position: center top, 0 0, 0 0, center top, center top, 100px 90px, 125px 115px, 150px 0, 80px 15px, 40px 260px, center top;
  background-repeat: repeat;
  background-attachment: scroll;
}

body::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  min-height: 100%;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 260 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cg opacity='.2'%3E%3Ccircle cx='21' cy='32' r='.42' fill='%238f8878'/%3E%3Ccircle cx='92' cy='57' r='.32' fill='%23ffffff'/%3E%3Ccircle cx='183' cy='41' r='.4' fill='%238f8878'/%3E%3Ccircle cx='150' cy='134' r='.36' fill='%238f8878'/%3E%3Ccircle cx='55' cy='184' r='.4' fill='%23ffffff'/%3E%3Ccircle cx='220' cy='214' r='.34' fill='%238f8878'/%3E%3Cpath d='M-10 74c44-12 77 10 121-3 40-12 78-14 141 1' stroke='%23aaa18c' stroke-width='.48' fill='none' opacity='.18'/%3E%3Cpath d='M10 178c36 7 63-8 101-1 42 8 80 3 139-9' stroke='%23fffaf0' stroke-width='.6' fill='none' opacity='.25'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 260px 260px;
  opacity: .3;
  mix-blend-mode: normal;
}

body::after {
  display: none;
}

.app-card,
.panel,
.drop-zone,
.btn {
  background-blend-mode: normal;
}

.app-card {
  contain: layout paint;
  content-visibility: auto;
  contain-intrinsic-size: 220px 240px;
}

.app-card,
.btn,
.icon-btn,
.panel {
  transition-duration: .08s;
}

.app-card:hover .squircle-icon::after,
#apps-list .app-card:hover .app-info::before,
.panel:hover::after,
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon,
.edit-mode-banner,
.edit-mode-icon {
  animation: none;
}

.app-preview {
  transform: scale(0.2);
}

/* Final background: real crumpled paper texture */
html {
  background: #eee8d7;
}

body {
  background-color: #eee8d7;
  background-image: url("assets/crumpled-paper.png");
  background-size: cover;
  background-position: center top;
  background-repeat: repeat-y;
  background-attachment: scroll;
}

body::before,
body::after {
  display: none;
}

/* Foreground polish: realistic tape and paper-cut details */
#apps-list .app-info::before,
.panel::after,
.drop-zone::after {
  border: 1px solid rgba(118, 102, 54, .32);
  background:
    linear-gradient(90deg, rgba(255,255,255,.22), transparent 18% 82%, rgba(134,115,50,.13)),
    linear-gradient(180deg, rgba(255,255,255,.28), rgba(228, 203, 103, .16)),
    repeating-linear-gradient(98deg, rgba(105, 88, 38, .08) 0 1px, transparent 1px 7px),
    rgba(245, 221, 122, .64);
  box-shadow:
    0 1px 0 rgba(255,255,255,.34) inset,
    0 -1px 0 rgba(88,70,27,.12) inset,
    1px 2px 3px rgba(38,32,20,.22);
  clip-path: polygon(0 16%, 7% 0, 13% 13%, 21% 0, 29% 15%, 38% 0, 48% 12%, 57% 0, 66% 14%, 75% 0, 84% 13%, 93% 0, 100% 16%, 100% 84%, 93% 100%, 85% 87%, 76% 100%, 67% 86%, 58% 100%, 48% 88%, 39% 100%, 30% 86%, 21% 100%, 13% 87%, 6% 100%, 0 84%);
  backdrop-filter: blur(.2px);
}

#apps-list .app-info::after,
.panel .panel-head::before {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: .45;
}

#apps-list .app-info::after {
  left: 10px;
  right: 10px;
  top: -3px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.26), transparent);
}

.panel .panel-head::before {
  inset: -12px -10px auto -10px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(23,23,23,.18), transparent);
}

.app-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,252,244,.78) 38%, rgba(244,239,226,.92)),
    var(--panel);
  box-shadow:
    4px 5px 0 rgba(25,22,18,.86),
    8px 9px 0 rgba(25,22,18,.15),
    0 1px 0 rgba(255,255,255,.72) inset;
}

.app-card::before {
  border-color: rgba(23,23,23,.74);
  box-shadow: 0 0 0 1px rgba(255,255,255,.24) inset;
}

.app-info {
  background:
    linear-gradient(180deg, rgba(255,255,255,.8), transparent 55%),
    linear-gradient(90deg, rgba(23,23,23,.025) 0 1px, transparent 1px),
    #fffdf6;
  background-size: auto, 18px 100%, auto;
}

.squircle-icon {
  box-shadow:
    inset 0 10px 18px rgba(255,255,255,.16),
    inset 0 -12px 18px rgba(0,0,0,.1);
}

.preview-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(105deg, rgba(255,255,255,.12), transparent 22% 78%, rgba(0,0,0,.08)),
    radial-gradient(ellipse at 50% 5%, rgba(255,255,255,.12), transparent 35%);
}

.panel,
.options-sidebar,
.viewer-header,
.studio-bar {
  box-shadow:
    var(--sketch-shadow),
    0 1px 0 rgba(255,255,255,.55) inset;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,.78), transparent 56%),
    linear-gradient(90deg, rgba(23,23,23,.025) 0 1px, transparent 1px),
    #fffaf0;
  background-size: auto, 22px 100%, auto;
}

.btn,
.icon-btn {
  box-shadow:
    4px 5px 0 rgba(25,22,18,.82),
    7px 8px 0 rgba(25,22,18,.13),
    0 2px 0 rgba(255,255,255,.45) inset;
}

.btn::first-letter,
.icon-btn::first-letter {
  text-shadow: .5px .5px 0 rgba(255,255,255,.35);
}

.badge {
  border-radius: 10px 8px 11px 7px / 8px 11px 7px 10px;
  box-shadow:
    2px 2px 0 rgba(25,22,18,.76),
    4px 4px 0 rgba(25,22,18,.13),
    0 1px 0 rgba(255,255,255,.35) inset;
}

.drop-zone {
  background:
    radial-gradient(circle at 16px 16px, rgba(0,0,0,.1) 0 1px, transparent 2px),
    linear-gradient(180deg, rgba(255,255,255,.75), rgba(255,248,230,.78)),
    #fffef9;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.5),
    inset 0 -10px 20px rgba(0,0,0,.035);
}

.main-header {
  background:
    linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,248,230,.94)),
    rgba(255,250,240,.9);
}

/* Portfolio page compatibility layer */
:root {
  --bg-base: #f6f2e8;
  --surface: #fffdf7;
  --surface-soft: #fdf7e8;
  --primary: #e85f4c;
  --primary-dark: #c94335;
  --secondary: #3d9fb4;
  --text-main: #171717;
  --border: #171717;
}

html {
  scroll-behavior: smooth;
}

body {
  display: block;
  font-family: 'Outfit', 'Comic Neue', system-ui, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-base);
}

body,
button,
input,
textarea {
  letter-spacing: 0;
}

.mono {
  font-family: 'JetBrains Mono', Consolas, monospace;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#bg-canvas {
  z-index: 0;
  opacity: .24;
}

.container {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

section {
  padding: clamp(3rem, 8vw, 6.5rem) 0;
}

#hero {
  min-height: 92vh;
  display: grid;
  align-content: center;
  overflow: clip;
}

@supports not (overflow: clip) {
  #hero {
    overflow: hidden;
  }
}

@media (max-width: 620px) {
  #hero::before,
  #hero::after {
    display: none;
  }
}

/* Keep the page's measured width honest on mobile browsers. */
@media (max-width: 620px) {
  body {
    max-width: 100vw;
  }
}

.hero-pre,
.status-badge {
  width: fit-content;
  color: var(--secondary);
  background: rgba(255,253,247,.78);
  border: 3px solid var(--border);
  border-radius: 8px;
  box-shadow: 4px 5px 0 rgba(23,23,23,.82);
}

.hero-pre {
  padding: .55rem .8rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.hero-title {
  margin: 0;
  font-size: clamp(4rem, 14vw, 9rem);
  line-height: .88;
  font-weight: 800;
  color: #fffdf7;
  text-shadow: -3px -3px 0 var(--border), 3px -3px 0 var(--border), -3px 3px 0 var(--border), 3px 3px 0 var(--border), 8px 9px 0 var(--secondary);
}

.hero-subtitle,
.section-title {
  margin: 1rem 0 0;
  font-size: clamp(1.45rem, 4vw, 3rem);
  color: var(--text-main);
}

.section-title {
  margin-bottom: 1.5rem;
  text-decoration: underline;
  text-decoration-color: var(--accent-4);
  text-decoration-thickness: .35em;
  text-underline-offset: -.16em;
  text-decoration-skip-ink: none;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-top: 1.4rem;
  padding: .7rem .9rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(57,169,107,.55);
  animation: pulse 1.6s infinite;
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: 1.2rem;
  align-items: start;
}

.about-text,
.stat-card,
.skill-card,
.project-card,
.modal-content,
.ai-panel {
  background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,250,240,.92)), var(--surface);
  border: 3px solid var(--border);
  border-radius: 8px;
  box-shadow: 5px 6px 0 rgba(23,23,23,.82), 9px 10px 0 rgba(23,23,23,.12);
}

.about-text {
  padding: clamp(1.2rem, 3vw, 2rem);
  font-size: 1.13rem;
}

.about-text p {
  margin: 0 0 1rem;
}

.tags,
.p-tech,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}

.tag,
.t-badge,
.matched-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .7rem;
  background: var(--accent-4);
  border: 2px solid var(--border);
  border-radius: 999px;
  font-weight: 800;
}

.stats-grid,
.skills-grid {
  display: grid;
  gap: 1rem;
}

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.skill-card {
  padding: 1rem;
}

.stat-icon {
  color: var(--primary);
  font-size: 1.5rem;
}

.stat-count {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1;
  margin: .55rem 0 .25rem;
}

.skills-grid,
.projects-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.skills-grid,
.projects-grid {
  display: grid;
  gap: 1rem;
}

.skill-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .8rem;
  font-weight: 800;
}

.skill-bar-bg {
  height: 12px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: #efe4ca;
  overflow: hidden;
}

.skill-bar-fill {
  height: 100%;
}

.project-card {
  position: relative;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  cursor: pointer;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease;
}

.project-card:nth-child(2n) {
  transform: rotate(.6deg);
}

.project-card:nth-child(3n) {
  transform: rotate(-.5deg);
}

.project-card:hover {
  transform: translateY(-5px) rotate(0deg);
  box-shadow: 7px 8px 0 rgba(23,23,23,.86), 11px 12px 0 rgba(23,23,23,.12);
}

.project-card.featured {
  grid-column: span 2;
  min-height: 320px;
}

.tape {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 74px;
  height: 20px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(245,221,122,.68);
  border: 1px solid rgba(118,102,54,.32);
  z-index: 2;
}

.card-top-section {
  min-height: 145px;
  display: grid;
  place-items: center;
}

.icon-box {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border: 3px solid var(--border);
  border-radius: 8px;
  background: var(--secondary);
  color: #fffdf7;
  font-size: 2.4rem;
  box-shadow: 4px 5px 0 rgba(23,23,23,.78);
}

.card-bottom-section {
  position: relative;
  z-index: 1;
}

.p-title {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.05;
}

.p-sub {
  margin-top: .4rem;
  color: var(--text-muted);
  font-weight: 600;
}

.click-hint {
  position: absolute;
  right: .9rem;
  top: .9rem;
  color: var(--text-muted);
}

.float-icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  color: rgba(23,23,23,.08);
  font-size: 3rem;
  pointer-events: none;
}

.matched {
  outline: 4px solid var(--success);
}

.matched-badge {
  position: absolute;
  top: .7rem;
  left: .7rem;
  background: var(--success);
  color: #fff;
  z-index: 3;
}

.floating-controls {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 60;
  display: flex;
  gap: .55rem;
}

.control-btn,
.ai-fab,
.ai-send,
.btn {
  border: 3px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  font: 800 1rem/1 'Outfit', sans-serif;
  box-shadow: 4px 5px 0 rgba(23,23,23,.82);
}

.control-btn,
.ai-fab,
.ai-send {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: .8rem 1rem;
  text-decoration: none;
}

.btn-primary,
.ai-send {
  background: var(--primary);
  color: #fffdf7;
}

#contact {
  text-align: center;
}

#contact p {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  font-size: 1.15rem;
  color: var(--text-muted);
}

footer {
  padding: 2rem 0 3rem;
  text-align: center;
  color: var(--text-muted);
}

.ai-hud {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
}

.ai-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ai-panel.active {
  display: flex;
}

.ai-head,
.ai-input-wrapper {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem;
  border-bottom: 3px solid var(--border);
}

.ai-input-wrapper {
  border-top: 3px solid var(--border);
  border-bottom: 0;
}

.ai-title {
  flex: 1;
  font-weight: 800;
  color: var(--primary);
}

.ai-chat {
  flex: 1;
  overflow: auto;
  padding: .9rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.msg {
  max-width: 88%;
  padding: .65rem .8rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.msg.user {
  align-self: flex-end;
  background: #d8eef3;
}

.msg.bot {
  align-self: flex-start;
  background: #fff8df;
}

.typing {
  display: none;
  padding: 0 .9rem .75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.ai-input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  font: inherit;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(23,23,23,.56);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  position: relative;
  width: min(820px, 100%);
  max-height: min(86vh, 780px);
  overflow: auto;
  padding: clamp(1.1rem, 3vw, 2rem);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  cursor: pointer;
  font-size: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.modal-body {
  font-size: 1.08rem;
}

.modal-features ul {
  padding-left: 1.25rem;
}

.editable {
  outline: 2px dashed var(--primary);
  outline-offset: 3px;
}

.admin-top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-main);
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
}

.admin-top-left,
.admin-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-top-left {
  gap: 15px;
  color: var(--primary);
}

.btn-compact {
  padding: 4px 10px;
  font-size: .8rem;
  margin-left: 10px;
  background: var(--bg-base);
}

.btn-admin-logout {
  padding: 6px 15px;
  font-size: .9rem;
}

.save-status {
  display: none;
  margin-right: 10px;
  color: var(--success);
  font-size: .85rem;
}

.contact-button {
  padding: 15px 40px;
  font-size: 1.2rem;
}

.footer-admin-icon {
  cursor: pointer;
  margin-left: 10px;
  opacity: .3;
}

.icon-close {
  cursor: pointer;
  color: var(--text-muted);
}

.modal-narrow {
  max-width: 400px;
}

.modal-medium {
  max-width: 600px;
}

.modal-centered {
  text-align: center;
}

.modal-title {
  margin: 0 0 20px;
  color: var(--primary);
}

.modal-title-large {
  margin-bottom: 10px;
  font-size: 2rem;
}

.modal-lead {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.form-control {
  width: 100%;
  padding: 10px;
  color: var(--text-main);
  background: var(--bg-base);
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  font: inherit;
}

.form-control:focus {
  box-shadow: 0 0 0 4px rgba(61,159,180,.18);
}

.form-gap-small {
  margin-bottom: 10px;
}

.form-gap-large,
.textarea-control {
  margin-bottom: 20px;
}

.textarea-control {
  padding: 15px;
  resize: vertical;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.form-error {
  display: none;
  margin-top: 10px;
  color: var(--primary);
}

.job-match-result {
  display: none;
  margin-top: 30px;
  text-align: center;
}

.job-score {
  color: var(--success);
  font-size: 4rem;
  font-weight: 800;
  text-shadow: 2px 2px 0 #000;
}

.job-score-label {
  margin-bottom: 15px;
  font-size: 1.2rem;
  font-weight: 700;
}

.job-summary {
  margin: 0 0 25px;
  color: var(--text-muted);
  line-height: 1.6;
}

.job-loading {
  display: none;
  margin-top: 20px;
  text-align: center;
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
}

.job-loading .pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 5px;
}

.modal-card-header {
  margin-bottom: 20px;
}

.modal-icon {
  width: 80px;
  height: 80px;
  font-size: 2.5rem;
}

.project-modal-title {
  margin: 0;
  color: var(--primary);
  font-size: 2.5rem;
}

.project-modal-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.features-title {
  margin-bottom: 15px;
}

.modal-tech {
  margin-top: 20px;
}

.text-muted {
  color: var(--text-muted);
}

.project-card[draggable="true"] {
  border-style: dashed;
  cursor: move;
}

.admin-card-action {
  position: absolute;
  top: -10px;
  z-index: 10;
  display: block;
  height: inherit;
  padding: 5px 10px;
  font-size: .8rem;
  opacity: 1;
}

.admin-card-delete {
  right: -10px;
  color: #fff;
  background: var(--primary);
}

.admin-card-edit {
  right: 40px;
}

.feature-editor {
  margin-top: 20px;
  padding: 10px;
  white-space: pre-wrap;
  border: 2px dashed var(--primary);
  border-radius: 8px;
  background: var(--surface-soft);
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 9px rgba(57,169,107,0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(57,169,107,0);
  }
}

@media (max-width: 900px) {
  .about-grid {
    grid-template-columns: 1fr;
  }

  .projects-grid,
  .skills-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-card.featured {
    grid-column: span 1;
  }
}

@media (max-width: 620px) {
  .container {
    width: min(100% - 24px, 1120px);
  }

  #hero {
    min-height: 82vh;
    padding-top: 5.5rem;
  }

  .floating-controls {
    right: 12px;
    top: 12px;
  }

  .control-btn,
  .ai-fab,
  .ai-send {
    width: 42px;
    height: 42px;
  }

  .projects-grid,
  .skills-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hero-title {
    font-size: clamp(3.4rem, 21vw, 5.8rem);
    text-shadow: -2px -2px 0 var(--border), 2px -2px 0 var(--border), -2px 2px 0 var(--border), 2px 2px 0 var(--border), 5px 6px 0 var(--secondary);
  }

  .project-card {
    min-height: 235px;
  }

  .card-header {
    align-items: flex-start;
  }
}

/* Comic-book punch pass: red ink, panel detail, and lively motion */
:root {
  --primary: #d95643;
  --primary-dark: #a92f27;
  --secondary: #276f82;
  --ink-red: #d95643;
  --ink-red-dark: #8f241f;
  --ink-yellow: #f2d86b;
  --ink-blue: #3e8da3;
  --comic-shadow: 7px 8px 0 rgba(23,23,23,.88), 12px 13px 0 rgba(146,44,37,.24);
}

.container {
  width: min(1280px, calc(100% - 36px));
}

#hero {
  position: relative;
}

#hero::before,
#hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

#hero::before {
  width: min(520px, 56vw);
  height: min(520px, 56vw);
  right: -8vw;
  top: 15vh;
  opacity: .16;
  background:
    radial-gradient(circle, var(--ink-red) 0 2px, transparent 2.5px) 0 0 / 18px 18px,
    radial-gradient(circle, var(--ink-red-dark) 0 1.5px, transparent 2px) 9px 9px / 18px 18px;
  clip-path: polygon(50% 0, 58% 35%, 93% 17%, 69% 48%, 100% 59%, 63% 64%, 80% 100%, 51% 74%, 23% 100%, 37% 65%, 0 58%, 33% 47%, 9% 15%, 42% 35%);
  animation: comicFloat 6s ease-in-out infinite;
}

#hero::after {
  left: -9vw;
  bottom: 7vh;
  width: min(420px, 48vw);
  height: 160px;
  opacity: .2;
  background:
    repeating-linear-gradient(-11deg, transparent 0 13px, var(--ink-red) 14px 18px, transparent 19px 34px);
  transform: rotate(-4deg);
  animation: speedLines 1.8s steps(2, end) infinite;
}

.hero-pre,
.status-badge,
.section-title,
.tag,
.t-badge {
  transform: rotate(-1.2deg);
}

.hero-pre {
  color: var(--ink-red-dark);
  background: var(--ink-yellow);
  text-transform: uppercase;
  box-shadow: var(--comic-shadow);
  animation: labelPop .8s cubic-bezier(.22,1.5,.36,1) both;
}

.hero-title {
  color: #fffdf7;
  text-transform: uppercase;
  text-shadow:
    -4px -4px 0 var(--border),
    4px -4px 0 var(--border),
    -4px 4px 0 var(--border),
    4px 4px 0 var(--border),
    8px 8px 0 var(--ink-red),
    13px 13px 0 var(--ink-red-dark);
  animation: heroInk 3.8s ease-in-out infinite;
}

.hero-subtitle {
  width: fit-content;
  padding: .25rem .6rem;
  background: rgba(255,253,247,.74);
  border-left: 8px solid var(--ink-red);
  box-shadow: 4px 4px 0 rgba(23,23,23,.22);
}

.section-title {
  position: relative;
  width: fit-content;
  padding: .2rem .75rem .25rem;
  color: #fffdf7;
  background: var(--ink-red);
  border: 3px solid var(--border);
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--border);
  box-shadow: 5px 6px 0 rgba(23,23,23,.82);
}

.section-title::after {
  content: "";
  position: absolute;
  left: 12px;
  right: -16px;
  bottom: -13px;
  height: 12px;
  background:
    repeating-linear-gradient(135deg, var(--border) 0 4px, transparent 4px 12px);
  opacity: .55;
}

.about-text,
.stat-card,
.skill-card,
.project-card,
.modal-content,
.ai-panel {
  border-width: 4px;
  background:
    radial-gradient(circle at 14px 14px, rgba(217,86,67,.13) 0 2px, transparent 2.5px) 0 0 / 18px 18px,
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,249,235,.94)),
    var(--surface);
  box-shadow: var(--comic-shadow);
}

.about-text::first-letter {
  color: var(--ink-red);
  font-size: 2.2em;
  font-weight: 800;
  line-height: .75;
  text-shadow: 2px 2px 0 rgba(23,23,23,.22);
}

.tag,
.t-badge {
  border-width: 3px;
  background: var(--ink-yellow);
  box-shadow: 3px 4px 0 rgba(23,23,23,.78);
  transition: transform .14s ease, background .14s ease;
}

.tag:nth-child(even),
.t-badge:nth-child(even) {
  background: #ffd5ce;
}

.tag:hover,
.t-badge:hover {
  transform: translateY(-3px) rotate(1deg);
  background: #fff2a6;
}

.stats-grid,
.skills-grid,
.projects-grid {
  gap: clamp(1.05rem, 2.2vw, 1.45rem);
}

.stat-card,
.skill-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after,
.skill-card::after {
  content: "BAM";
  position: absolute;
  right: -10px;
  bottom: -12px;
  color: rgba(217,86,67,.14);
  font-size: 3rem;
  font-weight: 800;
  transform: rotate(-13deg);
}

.skill-bar-bg {
  height: 16px;
  border-width: 3px;
}

.skill-bar-fill {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 7px, transparent 7px 14px),
    var(--ink-red) !important;
  animation: barCharge 2.2s linear infinite;
}

.projects-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  align-items: start;
}

.project-card {
  min-height: 300px;
  padding: 1.25rem;
  isolation: isolate;
  animation: cardEntrance .55s cubic-bezier(.2,1.3,.35,1) both;
}

.project-card:nth-child(2n) {
  transform: rotate(1.1deg);
  animation-delay: .05s;
}

.project-card:nth-child(3n) {
  transform: rotate(-1deg);
  animation-delay: .1s;
}

.project-card:nth-child(4n) {
  animation-delay: .15s;
}

.project-card::before,
.project-card::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.project-card::before {
  inset: 8px;
  border: 2px dashed rgba(217,86,67,.28);
  border-radius: 7px;
  z-index: -1;
}

.project-card::after {
  right: -62px;
  top: -52px;
  width: 170px;
  height: 170px;
  background:
    radial-gradient(circle, rgba(217,86,67,.22) 0 2px, transparent 2.5px) 0 0 / 14px 14px;
  transform: rotate(18deg);
  opacity: .86;
}

.project-card:hover {
  transform: translate(-3px, -9px) rotate(-.7deg) scale(1.015);
  box-shadow: 11px 13px 0 rgba(23,23,23,.9), 17px 18px 0 rgba(169,47,39,.26);
}

.project-card.featured {
  grid-column: span 2;
  min-height: 450px;
}

.project-card.featured .card-top-section {
  min-height: 240px;
}

.project-card.featured .icon-box {
  width: 118px;
  height: 118px;
  font-size: 3.25rem;
}

.project-card.featured .p-title {
  font-size: clamp(2rem, 3vw, 2.55rem);
}

.project-card.featured .p-sub {
  font-size: 1.15rem;
}

.project-card.featured::after {
  width: 250px;
  height: 250px;
}

.tape {
  top: 14px;
  width: 92px;
  height: 24px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.28), transparent 20% 80%, rgba(118,83,18,.16)),
    repeating-linear-gradient(100deg, rgba(118,83,18,.12) 0 1px, transparent 1px 8px),
    rgba(246,218,106,.78);
  border: 2px solid rgba(95,75,22,.36);
  clip-path: polygon(0 14%, 8% 0, 16% 16%, 26% 0, 36% 14%, 47% 0, 58% 14%, 69% 0, 80% 16%, 91% 0, 100% 14%, 100% 86%, 91% 100%, 80% 84%, 69% 100%, 58% 86%, 47% 100%, 36% 86%, 26% 100%, 16% 84%, 8% 100%, 0 86%);
  animation: tapeJitter 2.8s ease-in-out infinite;
}

.card-top-section {
  min-height: 160px;
}

.icon-box {
  background:
    radial-gradient(circle at 28% 24%, rgba(255,255,255,.45), transparent 18%),
    linear-gradient(145deg, #e36a58, var(--ink-red-dark));
  border-width: 4px;
  border-radius: 10px 7px 11px 8px / 9px 12px 7px 11px;
  box-shadow: 6px 7px 0 rgba(23,23,23,.82);
  animation: iconBob 3.3s ease-in-out infinite;
}

.project-card:nth-child(even) .icon-box,
.stat-card:nth-child(even) .stat-icon {
  animation-delay: .45s;
}

.p-title {
  font-size: 1.7rem;
  text-shadow: 1px 1px 0 rgba(217,86,67,.22);
}

.p-sub {
  color: #5d514b;
}

.click-hint {
  color: var(--ink-red-dark);
  animation: hintBlink 1.3s steps(2, end) infinite;
}

.float-icons {
  color: rgba(217,86,67,.09);
  font-size: 3.5rem;
  transform: rotate(-8deg);
  animation: ghostDrift 5s ease-in-out infinite;
  overflow: hidden;
}

.control-btn,
.ai-fab,
.ai-send,
.btn {
  border-width: 4px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), transparent),
    var(--surface);
  box-shadow: 5px 6px 0 rgba(23,23,23,.86);
  transition: transform .13s ease, box-shadow .13s ease, background .13s ease;
}

.control-btn:hover,
.ai-fab:hover,
.btn:hover {
  transform: translate(-2px, -3px) rotate(-1deg);
  box-shadow: 8px 9px 0 rgba(23,23,23,.88), 12px 13px 0 rgba(217,86,67,.22);
}

.btn-primary,
.ai-send {
  background:
    repeating-linear-gradient(-45deg, rgba(255,255,255,.15) 0 8px, transparent 8px 16px),
    var(--ink-red);
}

.contact-button {
  position: relative;
  overflow: hidden;
}

.contact-button::after {
  content: "";
  position: absolute;
  inset: -40% -20%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.42), transparent);
  transform: translateX(-120%) rotate(18deg);
  animation: shineSlash 2.8s ease-in-out infinite;
}

.modal-overlay {
  background:
    radial-gradient(circle at center, rgba(217,86,67,.18), transparent 42%),
    rgba(23,23,23,.58);
}

.modal-content {
  border-width: 5px;
  animation: modalSlam .28s cubic-bezier(.2,1.35,.38,1) both;
}

.modal-content::before {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  border: 2px dashed rgba(217,86,67,.25);
  border-radius: 6px;
}

.project-modal-title,
.modal-title {
  color: var(--ink-red);
  text-shadow: 2px 2px 0 rgba(23,23,23,.16);
}

.modal-close {
  color: var(--border);
  transition: transform .14s ease, color .14s ease;
}

.modal-close:hover {
  color: var(--ink-red);
  transform: rotate(12deg) scale(1.15);
}

.ai-fab {
  animation: fabPulse 2.4s ease-in-out infinite;
}

@keyframes comicFloat {
  0%, 100% { transform: rotate(-4deg) translateY(0) scale(1); }
  50% { transform: rotate(2deg) translateY(-10px) scale(1.03); }
}

@keyframes speedLines {
  0%, 100% { opacity: .16; translate: 0 0; }
  50% { opacity: .24; translate: 10px -2px; }
}

@keyframes heroInk {
  0%, 100% { transform: translate(0,0) rotate(0deg); }
  45% { transform: translate(0,-3px) rotate(-.25deg); }
  52% { transform: translate(2px,-2px) rotate(.2deg); }
}

@keyframes labelPop {
  from { opacity: 0; transform: translateY(14px) rotate(-5deg) scale(.9); }
  to { opacity: 1; transform: rotate(-1.2deg) scale(1); }
}

@keyframes cardEntrance {
  from { opacity: 0; translate: 0 18px; scale: .96; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes tapeJitter {
  0%, 100% { transform: translateX(-50%) rotate(-3deg); }
  48% { transform: translateX(-50%) rotate(-1deg) translateY(-1px); }
  52% { transform: translateX(-50%) rotate(-5deg) translateY(1px); }
}

@keyframes iconBob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

@keyframes ghostDrift {
  0%, 100% { translate: 0 0; opacity: .8; }
  50% { translate: 12px -8px; opacity: 1; }
}

@keyframes hintBlink {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

@keyframes barCharge {
  from { background-position: 0 0, 0 0; }
  to { background-position: 28px 0, 0 0; }
}

@keyframes shineSlash {
  0%, 55% { transform: translateX(-120%) rotate(18deg); }
  75%, 100% { transform: translateX(120%) rotate(18deg); }
}

@keyframes modalSlam {
  from { opacity: 0; transform: translateY(18px) rotate(-1deg) scale(.96); }
  to { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes fabPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px) rotate(-2deg); }
}

@media (max-width: 900px) {
  .container {
    width: min(100% - 28px, 1280px);
  }

  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-card.featured {
    grid-column: span 2;
    min-height: 420px;
  }
}

@media (max-width: 620px) {
  #hero::before {
    right: -28vw;
    top: 18vh;
  }

  #hero::after {
    width: 260px;
  }

  .hero-title {
    text-shadow:
      -2px -2px 0 var(--border),
      2px -2px 0 var(--border),
      -2px 2px 0 var(--border),
      2px 2px 0 var(--border),
      5px 6px 0 var(--ink-red),
      8px 9px 0 var(--ink-red-dark);
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .project-card,
  .project-card.featured {
    grid-column: span 1;
    min-height: 300px;
  }

  .project-card.featured .card-top-section {
    min-height: 170px;
  }

  .project-card.featured .icon-box {
    width: 94px;
    height: 94px;
    font-size: 2.55rem;
  }
}

/* Usability refinement pass: keep the comic theme, remove friction */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

* {
  min-width: 0;
}

.container {
  width: min(1240px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
}

#hero::before,
#hero::after {
  max-width: 100vw;
  overflow: hidden;
}

.floating-controls {
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  max-width: calc(100vw - 24px);
  flex-wrap: nowrap;
}

.control-btn,
.ai-fab,
.ai-send {
  flex: 0 0 auto;
}

.projects-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  grid-auto-flow: row;
  align-items: stretch;
  gap: clamp(1rem, 1.8vw, 1.35rem);
}

.project-card,
.project-card.featured {
  grid-column: span 1;
  min-height: 315px;
  height: 100%;
  padding: 1.05rem;
}

.project-card.featured .card-top-section,
.card-top-section {
  min-height: 150px;
}

.project-card.featured .icon-box,
.icon-box {
  width: 90px;
  height: 90px;
  font-size: 2.35rem;
}

.project-card.featured .p-title,
.p-title {
  font-size: clamp(1.45rem, 2vw, 1.8rem);
}

.project-card.featured .p-sub,
.p-sub {
  font-size: 1rem;
}

.project-card.featured::after,
.project-card::after {
  width: 160px;
  height: 160px;
}

.project-card.featured .card-bottom-section::before {
  content: "FEATURED";
  display: inline-flex;
  width: fit-content;
  margin-bottom: .55rem;
  padding: .24rem .55rem;
  color: #fffdf7;
  background:
    repeating-linear-gradient(-45deg, rgba(255,255,255,.12) 0 6px, transparent 6px 12px),
    var(--ink-red);
  border: 2px solid var(--border);
  border-radius: 6px;
  box-shadow: 2px 3px 0 rgba(23,23,23,.78);
  font: 800 .72rem/1 'JetBrains Mono', monospace;
  letter-spacing: .04em;
  transform: rotate(-1deg);
}

.project-card.featured {
  outline: 3px solid rgba(217,86,67,.38);
  outline-offset: -10px;
}

.tape {
  top: 13px;
  width: 76px;
  height: 18px;
  border: 1px solid rgba(116, 93, 35, .32);
  border-radius: 2px;
  clip-path: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.25), transparent 22% 78%, rgba(112,88,28,.12)),
    linear-gradient(180deg, rgba(255,246,174,.86), rgba(235,205,92,.58));
  box-shadow:
    0 1px 0 rgba(255,255,255,.4) inset,
    1px 2px 3px rgba(38,32,20,.18);
  opacity: .9;
  animation: tapeSettle 4s ease-in-out infinite;
}

.tape::before,
.tape::after {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  background: linear-gradient(135deg, transparent 0 45%, rgba(116,93,35,.16) 46% 54%, transparent 55%);
}

.tape::before {
  left: 0;
}

.tape::after {
  right: 0;
  transform: scaleX(-1);
}

.project-card::before {
  inset: 10px;
  border-color: rgba(217,86,67,.2);
}

.project-card:hover {
  transform: translate(-2px, -6px) rotate(-.35deg);
}

.modal-overlay {
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.modal-content {
  width: min(860px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: 1rem;
}

.modal-close {
  position: sticky;
  top: .35rem;
  z-index: 40;
  margin-left: auto;
  margin-bottom: .35rem;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fffdf7;
  background: var(--ink-red);
  border: 3px solid var(--border);
  border-radius: 8px;
  box-shadow: 4px 5px 0 rgba(23,23,23,.8);
}

.modal-card-header {
  clear: both;
  padding-right: 0;
}

.modal-body,
.modal-body p,
.modal-features,
.modal-features li {
  overflow-wrap: anywhere;
}

.p-tech,
.modal-actions {
  max-width: 100%;
}

.t-badge {
  max-width: 100%;
  overflow-wrap: anywhere;
}

@keyframes tapeSettle {
  0%, 100% { transform: translateX(-50%) rotate(-2deg); }
  50% { transform: translateX(-50%) rotate(-1deg) translateY(-.5px); }
}

@media (max-width: 900px) {
  .container {
    width: min(100% - 28px, 1240px);
    max-width: calc(100vw - 28px);
  }

  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-card,
  .project-card.featured {
    min-height: 300px;
  }
}

@media (max-width: 620px) {
  html,
  body {
    overflow-x: clip;
  }

  body {
    font-size: 15px;
  }

  .container {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  section {
    padding: clamp(2.25rem, 10vw, 4rem) 0;
  }

  #hero {
    min-height: 78vh;
    padding-top: 5.75rem;
  }

  #hero::before {
    right: -42vw;
    width: 82vw;
    height: 82vw;
    opacity: .11;
  }

  #hero::after {
    left: -22vw;
    width: 78vw;
    opacity: .14;
  }

  .floating-controls {
    right: max(8px, env(safe-area-inset-right));
    top: max(10px, env(safe-area-inset-top));
    gap: 6px;
    max-width: calc(100vw - 16px);
  }

  .control-btn,
  .ai-fab,
  .ai-send {
    width: 38px;
    height: 38px;
    border-width: 3px;
    box-shadow: 3px 4px 0 rgba(23,23,23,.86);
    font-size: .86rem;
  }

  .hero-pre {
    font-size: .78rem;
  }

  .hero-title {
    max-width: calc(100vw - 30px);
    font-size: clamp(3.25rem, 19vw, 5.1rem);
    line-height: .92;
    word-break: normal;
  }

  .hero-subtitle {
    max-width: calc(100vw - 32px);
    font-size: clamp(1.2rem, 6vw, 1.55rem);
  }

  .status-badge {
    max-width: calc(100vw - 36px);
    padding: .6rem .7rem;
    font-size: .86rem;
  }

  .about-grid,
  .projects-grid,
  .skills-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .project-card,
  .project-card.featured {
    min-height: 260px;
    height: auto;
    padding: .9rem;
  }

  .project-card.featured .card-top-section,
  .card-top-section {
    min-height: 128px;
  }

  .project-card.featured .icon-box,
  .icon-box {
    width: 74px;
    height: 74px;
    font-size: 1.9rem;
  }

  .project-card.featured .p-title,
  .p-title {
    font-size: 1.38rem;
  }

  .click-hint {
    right: .65rem;
    top: .65rem;
  }

  .tape {
    width: 60px;
    height: 15px;
  }

  .modal-overlay {
    align-items: stretch;
    justify-content: center;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .modal-content {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: .75rem .85rem 1rem;
    border-width: 4px;
  }

  .modal-content::before {
    inset: 8px;
  }

  .modal-close {
    top: .15rem;
    width: 38px;
    height: 38px;
    margin-bottom: .25rem;
  }

  .modal-card-header {
    gap: .75rem;
  }

  .modal-icon {
    width: 58px;
    height: 58px;
    font-size: 1.65rem;
  }

  .project-modal-title {
    font-size: clamp(1.65rem, 8vw, 2.15rem);
  }

  .project-modal-subtitle {
    font-size: .95rem;
  }

  .modal-body {
    font-size: 1rem;
    line-height: 1.5;
  }

  .t-badge {
    padding: .4rem .62rem;
    font-size: .86rem;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .ai-hud {
    right: 10px;
    bottom: 10px;
  }

  .ai-panel {
    right: 0;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    height: min(560px, calc(100dvh - 78px));
  }
}

/* Detail and motion pass: living comic panels */
:root {
  --headline-font: 'Bangers', 'Gochi Hand', 'Outfit', cursive;
  --body-font: 'Nunito Sans', 'Outfit', system-ui, sans-serif;
}

body {
  font-family: var(--body-font);
  font-weight: 700;
}

.hero-title,
.section-title,
.p-title,
.project-modal-title,
.modal-title,
.stat-count {
  font-family: var(--headline-font);
  font-weight: 400;
  letter-spacing: .035em;
}

.hero-subtitle,
.p-sub,
.modal-body {
  font-family: var(--body-font);
}

.hero-title {
  letter-spacing: .045em;
}

.section-title {
  letter-spacing: .055em;
}

.projects-grid {
  perspective: 1400px;
}

.project-card,
.project-card.featured {
  overflow: visible;
  min-height: 330px;
  padding: 1.15rem;
  border-radius: 10px 7px 11px 8px / 8px 12px 7px 11px;
  transform-style: preserve-3d;
  transition:
    transform .22s cubic-bezier(.2, 1.2, .26, 1),
    box-shadow .22s ease,
    filter .22s ease;
}

.project-card {
  background:
    linear-gradient(130deg, rgba(255,255,255,.95) 0 18%, rgba(255,255,255,.2) 18.3% 19.2%, transparent 19.4%),
    radial-gradient(circle at 17px 17px, rgba(217,86,67,.13) 0 2px, transparent 2.7px) 0 0 / 18px 18px,
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,250,238,.95)),
    var(--surface);
}

.project-card:nth-child(odd) {
  transform: rotate(-.45deg);
}

.project-card:nth-child(even) {
  transform: rotate(.55deg);
}

.project-card:hover {
  filter: saturate(1.06);
  transform: translateY(-8px) rotate(.2deg) scale(1.012);
}

.project-card::before {
  border-style: solid;
  border-color: rgba(217,86,67,.22);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.55),
    inset 0 -8px 18px rgba(169,47,39,.035);
}

.project-card::after {
  right: -42px;
  top: -36px;
  opacity: .72;
  transition: transform .25s ease, opacity .25s ease;
}

.project-card:hover::after {
  opacity: .95;
  transform: rotate(8deg) scale(1.08);
}

.card-top-section {
  position: relative;
}

.card-top-section::before {
  content: "";
  position: absolute;
  inset: 18px 18% auto;
  height: 44px;
  opacity: .58;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(217,86,67,.28) 15px 18px, transparent 19px 34px);
  transform: rotate(-8deg);
  filter: blur(.15px);
}

.card-top-section::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 30px;
  left: 50%;
  top: 58%;
  pointer-events: none;
  background: radial-gradient(ellipse, rgba(23,23,23,.17), transparent 66%);
  transform: translateX(-50%);
}

.icon-box {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.icon-box::after {
  content: "";
  position: absolute;
  inset: -45%;
  background: linear-gradient(110deg, transparent 42%, rgba(255,255,255,.48) 47%, transparent 53%);
  transform: translateX(-58%) rotate(8deg);
  animation: iconGlint 4.2s ease-in-out infinite;
}

.p-title {
  line-height: .95;
  letter-spacing: .025em;
}

.p-sub {
  font-weight: 900;
}

.tape {
  top: -19px;
  left: 50%;
  width: 112px;
  height: 42px;
  z-index: 8;
  transform-origin: 15% 16%;
  border-radius: 4px 3px 5px 2px / 3px 5px 2px 4px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.32), transparent 18% 82%, rgba(122,95,28,.18)),
    repeating-linear-gradient(100deg, rgba(117,91,29,.12) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, rgba(255,247,173,.88) 0 48%, rgba(232,203,92,.72) 48% 100%);
  box-shadow:
    0 1px 0 rgba(255,255,255,.48) inset,
    0 -1px 0 rgba(89,70,22,.14) inset,
    1px 4px 6px rgba(38,32,20,.2);
  opacity: .96;
  animation: tapeSettle 4.8s ease-in-out infinite;
}

.tape::before,
.tape::after {
  width: 16px;
  background:
    linear-gradient(135deg, transparent 0 38%, rgba(116,93,35,.19) 39% 50%, transparent 51%),
    linear-gradient(180deg, rgba(255,247,173,.7), rgba(232,203,92,.55));
}

.tape::before {
  clip-path: polygon(0 0, 100% 12%, 82% 100%, 0 88%);
}

.tape::after {
  clip-path: polygon(18% 0, 100% 0, 100% 88%, 0 100%);
}

.project-card:hover .tape {
  animation: tapeTug .7s ease-in-out infinite alternate;
}

.project-card.is-opening {
  z-index: 80;
  pointer-events: none;
  animation: cardPopOpen .54s cubic-bezier(.18, 1.35, .25, 1) both;
}

.project-card.is-opening .tape {
  animation: tapePeel .52s cubic-bezier(.2, 1.15, .32, 1) forwards;
}

.project-card.is-opening .icon-box {
  animation: iconLaunch .5s ease both;
}

.project-card.is-opening .card-bottom-section {
  animation: titleSlide .42s ease both;
}

.project-card.is-opening::before {
  animation: panelFlash .52s ease both;
}

.project-card.featured .card-bottom-section::before {
  font-size: .78rem;
  transform: rotate(-2deg) translateY(-1px);
}

.modal-overlay.active {
  animation: overlayInk .22s ease both;
}

.modal-overlay.active .modal-content {
  animation: modalComicUnfold .42s cubic-bezier(.18, 1.18, .28, 1) both;
}

.modal-content {
  background:
    linear-gradient(135deg, rgba(255,255,255,.96) 0 16%, transparent 16.5%),
    radial-gradient(circle at 18px 18px, rgba(217,86,67,.12) 0 2px, transparent 2.8px) 0 0 / 20px 20px,
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,249,234,.96)),
    var(--surface);
}

.modal-content::after {
  content: "POW";
  position: absolute;
  right: 74px;
  top: 18px;
  z-index: 0;
  color: rgba(217,86,67,.09);
  font-family: var(--headline-font);
  font-size: clamp(3rem, 8vw, 5rem);
  transform: rotate(8deg);
  pointer-events: none;
}

.modal-card-header,
.modal-body {
  position: relative;
  z-index: 1;
}

.btn,
.control-btn,
.ai-fab {
  position: relative;
  overflow: hidden;
}

.btn::after,
.control-btn::after,
.ai-fab::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.38), transparent);
  transform: translateX(-120%) rotate(18deg);
  transition: transform .35s ease;
  pointer-events: none;
}

.btn:hover::after,
.control-btn:hover::after,
.ai-fab:hover::after {
  transform: translateX(120%) rotate(18deg);
}

@keyframes iconGlint {
  0%, 50% { transform: translateX(-62%) rotate(8deg); }
  70%, 100% { transform: translateX(62%) rotate(8deg); }
}

@keyframes tapeTug {
  from { transform: translateX(-50%) rotate(-2deg) translateY(0); }
  to { transform: translateX(-50%) rotate(1deg) translateY(-2px); }
}

@keyframes tapePeel {
  0% { transform: translateX(-50%) rotate(-2deg) translateY(0) scale(1); opacity: 1; }
  38% { transform: translateX(-58%) rotate(-18deg) translateY(-7px) scale(1.02); opacity: 1; }
  100% { transform: translateX(-92%) rotate(-72deg) translateY(-38px) scale(.86); opacity: 0; }
}

@keyframes cardPopOpen {
  0% { transform: translateY(0) rotate(0deg) scale(1); filter: brightness(1); }
  55% { transform: translateY(-14px) rotate(-1deg) scale(1.055); filter: brightness(1.06); }
  100% { transform: translateY(-18px) rotate(.5deg) scale(1.035); filter: brightness(1.03); }
}

@keyframes iconLaunch {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  55% { transform: translateY(-10px) rotate(4deg) scale(1.08); }
}

@keyframes titleSlide {
  0% { transform: translateY(0); }
  55% { transform: translateY(-5px); }
  100% { transform: translateY(-3px); }
}

@keyframes panelFlash {
  0%, 100% { border-color: rgba(217,86,67,.22); }
  45% { border-color: rgba(242,216,107,.95); box-shadow: 0 0 0 7px rgba(242,216,107,.24) inset; }
}

@keyframes overlayInk {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalComicUnfold {
  0% {
    opacity: 0;
    transform: translateY(22px) rotate(-1.8deg) scale(.92);
    clip-path: inset(48% 48% 48% 48% round 8px);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) rotate(.35deg) scale(1.015);
    clip-path: inset(0 0 0 0 round 8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
    clip-path: inset(0 0 0 0 round 8px);
  }
}

@media (max-width: 620px) {
  .project-card,
  .project-card.featured {
    min-height: 280px;
  }

  .tape {
    top: -15px;
    width: 86px;
    height: 32px;
  }

  .modal-content::after {
    right: 56px;
    top: 18px;
    font-size: 3rem;
  }

  .float-icons {
    left: 10px;
    right: 10px;
    width: auto;
    max-width: calc(100% - 20px);
    transform: none;
    font-size: 2.25rem;
  }
}

/* Smooth expressive finish: richer panels, calmer motion, lower paint cost */
:root {
  --motion-fast: 150ms;
  --motion-mid: 320ms;
  --motion-long: 760ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-bounce-soft: cubic-bezier(.18, 1.12, .28, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  text-rendering: optimizeLegibility;
}

#bg-canvas {
  opacity: .18;
  transform: translateZ(0);
}

.container {
  width: min(1220px, calc(100vw - 40px));
}

section {
  content-visibility: auto;
  contain-intrinsic-size: 1px 760px;
}

#hero,
#contact {
  content-visibility: visible;
}

#hero {
  min-height: min(860px, 92vh);
  overflow: hidden;
}

#hero::before {
  animation: smoothFloat 9s var(--ease-out) infinite;
  will-change: transform;
}

#hero::after {
  animation: panelLines 4.8s steps(3, end) infinite;
}

.hero-pre,
.hero-title,
.hero-subtitle,
.status-badge,
.section-title {
  backface-visibility: hidden;
}

.hero-title {
  animation: heroBreath 6.5s var(--ease-out) infinite;
  transform-origin: 50% 60%;
}

.status-badge {
  animation: statusSettle .7s var(--ease-bounce-soft) both .2s;
}

.about-text,
.stat-card,
.skill-card,
.project-card,
.modal-content,
.ai-panel {
  box-shadow:
    6px 7px 0 rgba(23,23,23,.84),
    11px 12px 0 rgba(169,47,39,.16),
    0 1px 0 rgba(255,255,255,.72) inset;
}

.about-text,
.stat-card,
.skill-card {
  transition: transform var(--motion-mid) var(--ease-out), box-shadow var(--motion-mid) ease;
}

.stat-card:hover,
.skill-card:hover,
.about-text:hover {
  transform: translateY(-4px) rotate(.15deg);
  box-shadow:
    8px 10px 0 rgba(23,23,23,.86),
    14px 15px 0 rgba(169,47,39,.15),
    0 1px 0 rgba(255,255,255,.72) inset;
}

.skill-card {
  min-height: 112px;
}

.skill-bar-fill {
  transform-origin: left center;
  animation: barFlow 4.8s linear infinite;
}

.projects-grid {
  perspective: 1200px;
  align-items: stretch;
}

.project-card,
.project-card.featured {
  contain: layout paint;
  min-height: 390px;
  overflow: hidden;
  transform: translateZ(0) rotate(var(--tilt, -.35deg));
  transition:
    transform var(--motion-mid) var(--ease-out),
    box-shadow var(--motion-mid) ease,
    filter var(--motion-mid) ease;
  will-change: transform;
}

.project-card:nth-child(even) {
  --tilt: .35deg;
}

.project-card:nth-child(3n) {
  --tilt: -.55deg;
}

.project-card:nth-child(5n) {
  --tilt: .65deg;
}

.project-card:hover {
  filter: saturate(1.05) contrast(1.01);
  transform: translate3d(0, -8px, 0) rotate(0deg) scale(1.01);
}

.project-card::after {
  transition: transform var(--motion-long) var(--ease-out), opacity var(--motion-mid) ease;
}

.project-card:hover::after {
  transform: rotate(8deg) scale(1.08);
}

.project-card .card-top-section::before,
.project-card .card-top-section::after,
.project-card .icon-box::after,
.project-card .tape,
.float-icons {
  will-change: transform;
}

.card-top-section {
  min-height: 138px;
}

.project-card.featured .card-top-section {
  min-height: 158px;
}

.icon-box {
  animation: iconHover 5.2s var(--ease-out) infinite;
}

.icon-box::after {
  animation: iconGlintSmooth 5.8s var(--ease-out) infinite;
}

.project-card:hover .icon-box {
  animation-play-state: paused;
  transform: translateY(-4px) rotate(1deg);
}

.tape {
  top: 11px;
  animation: tapeBreathe 7.2s var(--ease-out) infinite;
}

.project-card:hover .tape {
  animation: tapeBreathe 7.2s var(--ease-out) infinite;
}

.project-card.is-opening {
  animation: cardPopOpenSmooth .46s var(--ease-bounce-soft) both;
}

.project-card.is-opening .tape {
  animation: tapePeelSmooth .46s var(--ease-out) forwards;
}

.card-bottom-section {
  display: grid;
  gap: .58rem;
}

.p-title {
  overflow-wrap: anywhere;
}

.p-sub {
  color: #4d382f;
}

.p-desc {
  margin: .1rem 0 0;
  color: #3f3a33;
  font: 800 .94rem/1.45 var(--body-font);
}

.p-tech-preview {
  display: flex;
  flex-wrap: wrap;
  gap: .38rem;
}

.p-tech-preview span {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: .22rem .45rem;
  color: #171717;
  background: rgba(242,216,107,.86);
  border: 2px solid rgba(23,23,23,.84);
  border-radius: 6px 4px 5px 4px;
  box-shadow: 2px 2px 0 rgba(23,23,23,.72);
  font: 900 .72rem/1 var(--body-font);
}

.p-tech-preview span:nth-child(even) {
  background: rgba(168,218,230,.82);
}

.project-meter {
  position: relative;
  height: 12px;
  border: 2px solid rgba(23,23,23,.88);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,253,247,.82);
  box-shadow: 2px 2px 0 rgba(23,23,23,.68);
}

.project-meter span {
  display: block;
  width: var(--meter);
  height: 100%;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.4) 0 6px, transparent 6px 12px),
    linear-gradient(90deg, var(--ink-red), var(--ink-yellow));
  animation: meterFlow 3.8s linear infinite;
}

.float-icons {
  opacity: .7;
  animation: ghostDriftSmooth 8s var(--ease-out) infinite;
}

.btn,
.control-btn,
.ai-fab,
.ai-send {
  transition:
    transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) ease,
    background var(--motion-fast) ease;
}

.modal-overlay {
  backdrop-filter: blur(3px);
}

.modal-overlay.active .modal-content {
  animation: modalRiseSmooth .34s var(--ease-bounce-soft) both;
}

.ai-panel.active {
  animation: modalRiseSmooth .34s var(--ease-bounce-soft) both;
}

@keyframes smoothFloat {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-3deg); }
  50% { transform: translate3d(-10px, -14px, 0) rotate(2deg); }
}

@keyframes panelLines {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-4deg); opacity: .16; }
  50% { transform: translate3d(12px, -3px, 0) rotate(-3.5deg); opacity: .22; }
}

@keyframes heroBreath {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(0, -4px, 0) rotate(-.18deg); }
}

@keyframes statusSettle {
  from { opacity: 0; transform: translateY(12px) rotate(-2deg); }
  to { opacity: 1; transform: translateY(0) rotate(-1.2deg); }
}

@keyframes iconHover {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-1deg); }
  50% { transform: translate3d(0, -6px, 0) rotate(1deg); }
}

@keyframes iconGlintSmooth {
  0%, 58% { transform: translateX(-62%) rotate(8deg); }
  76%, 100% { transform: translateX(62%) rotate(8deg); }
}

@keyframes tapeBreathe {
  0%, 100% { transform: translateX(-50%) rotate(-2deg) translateY(0); }
  50% { transform: translateX(-50%) rotate(-.7deg) translateY(-1px); }
}

@keyframes ghostDriftSmooth {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-8deg); }
  50% { transform: translate3d(8px, -7px, 0) rotate(-5deg); }
}

@keyframes barFlow {
  from { background-position: 0 0, 0 0; }
  to { background-position: 56px 0, 0 0; }
}

@keyframes meterFlow {
  from { background-position: 0 0, 0 0; }
  to { background-position: 28px 0, 0 0; }
}

@keyframes cardPopOpenSmooth {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  65% { transform: translate3d(0, -14px, 0) rotate(-.7deg) scale(1.035); }
  100% { transform: translate3d(0, -11px, 0) rotate(.25deg) scale(1.018); }
}

@keyframes tapePeelSmooth {
  0% { transform: translateX(-50%) rotate(-2deg) translateY(0) scale(1); opacity: 1; }
  100% { transform: translateX(-82%) rotate(-48deg) translateY(-30px) scale(.9); opacity: 0; }
}

@keyframes modalRiseSmooth {
  from { opacity: 0; transform: translate3d(0, 18px, 0) scale(.97); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@media (max-width: 900px) {
  .project-card,
  .project-card.featured {
    min-height: 360px;
  }
}

@media (max-width: 620px) {
  .container {
    width: min(100% - 24px, 1220px);
  }

  .project-card,
  .project-card.featured {
    min-height: 0;
  }

  .p-desc {
    font-size: .9rem;
  }

  .p-tech-preview span {
    font-size: .68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #bg-canvas {
    display: none;
  }

  section {
    content-visibility: visible;
  }
}


/* Animation upgrade: realistic tape tear + x-axis project fold */
.projects-grid {
  perspective: 1600px;
  transform-style: preserve-3d;
}

.project-card,
.project-card.featured {
  contain: layout paint style;
  transform-style: preserve-3d;
  transform-origin: 50% 18px;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

.project-card:hover {
  transform: translate3d(0, -7px, 0) rotate(var(--tilt, 0deg)) rotateX(1.5deg) scale(1.008);
}

.project-card .card-top-section,
.project-card .card-bottom-section,
.project-card .icon-box,
.project-card .click-hint,
.project-card .matched-badge {
  transform: translateZ(18px);
  backface-visibility: hidden;
}

.project-card::before {
  transform: translateZ(2px);
}

.project-card::after {
  transform: translateZ(1px) rotate(0deg);
}

.tape {
  top: -18px;
  left: 50%;
  width: 118px;
  height: 38px;
  overflow: visible;
  transform: translate3d(-50%, 0, 28px) rotate(-2.5deg);
  transform-origin: 50% 52%;
  border: 1px solid rgba(92, 73, 27, .34);
  border-radius: 4px 3px 5px 4px / 3px 6px 3px 5px;
  clip-path: polygon(0 10%, 8% 0, 18% 8%, 31% 0, 44% 7%, 56% 0, 70% 8%, 84% 0, 100% 10%, 96% 100%, 82% 90%, 68% 100%, 53% 91%, 40% 100%, 24% 91%, 9% 100%, 0 90%);
  background:
    linear-gradient(90deg, rgba(255,255,255,.42), transparent 18% 82%, rgba(91,70,21,.18)),
    repeating-linear-gradient(96deg, rgba(103,82,31,.16) 0 1px, transparent 1px 8px),
    radial-gradient(circle at 28% 42%, rgba(255,255,255,.42), transparent 18%),
    linear-gradient(180deg, rgba(255,247,181,.92), rgba(221,190,74,.74));
  box-shadow:
    0 1px 0 rgba(255,255,255,.55) inset,
    0 -1px 0 rgba(84,65,21,.2) inset,
    0 8px 12px rgba(35,27,15,.18);
  animation: tapeBreatheReal 6.8s var(--ease-out) infinite;
  will-change: transform, opacity, filter;
}

.tape::before,
.tape::after {
  content: "";
  position: absolute;
  top: -1px;
  width: 61px;
  height: calc(100% + 2px);
  border: 1px solid rgba(92,73,27,.25);
  background:
    linear-gradient(90deg, rgba(255,255,255,.35), transparent 72%),
    repeating-linear-gradient(100deg, rgba(94,75,28,.15) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, rgba(255,248,185,.9), rgba(221,190,74,.72));
  box-shadow: 0 5px 10px rgba(35,27,15,.16);
  opacity: .98;
  will-change: transform, opacity, filter;
}

.tape::before {
  left: -1px;
  transform-origin: 92% 42%;
  clip-path: polygon(0 10%, 12% 0, 25% 8%, 40% 0, 58% 8%, 75% 0, 100% 7%, 94% 24%, 100% 41%, 92% 56%, 100% 75%, 93% 100%, 72% 90%, 54% 100%, 37% 91%, 18% 100%, 0 88%);
}

.tape::after {
  right: -1px;
  transform-origin: 8% 44%;
  clip-path: polygon(0 7%, 25% 0, 42% 8%, 60% 0, 75% 8%, 88% 0, 100% 10%, 100% 88%, 82% 100%, 63% 91%, 46% 100%, 28% 90%, 7% 100%, 0 76%, 8% 58%, 0 42%, 7% 24%);
}

.project-card:hover .tape {
  animation: tapeTensionReal .9s cubic-bezier(.4, 0, .2, 1) infinite alternate;
}

.project-card.is-opening,
.project-card.is-opening.featured {
  z-index: 120;
  pointer-events: none;
  animation: cardFoldOpenX .92s cubic-bezier(.18, .84, .2, 1) both;
  filter: saturate(1.04) contrast(1.015);
}

.project-card.is-opening .tape {
  animation: tapeRipCore .92s cubic-bezier(.2, .72, .18, 1) both;
}

.project-card.is-opening .tape::before {
  animation: tapeRipLeft .92s cubic-bezier(.18, .78, .18, 1) both;
}

.project-card.is-opening .tape::after {
  animation: tapeRipRight .92s cubic-bezier(.18, .78, .18, 1) both;
}

.project-card.is-opening .card-top-section {
  animation: cardTopFoldLag .92s cubic-bezier(.18, .84, .2, 1) both;
}

.project-card.is-opening .card-bottom-section {
  animation: cardContentUnfold .92s cubic-bezier(.18, .84, .2, 1) both;
}

.project-card.is-opening .icon-box {
  animation: iconSettleFold .92s cubic-bezier(.18, .84, .2, 1) both;
}

.project-card.is-opening::before {
  animation: foldHighlight .92s ease both;
}

.modal-overlay.active .modal-content {
  transform-origin: 50% 0;
  animation: modalFoldReveal .44s cubic-bezier(.2, .9, .22, 1) both;
}

@keyframes tapeBreatheReal {
  0%, 100% { transform: translate3d(-50%, 0, 28px) rotate(-2.5deg); }
  50% { transform: translate3d(-50%, -1px, 28px) rotate(-1.2deg); }
}

@keyframes tapeTensionReal {
  from { transform: translate3d(-50%, 0, 28px) rotate(-2.5deg) skewX(0deg); filter: brightness(1); }
  to { transform: translate3d(-51%, -2px, 28px) rotate(.7deg) skewX(-2deg); filter: brightness(1.04); }
}

@keyframes tapeRipCore {
  0% { transform: translate3d(-50%, 0, 34px) rotate(-2.5deg) scale(1); opacity: 1; filter: brightness(1); }
  18% { transform: translate3d(-50%, -2px, 38px) rotate(-.5deg) scaleX(1.06); opacity: 1; filter: brightness(1.08); }
  34% { transform: translate3d(-50%, -5px, 42px) rotate(-3deg) scaleX(.96); opacity: .98; filter: brightness(1.1); }
  48% { transform: translate3d(-50%, -10px, 44px) rotate(-7deg) scale(.9); opacity: .18; filter: brightness(1.16); }
  100% { transform: translate3d(-50%, -30px, 44px) rotate(-12deg) scale(.78); opacity: 0; filter: brightness(1.05); }
}

@keyframes tapeRipLeft {
  0%, 18% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); opacity: 1; }
  36% { transform: translate3d(-8px, -6px, 10px) rotate(-18deg) scale(1.02); opacity: 1; }
  58% { transform: translate3d(-38px, -26px, 18px) rotate(-54deg) scale(.94); opacity: .9; }
  100% { transform: translate3d(-86px, -58px, 24px) rotate(-98deg) scale(.82); opacity: 0; }
}

@keyframes tapeRipRight {
  0%, 18% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); opacity: 1; }
  36% { transform: translate3d(9px, -5px, 10px) rotate(18deg) scale(1.02); opacity: 1; }
  58% { transform: translate3d(42px, -23px, 18px) rotate(57deg) scale(.94); opacity: .9; }
  100% { transform: translate3d(92px, -54px, 24px) rotate(104deg) scale(.82); opacity: 0; }
}

@keyframes cardFoldOpenX {
  0% { transform: translate3d(0, 0, 0) rotate(var(--tilt, 0deg)) rotateX(0deg) scale(1); box-shadow: 6px 7px 0 rgba(23,23,23,.84), 11px 12px 0 rgba(169,47,39,.16), 0 1px 0 rgba(255,255,255,.72) inset; }
  32% { transform: translate3d(0, -5px, 18px) rotate(0deg) rotateX(-4deg) scale(1.012); }
  58% { transform: translate3d(0, -18px, 44px) rotate(0deg) rotateX(-72deg) scale(1.018); box-shadow: 0 22px 34px rgba(23,23,23,.28), 0 1px 0 rgba(255,255,255,.72) inset; }
  78% { transform: translate3d(0, -10px, 24px) rotate(0deg) rotateX(9deg) scale(1.012); }
  100% { transform: translate3d(0, -8px, 16px) rotate(0deg) rotateX(0deg) scale(1.006); box-shadow: 10px 13px 0 rgba(23,23,23,.8), 16px 18px 0 rgba(169,47,39,.14), 0 1px 0 rgba(255,255,255,.72) inset; }
}

@keyframes cardTopFoldLag {
  0%, 28% { transform: translateZ(18px) rotateX(0deg); }
  58% { transform: translateZ(30px) rotateX(10deg) translateY(-4px); }
  100% { transform: translateZ(18px) rotateX(0deg); }
}

@keyframes cardContentUnfold {
  0%, 34% { transform: translateZ(18px) rotateX(0deg); }
  60% { transform: translateZ(34px) rotateX(-16deg) translateY(6px); }
  100% { transform: translateZ(18px) rotateX(0deg); }
}

@keyframes iconSettleFold {
  0% { transform: translateY(0) rotate(-1deg) scale(1); }
  42% { transform: translateY(-8px) rotate(2deg) scale(1.04); }
  68% { transform: translateY(2px) rotate(-1deg) scale(.98); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes foldHighlight {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,255,255,.55), inset 0 -8px 18px rgba(169,47,39,.035); }
  52% { box-shadow: inset 0 34px 40px rgba(255,255,255,.42), inset 0 -18px 34px rgba(23,23,23,.12), 0 0 0 7px rgba(242,216,107,.18) inset; }
}

@keyframes modalFoldReveal {
  from { opacity: 0; transform: translate3d(0, 20px, 0) rotateX(-18deg) scale(.965); }
  to { opacity: 1; transform: translate3d(0, 0, 0) rotateX(0deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .project-card.is-opening,
  .project-card.is-opening .tape,
  .project-card.is-opening .tape::before,
  .project-card.is-opening .tape::after,
  .project-card.is-opening .card-top-section,
  .project-card.is-opening .card-bottom-section,
  .project-card.is-opening .icon-box,
  .project-card.is-opening::before,
  .modal-overlay.active .modal-content {
    animation-duration: 0.001ms !important;
  }
}

@media (max-width: 620px) {
  .tape {
    top: -13px;
    width: 92px;
    height: 30px;
  }

  .tape::before,
  .tape::after {
    width: 48px;
  }

  .project-card.is-opening,
  .project-card.is-opening.featured {
    animation-duration: .78s;
  }
}

/* Smooth project-card motion pass: lighter transforms for desktop and mobile */
:root {
  --project-card-ease: cubic-bezier(.22, .72, .18, 1);
  --project-card-open: 480ms;
}

.projects-grid {
  perspective: none;
  transform-style: flat;
}

.project-card,
.project-card.featured {
  contain: layout paint;
  transform-style: flat;
  transform-origin: 50% 50%;
  transform: translate3d(0, 0, 0) rotate(var(--tilt, -.35deg));
  transition:
    transform 260ms var(--project-card-ease),
    box-shadow 260ms ease,
    filter 260ms ease;
  will-change: auto;
}

.project-card:hover {
  filter: saturate(1.035);
  transform: translate3d(0, -6px, 0) rotate(0deg) scale(1.008);
}

.project-card:active {
  transform: translate3d(0, -2px, 0) rotate(0deg) scale(.996);
  transition-duration: 120ms;
}

.project-card .card-top-section,
.project-card .card-bottom-section,
.project-card .icon-box,
.project-card .click-hint,
.project-card .matched-badge,
.project-card::before,
.project-card::after {
  transform: none;
  backface-visibility: hidden;
}

.project-card .card-top-section,
.project-card .card-bottom-section,
.project-card .icon-box {
  transition: transform 260ms var(--project-card-ease), opacity 220ms ease;
}

.project-card:hover .card-top-section {
  transform: translate3d(0, -2px, 0);
}

.project-card:hover .card-bottom-section {
  transform: translate3d(0, -1px, 0);
}

.project-card:hover .icon-box {
  animation-play-state: paused;
  transform: translate3d(0, -4px, 0) rotate(1deg) scale(1.015);
}

.tape {
  top: -14px;
  transform: translate3d(-50%, 0, 0) rotate(-2.5deg);
  animation: tapeBreatheLite 7.2s var(--ease-out) infinite;
  will-change: auto;
}

.project-card:hover .tape {
  animation: tapeBreatheLite 7.2s var(--ease-out) infinite;
}

.tape::before,
.tape::after {
  will-change: auto;
}

.project-card.is-opening,
.project-card.is-opening.featured {
  z-index: 120;
  pointer-events: none;
  animation: cardOpenLite var(--project-card-open) var(--project-card-ease) both;
  filter: saturate(1.04);
}

.project-card.is-opening .tape {
  animation: tapeLiftLite var(--project-card-open) var(--project-card-ease) both;
}

.project-card.is-opening .tape::before,
.project-card.is-opening .tape::after {
  animation: none;
}

.project-card.is-opening .card-top-section,
.project-card.is-opening .card-bottom-section,
.project-card.is-opening .icon-box {
  animation: none;
}

.project-card.is-opening::before {
  animation: cardFlashLite var(--project-card-open) ease both;
}

.modal-overlay.active .modal-content {
  transform-origin: 50% 50%;
  animation: modalRiseSmooth .32s var(--project-card-ease) both;
}

@keyframes tapeBreatheLite {
  0%, 100% { transform: translate3d(-50%, 0, 0) rotate(-2.5deg); }
  50% { transform: translate3d(-50%, -1px, 0) rotate(-1.4deg); }
}

@keyframes cardOpenLite {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--tilt, 0deg)) scale(1);
    opacity: 1;
  }
  48% {
    transform: translate3d(0, -10px, 0) rotate(0deg) scale(1.018);
    opacity: 1;
  }
  100% {
    transform: translate3d(0, -5px, 0) rotate(0deg) scale(1.006);
    opacity: .98;
  }
}

@keyframes tapeLiftLite {
  0% {
    transform: translate3d(-50%, 0, 0) rotate(-2.5deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate3d(-50%, -18px, 0) rotate(-16deg) scale(.9);
    opacity: 0;
  }
}

@keyframes cardFlashLite {
  0%, 100% { opacity: 1; }
  45% { opacity: .82; }
}

@media (hover: none), (pointer: coarse) {
  .project-card,
  .project-card.featured {
    transition-duration: 180ms;
  }

  .project-card:hover {
    filter: none;
    transform: translate3d(0, 0, 0) rotate(var(--tilt, -.35deg));
  }

  .project-card:active {
    transform: translate3d(0, -3px, 0) rotate(0deg) scale(.992);
  }

  .project-card:hover .card-top-section,
  .project-card:hover .card-bottom-section,
  .project-card:hover .icon-box {
    transform: none;
  }

  .icon-box,
  .icon-box::after,
  .float-icons,
  .project-meter span {
    animation-duration: 8s;
  }
}

@media (max-width: 620px) {
  :root {
    --project-card-open: 420ms;
  }

  .project-card,
  .project-card.featured {
    transform: translate3d(0, 0, 0);
    transition-duration: 170ms;
  }

  .project-card.is-opening,
  .project-card.is-opening.featured {
    animation-duration: var(--project-card-open);
  }

  .tape {
    top: -11px;
    transform: translate3d(-50%, 0, 0) rotate(-2deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-card,
  .project-card.featured,
  .project-card *,
  .project-card::before,
  .project-card::after {
    animation: none !important;
    transition-duration: 0.001ms !important;
  }
}

/* Simple project-card motion: no fold, peel, or delayed opening */
.projects-grid {
  perspective: none;
  transform-style: flat;
}

.project-card,
.project-card.featured {
  transform-style: flat;
  transform-origin: 50% 50%;
  transform: translate3d(0, 0, 0) rotate(var(--tilt, -.25deg));
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.project-card:hover {
  filter: saturate(1.025);
  transform: translate3d(0, -4px, 0) rotate(0deg);
}

.project-card:active {
  transform: translate3d(0, -1px, 0) rotate(0deg) scale(.995);
  transition-duration: 90ms;
}

.project-card .card-top-section,
.project-card .card-bottom-section,
.project-card .icon-box,
.project-card .click-hint,
.project-card .matched-badge,
.project-card::before,
.project-card::after {
  transform: none;
}

.project-card .card-top-section,
.project-card .card-bottom-section,
.project-card .icon-box {
  transition: none;
}

.project-card:hover .card-top-section,
.project-card:hover .card-bottom-section,
.project-card:hover .icon-box {
  transform: none;
}

.tape,
.project-card:hover .tape,
.project-card.is-opening .tape,
.project-card.is-opening .tape::before,
.project-card.is-opening .tape::after {
  animation: none;
  transform: translate3d(-50%, 0, 0) rotate(-2.5deg);
  opacity: 1;
}

.project-card.is-opening,
.project-card.is-opening.featured,
.project-card.is-opening .card-top-section,
.project-card.is-opening .card-bottom-section,
.project-card.is-opening .icon-box,
.project-card.is-opening::before {
  animation: none;
}

.modal-overlay.active .modal-content {
  transform-origin: 50% 50%;
  animation: modalSimpleIn 180ms ease both;
}

@keyframes modalSimpleIn {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0) scale(.985);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@media (hover: none), (pointer: coarse) {
  .project-card:hover {
    filter: none;
    transform: translate3d(0, 0, 0) rotate(var(--tilt, -.25deg));
  }

  .project-card:active {
    transform: translate3d(0, -2px, 0) rotate(0deg) scale(.995);
  }
}

@media (max-width: 620px) {
  .project-card,
  .project-card.featured {
    transform: translate3d(0, 0, 0);
  }

  .tape {
    transform: translate3d(-50%, 0, 0) rotate(-2deg);
  }
}
