:root {
  color-scheme: light;
  --bg: #b9b4aa;
  --panel: rgba(214, 210, 199, 0.96);
  --panel-strong: #eee9dc;
  --ink: #1d1d1d;
  --muted: #4f4b46;
  --cyan: #595959;
  --pink: #b21f2d;
  --lime: #6c6a64;
  --yellow: #c8b66b;
  --danger: #b21f2d;
  --switch-blue: #595959;
  --switch-red: #b21f2d;
  --switch-dark: #1d1d1d;
  --line: rgba(255, 255, 255, 0.16);
  --pixel-shadow: 6px 6px 0 #1d1d1d;
  --corner: 8px;
  font-family: "Courier New", "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(45deg, rgba(29, 29, 29, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(29, 29, 29, 0.05) 25%, transparent 25%),
    linear-gradient(90deg, #1d1d1d 0 72px, #b9b4aa 72px calc(100% - 72px), #b21f2d calc(100% - 72px) 100%);
  background-size: 16px 16px, 16px 16px, auto;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(29, 29, 29, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 29, 29, 0.08) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 85%);
}

.draw-canvas {
  position: fixed;
  inset: 0;
  z-index: 18;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  touch-action: none;
}

.draw-canvas.is-drawing-enabled {
  cursor: crosshair;
  pointer-events: auto;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 110px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border: 4px solid #1d1d1d;
  border-radius: var(--corner);
  padding: 14px;
  background: #d6d2c7;
  box-shadow: var(--pixel-shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  flex: 0 0 auto;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 0 16px;
  background: #1d1d1d;
  color: #eee9dc;
  box-shadow: 4px 4px 0 #7b756d;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 68px;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid #1d1d1d;
  border-radius: var(--corner);
  background: linear-gradient(90deg, #d6d2c7 0 62%, var(--switch-red) 62% 100%);
  color: #1d1d1d;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: var(--pixel-shadow);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
  text-shadow: 3px 3px 0 #eee9dc;
}

.brand p,
.hint,
.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: stretch;
}

.play-zone,
.notes-zone {
  border: 4px solid #1d1d1d;
  border-radius: var(--corner);
  background: var(--panel);
  box-shadow: 7px 7px 0 #1d1d1d;
}

.play-zone {
  padding: 18px;
}

.run-warning {
  margin-bottom: 14px;
  border: 2px solid rgba(255, 225, 92, 0.65);
  border-radius: var(--corner);
  padding: 12px 14px;
  background: rgba(255, 225, 92, 0.12);
  color: #fff4a8;
  font-weight: 900;
  line-height: 1.35;
}

.notes-zone {
  display: flex;
  min-height: 560px;
  padding: 18px;
  flex-direction: column;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border-bottom: 4px solid #1d1d1d;
  padding-bottom: 12px;
}

.game-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.inline-card-form {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.inline-card-form[hidden] {
  display: none;
}

.inline-card-form input {
  min-width: min(260px, 100%);
  min-height: 44px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 0 12px;
  background: #eee9dc;
  color: #1d1d1d;
  font: 800 1rem/1 "Segoe UI", sans-serif;
  box-shadow: 4px 4px 0 #000000;
}

.game-menu {
  position: relative;
}

.game-menu summary {
  list-style: none;
}

.game-menu summary::-webkit-details-marker {
  display: none;
}

.section-head.compact {
  margin-bottom: 12px;
}

.notes-head {
  align-items: flex-start;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.4rem, 2.5vw, 2.2rem);
}

.file-button,
button {
  border: 0;
  border-radius: 0;
  color: #101326;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  background: #1d1d1d;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  color: #eee9dc;
  box-shadow: 4px 4px 0 #7b756d;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button:hover,
button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.screen-wrap {
  position: relative;
  overflow: hidden;
  border: 10px solid #1d1d1d;
  border-radius: var(--corner);
  background: #060714;
  box-shadow: inset 0 0 0 4px #595959;
}

.screen-glow {
  display: none;
}

.emulator-mount {
  position: relative;
  display: grid;
  min-height: 500px;
  place-items: center;
  background:
    linear-gradient(rgba(9, 11, 18, 0.28), rgba(9, 11, 18, 0.78)),
    url("images/wallpaper.jpg") center / cover no-repeat,
    #090b18;
  image-rendering: pixelated;
}

.emulator-mount iframe {
  width: 100%;
  height: 500px;
  border: 0;
  background: #000;
}

.empty-state {
  display: grid;
  width: min(430px, 90%);
  justify-items: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  border: 3px solid rgba(238, 233, 220, 0.75);
  border-radius: var(--corner);
  background: rgba(29, 29, 29, 0.72);
  color: #eee9dc;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
}

.empty-state h3,
.empty-state p {
  color: #eee9dc;
  text-shadow: 2px 2px 0 #000000;
}

.pixel-device {
  display: grid;
  width: 126px;
  aspect-ratio: 1.45;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px;
  border: 4px solid #1d1d1d;
  border-radius: var(--corner);
  background: linear-gradient(135deg, #d6d2c7, #b21f2d);
  box-shadow: 8px 8px 0 #000000;
}

.pixel-device span {
  border-radius: 3px;
  background: rgba(9, 11, 24, 0.88);
}

.pixel-device span:first-child {
  grid-column: span 2;
}

.game-library {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  display: none;
  width: min(430px, calc(100vw - 36px));
  max-height: 380px;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
  border: 4px solid #1d1d1d;
  border-radius: var(--corner);
  padding: 12px;
  background: #2a2a2a;
  box-shadow: 6px 6px 0 #1d1d1d;
}

.game-menu:hover .game-library,
.game-menu:focus-within .game-library,
.game-menu[open] .game-library {
  display: grid;
}

.game-library p {
  grid-column: 1 / -1;
  color: #eee9dc;
  line-height: 1.45;
}

.game-library-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.game-search-wrap {
  position: relative;
  display: block;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  color: #1d1d1d;
  font-size: 1.15rem;
  font-weight: 900;
  pointer-events: none;
  transform: translateY(-50%);
}

.game-search {
  width: 100%;
  min-height: 46px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 0 12px 0 38px;
  outline: 0;
  background: #eee9dc;
  color: #1d1d1d;
  font: 900 1rem/1 "Segoe UI", sans-serif;
  box-shadow: 4px 4px 0 #000000;
}

.game-search:focus {
  box-shadow: 0 0 0 4px rgba(200, 182, 107, 0.32);
}

.game-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.game-card,
.game-upload {
  min-height: 50px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 10px;
  background: #d6d2c7;
  color: var(--switch-dark);
  box-shadow: 4px 4px 0 #000000;
  text-align: left;
}

.game-upload {
  display: inline-grid;
  min-width: 74px;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 900;
  text-align: center;
}

.game-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.game-card:hover,
.game-upload:hover {
  background: var(--switch-red);
  color: #eee9dc;
}

.keyboard-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: center;
  margin-top: 16px;
  border: 4px solid var(--switch-dark);
  border-radius: var(--corner);
  padding: 14px;
  background: #8f897f;
  box-shadow: 5px 5px 0 var(--switch-dark);
  touch-action: manipulation;
}

.keyboard-block {
  display: grid;
  gap: 8px;
}

.keyboard-block.arrows {
  grid-template-columns: repeat(3, 70px);
}

.keyboard-block.actions {
  grid-template-columns: repeat(4, 82px);
}

.key {
  display: grid;
  width: 100%;
  min-height: 58px;
  place-items: center;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 4px;
  background: #d6d2c7;
  color: var(--switch-dark);
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--switch-dark);
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.virtual-key {
  appearance: none;
}

.virtual-key.is-pressed,
.virtual-key:active {
  filter: brightness(1.18);
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--switch-dark);
}

.key small {
  display: block;
  color: inherit;
  font-size: 0.64rem;
  line-height: 1;
}

.key.ghost {
  visibility: hidden;
}

.key.blue,
.key.cyan {
  background: #4a4a4a;
  color: #eee9dc;
}

.key.red {
  background: var(--switch-red);
  color: #eee9dc;
}

.key.gray {
  background: var(--switch-dark);
  color: #eee9dc;
}

.key.wide {
  grid-column: span 2;
}

textarea {
  width: 100%;
  min-height: 390px;
  flex: 1;
  resize: vertical;
  border: 4px solid #1d1d1d;
  border-radius: var(--corner);
  padding: 16px;
  outline: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    #eee9dc;
  color: var(--switch-dark);
  font: 1rem/1.55 "Segoe UI", sans-serif;
}

textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(53, 231, 255, 0.18);
}

.notes-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin: 0;
}

.voice-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--switch-blue);
  border: 3px solid #1d1d1d;
  box-shadow: 5px 5px 0 #080914;
}

.voice-button.listening {
  background: var(--switch-red);
  box-shadow: 5px 5px 0 #080914;
}

.mic-dot {
  width: 12px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #101326;
  box-shadow: 0 0 0 5px rgba(16, 19, 38, 0.18);
}

.ghost-button {
  min-height: 44px;
  padding: 0 14px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  background: #d6d2c7;
  color: var(--switch-dark);
  box-shadow: 4px 4px 0 #000000;
}

.paint-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  gap: 10px;
  justify-items: end;
}

.paint-fab {
  min-height: 48px;
  border: 3px solid #1d1d1d;
  border-radius: var(--corner);
  padding: 0 16px;
  background: #d6d2c7;
  color: var(--switch-dark);
  box-shadow: 5px 5px 0 #000000;
}

.paint-dock.open .paint-fab {
  background: var(--switch-red);
  color: #eee9dc;
}

.paint-toolbar {
  display: flex;
  width: min(720px, calc(100vw - 36px));
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 4px solid #1d1d1d;
  border-radius: var(--corner);
  padding: 10px;
  background: var(--switch-dark);
  box-shadow: var(--pixel-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.paint-dock.open .paint-toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tool-button {
  min-height: 44px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 0 12px;
  background: #d6d2c7;
  color: var(--switch-dark);
  box-shadow: 4px 4px 0 #000000;
  opacity: 0.65;
  transition: opacity 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.tool-button.active {
  background: #16a34a;
  color: #ffffff;
  opacity: 1;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.35);
  animation: tool-pulse 1.6s ease infinite;
}

.tool-button.danger {
  background: var(--switch-red);
  color: #eee9dc;
  opacity: 1;
}

@keyframes tool-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.35); }
  50%      { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0.08); }
}

.swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 36px;
  height: 36px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  background: var(--swatch);
  box-shadow: 4px 4px 0 #000000;
}

.swatch.active {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
}

.hint {
  margin-top: 10px;
  font-size: 0.92rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Card Board ── */

.card-board {
  position: relative;
  z-index: 28;
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 110px;
}

.card-board-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 0;
  border: 4px solid #1d1d1d;
  border-bottom: 0;
  border-radius: var(--corner) var(--corner) 0 0;
  padding: 14px 18px;
  background: #d6d2c7;
  box-shadow: var(--pixel-shadow);
  flex-wrap: wrap;
}

.card-board-head h2 {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  margin: 0;
}

.board-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.board-color-picker {
  -webkit-appearance: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 3px solid #1d1d1d;
  border-radius: 8px;
  cursor: pointer;
  background: none;
}
.board-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
.board-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.card-board-surface {
  position: relative;
  min-height: 500px;
  border: 4px solid #1d1d1d;
  border-radius: 0 0 var(--corner) var(--corner);
  padding: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 18px,
      rgba(29, 29, 29, 0.03) 18px,
      rgba(29, 29, 29, 0.03) 19px
    ),
    #e8e0d0;
  box-shadow: var(--pixel-shadow);
  overflow: hidden;
}

.board-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.board-empty-hint {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #7b756d;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

/* ── Card Layer (inside board surface) ── */

.card-layer {
  position: fixed;
  inset: 0;
  z-index: 32;
  pointer-events: none;
}

.floating-card {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
  max-width: min(320px, calc(100vw - 32px));
  min-height: 52px;
  border: 2px solid rgba(29, 29, 29, 0.28);
  border-radius: 8px;
  padding: 10px 10px 10px 14px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  transition: box-shadow 160ms ease;
}

.floating-card:active {
  cursor: grabbing;
  box-shadow: 6px 8px 18px rgba(0, 0, 0, 0.22);
}

.floating-card[data-color="pink"]   { background: #fce7f3; }
.floating-card[data-color="yellow"] { background: #fef3c7; }
.floating-card[data-color="blue"]   { background: #dbeafe; }
.floating-card[data-color="green"]  { background: #dcfce7; }
.floating-card[data-color="purple"] { background: #ede9fe; }

.card-text {
  flex: 1;
  color: #1c1917;
  font: 800 1rem/1.25 "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  word-break: break-word;
  pointer-events: none;
}

.card-controls {
  display: flex;
  gap: 4px;
}

.card-close, .card-pin {
  display: grid;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: rgba(0, 0, 0, 0.12);
  color: #1c1917;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  opacity: 0.6;
  pointer-events: auto;
  transition: opacity 120ms ease, background 120ms ease;
}

.board-text-input {
  position: absolute;
  z-index: 12;
  min-width: 180px;
  max-width: min(420px, calc(100% - 24px));
  border: 2px dashed rgba(29, 29, 29, 0.42);
  border-radius: 6px;
  padding: 4px 6px;
  outline: 0;
  background: rgba(255, 255, 255, 0.74);
  font: 800 20px/1.2 "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.card-close:hover {
  opacity: 1;
  background: rgba(220, 38, 38, 0.25);
}

.card-pin:hover {
  opacity: 1;
  background: rgba(34, 197, 94, 0.25);
}

.theme-options {
  display: flex;
  gap: 8px;
}

.theme-btn {
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.theme-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.theme-toggle {
  display: none; /* old toggle */
}

.create-card-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 3px solid #1d1d1d;
  border-radius: 6px;
  padding: 0 14px;
  background: #fef3c7;
  color: #1c1917;
  font-weight: 900;
  box-shadow: 4px 4px 0 #000000;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.create-card-button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

body.modern-theme {
  --bg: #10151f;
  --panel: rgba(22, 30, 43, 0.92);
  --panel-strong: #1f2a3a;
  --ink: #edf4ff;
  --muted: #9fb0c7;
  --cyan: #66d9ff;
  --pink: #7c5cff;
  --lime: #7ee787;
  --yellow: #ffd166;
  --danger: #ff6b6b;
  --switch-blue: #66d9ff;
  --switch-red: #7c5cff;
  --switch-dark: #0d1117;
  --pixel-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --corner: 18px;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(102, 217, 255, 0.24), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(124, 92, 255, 0.26), transparent 26%),
    linear-gradient(135deg, #0d1117 0%, #10151f 52%, #171d2a 100%);
}

body.modern-theme::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

body.modern-theme .topbar,
body.modern-theme .play-zone,
body.modern-theme .notes-zone,
body.modern-theme .keyboard-guide {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

body.modern-theme .brand-mark {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, #66d9ff, #7c5cff);
  color: #ffffff;
  box-shadow: 0 16px 36px rgba(102, 217, 255, 0.24);
}

body.modern-theme h1 {
  text-shadow: none;
}

body.modern-theme .section-head {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

body.modern-theme .file-button,
body.modern-theme .theme-toggle,
body.modern-theme .paint-fab,
body.modern-theme .voice-button,
body.modern-theme .ghost-button,
body.modern-theme .tool-button,
body.modern-theme .game-card,
body.modern-theme .game-upload,
body.modern-theme .inline-card-form input {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, rgba(102, 217, 255, 0.16), rgba(124, 92, 255, 0.24));
  color: #edf4ff;
  box-shadow: none;
}

body.modern-theme .screen-wrap {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
}

body.modern-theme .game-library,
body.modern-theme .paint-toolbar {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(13, 17, 23, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

body.modern-theme .key {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

body.modern-theme textarea {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(13, 17, 23, 0.72);
  color: #edf4ff;
}

body.modern-theme .hint,
body.modern-theme .brand p {
  color: var(--muted);
}

body:has(#themeSwitch:checked) {
  --bg: #10151f;
  --panel: rgba(22, 30, 43, 0.92);
  --panel-strong: #1f2a3a;
  --ink: #edf4ff;
  --muted: #9fb0c7;
  --cyan: #66d9ff;
  --pink: #7c5cff;
  --lime: #7ee787;
  --yellow: #ffd166;
  --danger: #ff6b6b;
  --switch-blue: #66d9ff;
  --switch-red: #7c5cff;
  --switch-dark: #0d1117;
  --pixel-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --corner: 18px;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(102, 217, 255, 0.24), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(124, 92, 255, 0.26), transparent 26%),
    linear-gradient(135deg, #0d1117 0%, #10151f 52%, #171d2a 100%);
}

body:has(#themeSwitch:checked)::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

body:has(#themeSwitch:checked) .topbar,
body:has(#themeSwitch:checked) .play-zone,
body:has(#themeSwitch:checked) .notes-zone,
body:has(#themeSwitch:checked) .keyboard-guide {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

body:has(#themeSwitch:checked) .brand-mark {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, #66d9ff, #7c5cff);
  color: #ffffff;
  box-shadow: 0 16px 36px rgba(102, 217, 255, 0.24);
}

body:has(#themeSwitch:checked) h1 {
  text-shadow: none;
}

body:has(#themeSwitch:checked) .section-head {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

body:has(#themeSwitch:checked) .file-button,
body:has(#themeSwitch:checked) .theme-toggle,
body:has(#themeSwitch:checked) .paint-fab,
body:has(#themeSwitch:checked) .voice-button,
body:has(#themeSwitch:checked) .ghost-button,
body:has(#themeSwitch:checked) .tool-button,
body:has(#themeSwitch:checked) .game-card,
body:has(#themeSwitch:checked) .game-upload {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, rgba(102, 217, 255, 0.16), rgba(124, 92, 255, 0.24));
  color: #edf4ff;
  box-shadow: none;
}

body:has(#themeSwitch:checked) .screen-wrap {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
}

body:has(#themeSwitch:checked) .game-library,
body:has(#themeSwitch:checked) .paint-toolbar {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(13, 17, 23, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

body:has(#themeSwitch:checked) .key {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

body:has(#themeSwitch:checked) textarea {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(13, 17, 23, 0.72);
  color: #edf4ff;
}

body:has(#themeSwitch:checked) .hint,
body:has(#themeSwitch:checked) .brand p {
  color: var(--muted);
}

/* ═══════════════════════════════════════
   TEMA ROSA / FEMENINO
   ═══════════════════════════════════════ */

body.feminine-theme {
  --bg: #fdf2f8;
  --panel: rgba(253, 242, 248, 0.95);
  --panel-strong: #fce7f3;
  --ink: #831843;
  --muted: #9d174d;
  --cyan: #ec4899;
  --pink: #a855f7;
  --lime: #f472b6;
  --yellow: #fbbf24;
  --danger: #e11d48;
  --switch-blue: #ec4899;
  --switch-red: #a855f7;
  --switch-dark: #500724;
  --pixel-shadow: 0 18px 50px rgba(236, 72, 153, 0.18);
  --corner: 16px;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(236, 72, 153, 0.18), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(168, 85, 247, 0.16), transparent 28%),
    radial-gradient(circle at 50% 80%, rgba(251, 191, 36, 0.1), transparent 35%),
    linear-gradient(145deg, #fdf2f8 0%, #fce7f3 40%, #fae8ff 100%);
}

body.feminine-theme::before {
  background-image:
    linear-gradient(rgba(236, 72, 153, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236, 72, 153, 0.06) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 70%);
}

body.feminine-theme .topbar,
body.feminine-theme .play-zone,
body.feminine-theme .notes-zone,
body.feminine-theme .keyboard-guide {
  border-color: rgba(236, 72, 153, 0.25);
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(236, 72, 153, 0.12);
  backdrop-filter: blur(12px);
}

body.feminine-theme .brand-mark {
  border-color: rgba(236, 72, 153, 0.3);
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(236, 72, 153, 0.3);
}

body.feminine-theme h1 {
  color: #831843;
  text-shadow: none;
}

body.feminine-theme .section-head {
  border-bottom-color: rgba(236, 72, 153, 0.2);
}

body.feminine-theme .file-button,
body.feminine-theme .theme-toggle,
body.feminine-theme .paint-fab,
body.feminine-theme .voice-button,
body.feminine-theme .ghost-button,
body.feminine-theme .game-card,
body.feminine-theme .game-upload,
body.feminine-theme .inline-card-form input {
  border-color: rgba(236, 72, 153, 0.25);
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(168, 85, 247, 0.2));
  color: #831843;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.12);
}

body.feminine-theme .tool-button {
  border-color: rgba(236, 72, 153, 0.25);
  background: rgba(253, 242, 248, 0.8);
  color: #831843;
  box-shadow: 0 3px 10px rgba(236, 72, 153, 0.1);
}

body.feminine-theme .tool-button.active {
  background: #16a34a;
  color: #fff;
  border-color: rgba(22, 163, 74, 0.4);
}

body.feminine-theme .tool-button.danger {
  background: #e11d48;
  color: #fff;
  border-color: rgba(225, 29, 72, 0.3);
}

body.feminine-theme .screen-wrap {
  border-color: rgba(236, 72, 153, 0.3);
  box-shadow: 0 14px 36px rgba(168, 85, 247, 0.18);
}

body.feminine-theme .game-library,
body.feminine-theme .paint-toolbar {
  border-color: rgba(236, 72, 153, 0.2);
  background: rgba(253, 242, 248, 0.97);
  box-shadow: 0 16px 50px rgba(236, 72, 153, 0.15);
}

body.feminine-theme .key {
  border-color: rgba(236, 72, 153, 0.2);
  background: #fce7f3;
  color: #831843;
  box-shadow: 0 3px 8px rgba(236, 72, 153, 0.1);
}

body.feminine-theme .key.blue,
body.feminine-theme .key.cyan {
  background: linear-gradient(135deg, #ec4899, #f472b6);
  color: #fff;
}

body.feminine-theme .key.red {
  background: linear-gradient(135deg, #a855f7, #c084fc);
  color: #fff;
}

body.feminine-theme .key.gray {
  background: #831843;
  color: #fce7f3;
}

body.feminine-theme textarea {
  border-color: rgba(236, 72, 153, 0.2);
  background: rgba(255, 255, 255, 0.75);
  color: #831843;
}

body.feminine-theme textarea:focus {
  border-color: #ec4899;
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.15);
}

body.feminine-theme .hint,
body.feminine-theme .brand p {
  color: var(--muted);
}

body.feminine-theme .swatch.active {
  outline-color: #ec4899;
}

body.feminine-theme .game-card:hover,
body.feminine-theme .game-upload:hover {
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: #fff;
}

body.feminine-theme .create-card-button {
  border-color: rgba(236, 72, 153, 0.25);
  background: linear-gradient(135deg, #fce7f3, #ede9fe);
  color: #831843;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.12);
}

body.feminine-theme .floating-card {
  border-color: rgba(236, 72, 153, 0.2);
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.12);
}

body.feminine-theme .voice-button.listening {
  background: linear-gradient(135deg, #e11d48, #ec4899);
  color: #fff;
}

body.feminine-theme .card-board-head {
  border-color: rgba(236, 72, 153, 0.25);
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(236, 72, 153, 0.12);
  backdrop-filter: blur(12px);
}

body.feminine-theme .card-board-surface {
  border-color: rgba(236, 72, 153, 0.25);
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 18px,
      rgba(236, 72, 153, 0.04) 18px,
      rgba(236, 72, 153, 0.04) 19px
    ),
    #fdf2f8;
  box-shadow: 0 14px 40px rgba(236, 72, 153, 0.12);
}

body.feminine-theme .board-empty-hint {
  color: #d946ef;
}

/* Modern theme card & tool overrides */

body.modern-theme .tool-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #9fb0c7;
  box-shadow: none;
}

body.modern-theme .tool-button.active {
  background: #16a34a;
  color: #fff;
  border-color: rgba(22, 163, 74, 0.4);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.25);
}

body.modern-theme .tool-button.danger {
  background: #ff6b6b;
  color: #fff;
}

body.modern-theme .create-card-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.2), rgba(255, 209, 102, 0.08));
  color: #ffd166;
  box-shadow: none;
}

body.modern-theme .floating-card {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

body.modern-theme .card-board-head {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

body.modern-theme .card-board-surface {
  border-color: rgba(255, 255, 255, 0.12);
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 18px,
      rgba(255, 255, 255, 0.02) 18px,
      rgba(255, 255, 255, 0.02) 19px
    ),
    rgba(13, 17, 23, 0.85);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
}

body.modern-theme .board-empty-hint {
  color: #4b5563;
}

body.mono-theme {
  --bg: #f4f4f4;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --ink: #050505;
  --muted: #555555;
  --cyan: #111111;
  --pink: #000000;
  --lime: #777777;
  --yellow: #d8d8d8;
  --danger: #000000;
  --switch-blue: #111111;
  --switch-red: #000000;
  --switch-dark: #050505;
  --pixel-shadow: 6px 6px 0 #050505;
  --corner: 8px;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(90deg, #050505 0 56px, #f4f4f4 56px calc(100% - 56px), #050505 calc(100% - 56px) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0 1px, transparent 1px 18px);
}

body.mono-theme::before {
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
}

body.mono-theme .topbar,
body.mono-theme .play-zone,
body.mono-theme .notes-zone,
body.mono-theme .keyboard-guide,
body.mono-theme .card-board-head,
body.mono-theme .card-board-surface {
  border-color: #050505;
  background: var(--panel);
  box-shadow: var(--pixel-shadow);
}

body.mono-theme .brand-mark {
  border-color: #050505;
  background: linear-gradient(90deg, #ffffff 0 55%, #050505 55% 100%);
  color: #050505;
  box-shadow: var(--pixel-shadow);
}

body.mono-theme h1 {
  color: #050505;
  text-shadow: 3px 3px 0 #ffffff;
}

body.mono-theme .section-head {
  border-bottom-color: #050505;
}

body.mono-theme .file-button,
body.mono-theme .theme-toggle,
body.mono-theme .paint-fab,
body.mono-theme .voice-button,
body.mono-theme .ghost-button,
body.mono-theme .tool-button,
body.mono-theme .game-card,
body.mono-theme .game-upload,
body.mono-theme .inline-card-form input,
body.mono-theme .game-search {
  border-color: #050505;
  background: #ffffff;
  color: #050505;
  box-shadow: 4px 4px 0 #050505;
}

body.mono-theme .file-button,
body.mono-theme .voice-button,
body.mono-theme .paint-fab {
  background: #050505;
  color: #ffffff;
}

body.mono-theme .screen-wrap {
  border-color: #050505;
  box-shadow: inset 0 0 0 4px #ffffff, 6px 6px 0 #050505;
}

body.mono-theme .game-library,
body.mono-theme .paint-toolbar {
  border-color: #050505;
  background: #111111;
  box-shadow: 6px 6px 0 #050505;
}

body.mono-theme .game-card:hover,
body.mono-theme .game-upload:hover {
  background: #050505;
  color: #ffffff;
}

body.mono-theme .key {
  border-color: #050505;
  background: #ffffff;
  color: #050505;
  box-shadow: 4px 4px 0 #050505;
}

body.mono-theme .key.blue,
body.mono-theme .key.cyan,
body.mono-theme .key.red,
body.mono-theme .key.gray {
  background: #050505;
  color: #ffffff;
}

body.mono-theme textarea {
  border-color: #050505;
  background: #ffffff;
  color: #050505;
}

body.mono-theme .hint,
body.mono-theme .brand p,
body.mono-theme .board-empty-hint {
  color: #555555;
}

body.mono-theme .tool-button.active {
  background: #050505;
  color: #ffffff;
  border-color: #050505;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.2);
}

body.mono-theme .tool-button.danger,
body.mono-theme .voice-button.listening {
  background: #ffffff;
  color: #050505;
}

body.mono-theme .create-card-button {
  border-color: #050505;
  background: #ffffff;
  color: #050505;
  box-shadow: 4px 4px 0 #050505;
}

body.mono-theme .floating-card {
  border-color: #050505;
  background: #ffffff;
  color: #050505;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}

body.mono-theme .floating-card[data-color="pink"],
body.mono-theme .floating-card[data-color="yellow"],
body.mono-theme .floating-card[data-color="blue"],
body.mono-theme .floating-card[data-color="green"],
body.mono-theme .floating-card[data-color="purple"] {
  background: #ffffff;
}

@media (max-width: 920px) {
  body {
    min-height: 100svh;
    overflow-x: hidden;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-shell {
    width: min(100% - 16px, 860px);
    min-height: 100svh;
    padding: 10px 0 176px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 10px;
    border-width: 2px;
    padding: 8px;
    box-shadow: 3px 3px 0 #1d1d1d;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 42px;
    border-width: 2px;
    font-size: 0.82rem;
    box-shadow: 3px 3px 0 #1d1d1d;
  }

  h1 {
    font-size: clamp(1.25rem, 5vw, 2rem);
    line-height: 1;
  }

  .theme-options,
  .notes-zone,
  .card-board,
  .paint-dock,
  .create-card-button,
  .inline-card-form,
  .keyboard-guide small {
    display: none !important;
  }

  .app-grid {
    display: block;
  }

  .play-zone {
    border-width: 2px;
    padding: 10px;
    box-shadow: 3px 3px 0 #1d1d1d;
  }

  .section-head {
    align-items: stretch;
    margin-bottom: 10px;
    border-bottom-width: 2px;
    padding-bottom: 10px;
  }

  .game-actions {
    display: block;
  }

  .game-menu {
    display: block;
  }

  .file-button {
    width: 100%;
    min-height: 44px;
  }

  .game-library {
    left: 0;
    right: auto;
    width: min(100%, calc(100vw - 24px));
    max-height: min(46vh, 360px);
    border-width: 2px;
    padding: 8px;
  }

  .game-library-tools {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .game-search,
  .game-upload {
    min-height: 42px;
    border-width: 2px;
    box-shadow: 3px 3px 0 #000000;
  }

  .game-card {
    min-height: 44px;
    border-width: 2px;
    padding: 8px 10px;
  }

  .screen-wrap {
    border-width: 4px;
    height: calc(100svh - 250px);
    min-height: 280px;
    max-height: 58svh;
  }

  .emulator-mount,
  .emulator-mount iframe {
    width: 100%;
    height: 100%;
    min-height: 100%;
  }

  .keyboard-guide {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 70;
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.25fr);
    gap: 10px;
    align-items: end;
    margin: 0;
    border-width: 2px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(143, 137, 127, 0.96);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  }

  .keyboard-block {
    gap: 7px;
  }

  .keyboard-block.arrows {
    grid-template-columns: repeat(3, minmax(44px, 1fr));
  }

  .keyboard-block.actions {
    grid-template-columns: repeat(3, minmax(48px, 1fr));
  }

  .key {
    min-height: 54px;
    border-width: 2px;
    border-radius: 10px;
    font-size: 1.16rem;
    box-shadow: 3px 3px 0 var(--switch-dark);
  }

  .key.wide {
    grid-column: span 2;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 12px, 1180px);
    padding: 6px 0 158px;
  }

  .topbar {
    margin-bottom: 6px;
  }

  .brand-mark {
    width: 36px;
    font-size: 1rem;
  }

  .keyboard-guide {
    left: 6px;
    right: 6px;
    bottom: 6px;
    gap: 8px;
    padding: 8px;
  }

  .screen-wrap {
    height: calc(100svh - 220px);
    min-height: 250px;
    max-height: 56svh;
  }

  .game-library {
    max-height: 42vh;
  }

  .key {
    min-height: 48px;
    font-size: 1.18rem;
  }
}
