:root {
  --ink: #252632;
  --muted: #747583;
  --line: #dedee8;
  --paper: #fff;
  --soft: #f7f7fc;
  --violet: #635bff;
  --coral: #ff4d57;
  --blue: #3eb4e8;
  --green: #76bf58;
  --yellow: #ffcc19;
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #e7e7f0;
  --muted: #9b9caa;
  --line: #34364a;
  --paper: #1b1c27;
  --soft: #101017;
  --violet: #8079ff;
  --coral: #ff6b74;
  --blue: #5cc3f0;
  --green: #8fd473;
  --yellow: #ffd84d;
  color-scheme: dark;
}

body {
  transition: background-color 0.2s ease, color 0.2s ease;
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.nav {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 38px;
  padding: 0 clamp(24px, 5vw, 82px);
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.logo {
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -1.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gem {
  width: 24px;
  height: 24px;
  border-radius: 8px 8px 8px 2px;
  display: inline-block;
  transform: rotate(-45deg);
  background: linear-gradient(135deg, #7b74ff, #3db8eb);
}

.links {
  display: flex;
  gap: 27px;
  align-items: center;
  flex: 1;
}

.links a {
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  color: var(--ink);
}

.login {
  font-size: 14px;
  border: 0;
  background: transparent;
  font-weight: 700;
}

.signup {
  background: var(--violet);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 800;
}

.menu {
  font-size: 22px;
  border: 0;
  background: transparent;
}

.hero {
  min-height: 455px;
  text-align: center;
  padding: 70px 20px 80px;
  overflow: hidden;
  position: relative;
  background: radial-gradient(circle at 2% 0, #e6ecff, transparent 28%), radial-gradient(circle at 98% 85%, #f3e8ff, transparent 35%), #fbfbff;
}

.hero:before, .hero:after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 50px solid #eef1ff;
  width: 340px;
  height: 340px;
  opacity: 0.6;
}

.hero:before {
  left: -180px;
  top: 105px;
}

.hero:after {
  right: -180px;
  top: -220px;
}

.eyebrow {
  color: var(--violet);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(34px, 4vw, 55px);
  letter-spacing: -2.7px;
  margin: 12px 0 13px;
  line-height: 1.05;
}

.hero p {
  margin: 0 auto;
  color: #5d5e6a;
  font-size: 19px;
  max-width: 610px;
}

.upload {
  margin: 34px auto 12px;
  width: min(550px, 100%);
  min-height: 150px;
  padding: 24px;
  border: 2px dashed #bfc1d5;
  border-radius: 18px;
  background: #fff;
  position: relative;
  z-index: 1;
  transition: 0.2s;
}

.upload.drag {
  border-color: var(--violet);
  background: #f6f5ff;
  transform: scale(1.01);
}

.upload-btn-wrap {
  position: relative;
  display: inline-block;
  margin: 10px 0 20px;
}

.upload-btn-wrap:after {
  content: "";
  height: 100%;
  width: 100%;
  padding: 4px;
  position: absolute;
  bottom: -12px;
  left: -4px;
  z-index: 0;
  background-color: #1e175d;
  border-radius: 12px;
}

.upload button {
  position: relative;
  z-index: 1;
  display: block;
  color: #ffffff;
  font-family: inherit;
  font-weight: 800;
  font-size: 20px;
  text-align: center;
  text-decoration: none;
  background-color: var(--violet);
  padding: 16px 42px;
  border: none;
  cursor: pointer;
  outline: none;

  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4);

  box-shadow: inset 0 1px 0 #b3adff, 0 10px 0 #3b33ab;
  border-radius: 12px;
  transition: background-color 0.1s ease, top 0.1s ease, box-shadow 0.1s ease;
}

.upload button:hover {
  background-color: #554de8;
  box-shadow: inset 0 1px 0 #c4beff, 0 10px 0 #312898;
}

.upload button:active {
  top: 8px;
  background-color: #4840d6;
  box-shadow: inset 0 1px 0 #b3adff, inset 0 -3px 0 #312898;
}

.upload small {
  display: block;
  color: #787987;
  margin-top: 15px;
}

.supported {
  font-size: 13px;
  color: #777987;
}

.supported b {
  color: #4a4b56;
}

.tools {
  padding: 65px clamp(20px, 8vw, 150px) 82px;
  background: #fff;
}

.section-head {
  text-align: center;
}

.section-head h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -1.25px;
}

.section-head p {
  color: var(--muted);
  margin: 9px 0 23px;
}

.filters {
  display: flex;
  gap: 9px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 31px;
}

.filter {
  border: 1px solid #d9dae5;
  color: #595a67;
  border-radius: 30px;
  padding: 8px 18px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.filter.active {
  background: #292a35;
  color: #fff;
  border-color: #292a35;
}

.grid {
  max-width: 1420px;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 23px 23px 20px;
  min-height: 212px;
  background: #fff;
  transition: 0.2s;
  cursor: pointer;
  position: relative;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 25px #292a3514;
  border-color: #bab9d1;
}

.icon {
  height: 47px;
  width: 47px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  margin-bottom: 18px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.card p {
  font-size: 13px;
  line-height: 1.42;
  color: #777885;
  margin: 0;
}

.tag {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #eaf7ff;
  color: #23799d;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 10px;
  font-weight: 800;
}

.how {
  background: #292a35;
  color: #fff;
  padding: 70px max(20px, 12vw);
  display: flex;
  gap: 75px;
  align-items: center;
}

.how h2 {
  font-size: 30px;
  letter-spacing: -1px;
  margin: 0 0 10px;
}

.how p {
  color: #c3c4ce;
  line-height: 1.5;
  max-width: 450px;
}

.steps {
  display: flex;
  gap: 26px;
}

.step {
  width: 145px;
}

.num {
  color: #a9a5ff;
  font-size: 28px;
  font-weight: 850;
}

.step b {
  display: block;
  margin: 6px 0;
}

.step span {
  font-size: 13px;
  color: #bdbec7;
  line-height: 1.4;
}

.modal {
  position: fixed;
  inset: 0;
  background: #20212b88;
  z-index: 10;
  display: none;
  place-items: center;
  padding: 20px;
}

.modal.show {
  display: grid;
}

.panel {
  background: #fff;
  border-radius: 18px;
  width: min(580px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 26px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25);
}

.panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 19px;
}

.panel h2 {
  font-size: 23px;
  margin: 0;
}

.close {
  border: 0;
  background: #f0f0f5;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close:hover {
  background: #e2e2ea;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  background: #f7f7fb;
  border-radius: 10px;
  margin: 10px 0;
}

.file-row .fileicon {
  font-size: 24px;
}

.file-row div {
  flex: 1;
  min-width: 0;
}

.file-row strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-row span {
  font-size: 12px;
  color: var(--muted);
}

.remove {
  border: 0;
  background: transparent;
  color: #8d8e99;
  font-size: 20px;
  cursor: pointer;
}

.remove:hover {
  color: var(--coral);
}

.controls {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.controls select {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px;
  background: #fff;
}

.convert {
  border: 0;
  border-radius: 9px;
  background: var(--violet);
  color: #fff;
  font-weight: 800;
  padding: 11px 17px;
  cursor: pointer;
  transition: background 0.2s;
}

.convert:hover {
  background: #5248e5;
}

.result {
  display: none;
  border-radius: 9px;
  padding: 13px;
  font-size: 14px;
}

.result.show {
  display: block;
}

.result-ok {
  background: #eaffea;
  color: #347443;
}

.result-err {
  background: #fff2f2;
  color: #b03a3f;
}

.result-info {
  background: #eef1ff;
  color: #4b48b0;
}

.msg-ok {
  color: #347443;
}

.msg-err {
  color: #b03a3f;
}

.editor {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  line-height: 1.5;
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.outline {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s;
}

.outline:hover {
  background: #f0f0f5;
}

.print-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 17px;
  display: inline-grid;
  place-items: center;
}

@media(max-width:900px) {
  .links { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .how { flex-direction: column; align-items: flex-start; gap: 25px; }
  .nav { gap: 14px; }
  .login { margin-left: auto; }
}

@media(max-width:530px) {
  .grid { grid-template-columns: 1fr; }
  .hero { padding-top: 52px; }
  .hero p { font-size: 16px; }
  .steps { gap: 15px; }
  .step { width: auto; flex: 1; }
  .signup { display: none; }
  .tools { padding: 45px 16px; }
  .card { min-height: 180px; }
}

.editor-actions .convert {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 0;
  display: inline-grid;
  place-items: center;
}

.editor-actions .convert:after {
  content: '🖨';
  font-size: 17px;
}

/* ---------- Dark theme ---------- */

.game-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 16px;
}

.game-overlay.show {
  display: flex;
}

.game-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  max-width: 100%;
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#gameScore {
  font-weight: 700;
  white-space: nowrap;
}

#gameStatus {
  color: var(--muted);
  font-size: 12px;
}

.game-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.game-tip {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  margin-top: 8px;
}

#gameCanvas {
  display: block;
  background: #10121a;
  border-radius: 8px;
  max-width: 100%;
  height: auto;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: background 0.2s;
}

.theme-toggle:hover {
  background: var(--soft);
}

[data-theme="dark"] .nav {
  background: var(--paper);
}

[data-theme="dark"] .hero {
  background: radial-gradient(circle at 2% 0, #232544, transparent 28%), radial-gradient(circle at 98% 85%, #2a2140, transparent 35%), var(--soft);
}

[data-theme="dark"] .hero:before,
[data-theme="dark"] .hero:after {
  border-color: #1e2036;
}

[data-theme="dark"] .hero p {
  color: #b3b4c2;
}

[data-theme="dark"] .upload {
  background: var(--paper);
  border-color: #3c3e54;
}

[data-theme="dark"] .upload.drag {
  background: #211f3a;
}

[data-theme="dark"] .upload small {
  color: #8f90a0;
}

[data-theme="dark"] .supported {
  color: #8f90a0;
}

[data-theme="dark"] .supported b {
  color: #c6c7d4;
}

[data-theme="dark"] .tools {
  background: var(--paper);
}

[data-theme="dark"] .filter {
  background: var(--paper);
  color: #b3b4c2;
  border-color: #3c3e54;
}

[data-theme="dark"] .filter.active {
  background: var(--violet);
  color: #fff;
  border-color: var(--violet);
}

[data-theme="dark"] .card {
  background: #20212f;
  border-color: #34364a;
}

[data-theme="dark"] .card:hover {
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.45);
  border-color: #4a4c66;
}

[data-theme="dark"] .card p {
  color: #a3a4b4;
}

[data-theme="dark"] .tag {
  background: #142c40;
  color: #6fcaff;
}

[data-theme="dark"] .how p {
  color: #b3b4c2;
}

[data-theme="dark"] .step span {
  color: #a3a4b4;
}

[data-theme="dark"] .modal {
  background: #05050a99;
}

[data-theme="dark"] .panel {
  background: var(--paper);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .close {
  background: #2a2c3d;
  color: var(--ink);
}

[data-theme="dark"] .close:hover {
  background: #363850;
}

[data-theme="dark"] .file-row {
  background: #232433;
}

[data-theme="dark"] .remove {
  color: #9596a5;
}

[data-theme="dark"] .controls select {
  background: #20212f;
  border-color: #3c3e54;
  color: var(--ink);
}

[data-theme="dark"] .convert:hover {
  background: #786fff;
}

[data-theme="dark"] .editor {
  background: #191a24;
  border-color: #3c3e54;
  color: var(--ink);
}

[data-theme="dark"] .outline {
  background: #20212f;
  border-color: #3c3e54;
  color: var(--ink);
}

[data-theme="dark"] .outline:hover {
  background: #2a2c3d;
}

[data-theme="dark"] .print-icon {
  background: #20212f;
  border-color: #3c3e54;
  color: var(--ink);
}

[data-theme="dark"] .result-ok {
  background: #12301c;
  color: #7fe0a0;
}

[data-theme="dark"] .result-err {
  background: #3a1418;
  color: #ff9a9f;
}

[data-theme="dark"] .result-info {
  background: #1c1f3a;
  color: #a6a4ff;
}

[data-theme="dark"] .msg-ok {
  color: #7fe0a0;
}

[data-theme="dark"] .msg-err {
  color: #ff9a9f;
}
