: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: fixed;
  top: clamp(80px, 14svh, 140px);
  left: 50%;
  right: auto;
  z-index: 90;
  display: none;
  width: min(430px, calc(100vw - 32px));
  max-height: min(52vh, 420px);
  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;
  transform: translateX(-50%);
}

.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;
}

/* ═══════════════════════════════════════
   TEMA AMARILLO
   ═══════════════════════════════════════ */

body.yellow-theme {
  --bg: #fffbeb;
  --panel: rgba(254, 243, 199, 0.96);
  --panel-strong: #fef3c7;
  --ink: #92400e;
  --muted: #b45309;
  --cyan: #d97706;
  --pink: #f59e0b;
  --lime: #fbbf24;
  --yellow: #f59e0b;
  --danger: #dc2626;
  --switch-blue: #d97706;
  --switch-red: #b45309;
  --switch-dark: #78350f;
  --pixel-shadow: 0 18px 50px rgba(217, 119, 6, 0.18);
  --corner: 14px;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(251, 191, 36, 0.28), transparent 32%),
    radial-gradient(circle at 82% 18%, rgba(245, 158, 11, 0.22), transparent 28%),
    radial-gradient(circle at 50% 82%, rgba(252, 211, 77, 0.18), transparent 36%),
    linear-gradient(145deg, #fffbeb 0%, #fef3c7 42%, #fde68a 100%);
}

body.yellow-theme::before {
  background-image:
    linear-gradient(rgba(217, 119, 6, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 119, 6, 0.07) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 70%);
}

body.yellow-theme .topbar,
body.yellow-theme .play-zone,
body.yellow-theme .notes-zone,
body.yellow-theme .keyboard-guide {
  border-color: rgba(217, 119, 6, 0.28);
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(217, 119, 6, 0.14);
  backdrop-filter: blur(12px);
}

body.yellow-theme .brand-mark {
  border-color: rgba(217, 119, 6, 0.32);
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.28);
}

body.yellow-theme h1 {
  color: #92400e;
  text-shadow: none;
}

body.yellow-theme .section-head {
  border-bottom-color: rgba(217, 119, 6, 0.22);
}

body.yellow-theme .file-button,
body.yellow-theme .theme-toggle,
body.yellow-theme .paint-fab,
body.yellow-theme .voice-button,
body.yellow-theme .ghost-button,
body.yellow-theme .game-card,
body.yellow-theme .game-upload,
body.yellow-theme .inline-card-form input,
body.yellow-theme .game-search {
  border-color: rgba(217, 119, 6, 0.28);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.35), rgba(245, 158, 11, 0.22));
  color: #92400e;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.12);
}

body.yellow-theme .tool-button {
  border-color: rgba(217, 119, 6, 0.28);
  background: rgba(254, 243, 199, 0.85);
  color: #92400e;
  box-shadow: 0 3px 10px rgba(217, 119, 6, 0.1);
}

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

body.yellow-theme .tool-button.danger {
  background: #dc2626;
  color: #fff;
  border-color: rgba(220, 38, 38, 0.3);
}

body.yellow-theme .screen-wrap {
  border-color: rgba(217, 119, 6, 0.32);
  box-shadow: 0 14px 36px rgba(245, 158, 11, 0.2);
}

body.yellow-theme .game-library,
body.yellow-theme .paint-toolbar {
  border-color: rgba(217, 119, 6, 0.24);
  background: rgba(255, 251, 235, 0.98);
  box-shadow: 0 16px 50px rgba(217, 119, 6, 0.16);
}

body.yellow-theme .game-library p {
  color: #92400e;
}

body.yellow-theme .key {
  border-color: rgba(217, 119, 6, 0.22);
  background: #fef3c7;
  color: #92400e;
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.1);
}

body.yellow-theme .key.blue,
body.yellow-theme .key.cyan {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #78350f;
}

body.yellow-theme .key.red {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
}

body.yellow-theme .key.gray {
  background: #92400e;
  color: #fef3c7;
}

body.yellow-theme textarea {
  border-color: rgba(217, 119, 6, 0.22);
  background: rgba(255, 255, 255, 0.78);
  color: #92400e;
}

body.yellow-theme textarea:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

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

body.yellow-theme .swatch.active {
  outline-color: #f59e0b;
}

body.yellow-theme .game-card:hover,
body.yellow-theme .game-upload:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

body.yellow-theme .create-card-button {
  border-color: rgba(217, 119, 6, 0.28);
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.12);
}

body.yellow-theme .floating-card {
  border-color: rgba(217, 119, 6, 0.22);
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.12);
}

body.yellow-theme .voice-button.listening {
  background: linear-gradient(135deg, #dc2626, #f59e0b);
  color: #fff;
}

body.yellow-theme .card-board-head {
  border-color: rgba(217, 119, 6, 0.28);
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(217, 119, 6, 0.14);
  backdrop-filter: blur(12px);
}

body.yellow-theme .card-board-surface {
  border-color: rgba(217, 119, 6, 0.28);
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 18px,
      rgba(245, 158, 11, 0.05) 18px,
      rgba(245, 158, 11, 0.05) 19px
    ),
    #fffbeb;
  box-shadow: 0 14px 40px rgba(217, 119, 6, 0.14);
}

body.yellow-theme .board-empty-hint {
  color: #d97706;
}

/* 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 {
    top: clamp(68px, 12svh, 120px);
    width: min(100%, calc(100vw - 24px));
    max-height: min(52vh, 420px);
    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;
  }
}

/* App navigation and centred child-friendly help overlays. */
.app-home-link { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; margin-left: 4px; border: 2px solid var(--ink); border-radius: 10px; padding: 0 11px; background: var(--coral); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); font-weight: 900; text-decoration: none; }
.welcome-backdrop { position: fixed; inset: 0; z-index: 99; backdrop-filter: blur(6px); background: rgba(32,35,31,.16); animation: welcome-backdrop 2.6s ease forwards; pointer-events: none; }
@keyframes welcome-backdrop { 0%, 12% { opacity: 0; } 18%, 68% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.save-help-button { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: grid; width: 54px; height: 54px; place-items: center; border: 2px solid var(--ink); border-radius: 50%; padding: 0; background: var(--sun); color: var(--ink); box-shadow: 5px 5px 0 var(--ink); animation: help-wiggle 2.6s ease-in-out infinite; }.save-help-button .material-symbols-rounded { font-size: 30px; }.save-help-button:hover { animation-play-state: paused; }
@keyframes help-wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-9deg) scale(1.06); } 92% { transform: rotate(9deg) scale(1.06); } }
.save-guide[hidden] { display: none !important; }.save-guide { position: fixed; top: 50%; left: 50%; z-index: 100; width: min(700px, calc(100% - 32px)); max-height: min(720px, calc(100svh - 32px)); margin: 0; overflow: auto; transform: translate(-50%, -50%); }.save-guide-close { position: absolute; top: 10px; right: 10px; z-index: 2; display: grid; width: 36px; height: 36px; place-items: center; border: 2px solid var(--ink); border-radius: 50%; padding: 0; background: var(--coral); box-shadow: 2px 2px 0 var(--ink); }.save-guide-open::after { content: ""; position: fixed; inset: 0; z-index: 99; background: rgba(32,35,31,.28); backdrop-filter: blur(7px); }

@media (max-width: 920px) {
  .app-home-link { min-width: 38px; min-height: 38px; margin-left: 0; padding: 0 8px; }.app-home-link span:last-child { display: none; }
  .topbar { gap: 8px; }.theme-options { margin-left: auto; }
  .save-help-button { right: 14px; bottom: 14px; width: 50px; height: 50px; }
  .save-guide { width: min(520px, calc(100% - 24px)); padding: 14px; }.save-guide-cards { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .card-board { display: none !important; }
}

/* Editorial neo-brutalist design system */
:root {
  color-scheme: light;
  --ink: #20231f;
  --paper: #f6f0df;
  --paper-warm: #fff9eb;
  --coral: #ff6b4a;
  --sun: #f4c84a;
  --mint: #71d7b3;
  --sky: #79b8ff;
  --lavender: #bba5ff;
  --bg: var(--paper);
  --panel: var(--paper-warm);
  --panel-strong: var(--paper-warm);
  --muted: #5a5f56;
  --cyan: var(--sky);
  --pink: var(--coral);
  --lime: var(--mint);
  --yellow: var(--sun);
  --danger: var(--coral);
  --switch-blue: var(--sky);
  --switch-red: var(--coral);
  --switch-dark: var(--ink);
  --line: var(--ink);
  --pixel-shadow: 6px 6px 0 var(--ink);
  --corner: 16px;
  font-family: Nunito, ui-sans-serif, system-ui, sans-serif;
}

body {
  background-color: var(--paper);
  background-image: radial-gradient(rgba(32, 35, 31, .13) 1px, transparent 1.5px);
  background-size: 16px 16px;
}

body::before { background-image: linear-gradient(rgba(32,35,31,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(32,35,31,.035) 1px, transparent 1px); mask-image: none; }
.page-shell { padding-top: 28px; }
.welcome-panel { position: fixed; top: 24px; left: 50%; z-index: 100; display: flex; align-items: center; gap: 12px; width: min(440px, calc(100% - 32px)); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 16px; background: var(--mint); box-shadow: 5px 5px 0 var(--ink); transform: translateX(-50%); animation: welcome-pop 2.6s ease forwards; pointer-events: none; }
.welcome-panel strong, .welcome-panel span { display: block; }.welcome-panel strong { font: 800 1.3rem/1 "Baloo 2", sans-serif; }.welcome-panel div > span { margin-top: 3px; font-weight: 700; }.welcome-star { font-size: 31px; }
@keyframes welcome-pop { 0% { opacity: 0; transform: translate(-50%, -18px) scale(.92); } 12%, 68% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -12px) scale(.96); visibility: hidden; } }
.topbar, .play-zone, .notes-zone, .keyboard-guide, .card-board-head, .card-board-surface { border: 2px solid var(--ink); box-shadow: var(--pixel-shadow); }
.topbar { padding: 16px 18px; background: var(--paper-warm); }
.brand-mark { width: 58px; border: 2px solid var(--ink); border-radius: 14px; background: var(--coral); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
h1, h2, h3 { font-family: "Baloo 2", Nunito, sans-serif; letter-spacing: -.035em; }
h1 { text-shadow: 2px 2px 0 var(--sun); }
.theme-options { padding: 4px; gap: 4px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); }
.theme-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; border: 0; border-radius: 8px; padding: 0 11px; background: transparent; color: var(--ink); font-size: .82rem; }
.theme-btn .material-symbols-rounded { font-size: 18px; }
.theme-btn.active { border: 0; background: var(--lavender); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }

.play-zone, .notes-zone { background: var(--panel); }
.app-grid { grid-template-columns: minmax(0, 1fr); }
.play-zone { padding: 20px; }
.notes-zone { padding: 18px; }
.section-head { border-color: var(--ink); }
.file-button, .ghost-button, .create-card-button, .voice-button, .paint-fab, .tool-button, .game-card, .game-upload, .key { border: 2px solid var(--ink); border-radius: 10px; box-shadow: 4px 4px 0 var(--ink); }
.file-button { background: var(--ink); color: var(--paper-warm); }
.create-card-button { background: var(--sun); color: var(--ink); }
.ghost-button, .paint-fab, .tool-button, .game-card, .game-upload { background: var(--paper-warm); color: var(--ink); }
.voice-button { padding: 0 14px; background: var(--mint); color: var(--ink); }
.voice-button.listening, .tool-button.danger { background: var(--coral); color: var(--ink); }
.tool-button.active { background: var(--sky); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); animation: none; }
button:hover, .file-button:hover { filter: none; transform: translate(-1px, -1px); }
button:active, .file-button:active, .virtual-key.is-pressed, .virtual-key:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

.screen-wrap { border: 2px solid var(--ink); border-radius: 14px; background: var(--ink); box-shadow: 5px 5px 0 var(--ink); }
.emulator-mount { min-height: 500px; background: linear-gradient(rgba(32,35,31,.2), rgba(32,35,31,.7)), url("images/wallpaper.jpg") center / cover no-repeat; }
.game-library, .paint-toolbar { border: 2px solid var(--ink); border-radius: 14px; background: var(--paper-warm); box-shadow: var(--pixel-shadow); }
.game-library p { color: var(--ink); }
.game-search, .inline-card-form input, textarea { border: 2px solid var(--ink); border-radius: 10px; background: var(--paper-warm); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); font-family: Nunito, sans-serif; }
.game-search:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 4px var(--lavender); }
.game-card:hover, .game-upload:hover { background: var(--lavender); color: var(--ink); }
.keyboard-guide { background: var(--lavender); }
.key.blue, .key.cyan { background: var(--sky); color: var(--ink); }
.key.red { background: var(--coral); color: var(--ink); }
.key.gray { background: var(--mint); color: var(--ink); }
textarea { min-height: 390px; background-image: linear-gradient(rgba(32,35,31,.04) 1px, transparent 1px); background-size: 100% 1.55em; }
.mic-dot { background: var(--ink); }
.paint-dock.open .paint-fab { background: var(--coral); color: var(--ink); }
.swatch { border: 2px solid var(--ink); border-radius: 50%; box-shadow: 3px 3px 0 var(--ink); }
.swatch.active { outline-color: var(--coral); }
.card-board-head { background: var(--sun); }
.card-board-surface { background-color: var(--paper-warm); background-image: linear-gradient(rgba(32,35,31,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(32,35,31,.08) 1px, transparent 1px); background-size: 24px 24px; }
.floating-card { border: 2px solid var(--ink); border-radius: 12px; box-shadow: 4px 4px 0 var(--ink); }
.floating-card[data-color="pink"] { background: var(--coral); }.floating-card[data-color="yellow"] { background: var(--sun); }.floating-card[data-color="blue"] { background: var(--sky); }.floating-card[data-color="green"] { background: var(--mint); }.floating-card[data-color="purple"] { background: var(--lavender); }
.card-text { color: var(--ink); font-family: Nunito, sans-serif; }
.save-guide { margin-top: 24px; border: 2px solid var(--ink); border-radius: 16px; padding: 18px; background: var(--paper-warm); box-shadow: 6px 6px 0 var(--ink); }
.save-guide-title { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }.save-guide-title > .material-symbols-rounded { display: grid; width: 48px; height: 48px; place-items: center; border: 2px solid var(--ink); border-radius: 12px; background: var(--sun); font-size: 26px; }.save-guide h2 { font-size: 1.35rem; }.save-guide p { margin-top: 2px; color: var(--muted); font-weight: 700; }
.save-guide-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }.save-card { position: relative; min-height: 190px; overflow: hidden; border: 2px solid var(--ink); border-radius: 14px; background: var(--sky); box-shadow: 4px 4px 0 var(--ink); cursor: pointer; outline: none; }.save-card--load { background: var(--lavender); }.save-card-front, .save-card-back { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; text-align: center; transition: transform 220ms ease; }.save-card-front img { width: min(100%, 300px); margin-bottom: 12px; border: 2px solid var(--ink); border-radius: 8px; background: #000; }.save-card-front strong { font: 800 1.25rem/1.1 "Baloo 2", sans-serif; }.save-card-front span { margin-top: 7px; font-weight: 900; }.save-card-back { transform: translateY(100%); background: var(--paper-warm); }.save-card-back .material-symbols-rounded { margin-bottom: 7px; font-size: 32px; }.save-card-back strong { font: 800 1.18rem/1.1 "Baloo 2", sans-serif; }.save-card-back p { max-width: 280px; margin-top: 8px; line-height: 1.35; }.save-card:hover .save-card-front, .save-card:focus .save-card-front { transform: translateY(-100%); }.save-card:hover .save-card-back, .save-card:focus .save-card-back { transform: translateY(0); }

body.dark-theme { color-scheme: dark; --ink: #f9f2e1; --paper: #1d211d; --paper-warm: #292f29; --muted: #c1c8bb; --panel: #252b25; --panel-strong: #292f29; }
body.dark-theme { background-color: var(--paper); background-image: radial-gradient(rgba(249,242,225,.14) 1px, transparent 1.5px); }
body.dark-theme .topbar, body.dark-theme .play-zone, body.dark-theme .notes-zone { background: var(--panel); }
body.dark-theme .theme-options, body.dark-theme .ghost-button, body.dark-theme .paint-fab, body.dark-theme .tool-button, body.dark-theme .game-card, body.dark-theme .game-upload, body.dark-theme .game-library, body.dark-theme .paint-toolbar, body.dark-theme textarea, body.dark-theme .game-search, body.dark-theme .inline-card-form input { background-color: var(--paper-warm); color: var(--ink); }
body.dark-theme .file-button { background: var(--coral); color: #20231f; }
body.dark-theme .card-board-surface { background-color: var(--panel); }
body.dark-theme .save-guide, body.dark-theme .save-card-back { background: var(--panel); }
body.dark-theme .hint, body.dark-theme .brand p, body.dark-theme .board-empty-hint { color: var(--muted); }

@media (max-width: 920px) {
  .theme-options { display: flex !important; }
  .topbar { flex-direction: row; align-items: center; }
  .notes-zone, .card-board, .paint-dock, .create-card-button, .inline-card-form { display: flex !important; }
  .notes-zone { margin-top: 20px; min-height: 360px; }
  .card-board { display: block !important; }
  .paint-dock { display: grid !important; }
  .create-card-button { display: inline-flex !important; }
  .inline-card-form[hidden] { display: none !important; }
  .save-guide-cards { grid-template-columns: 1fr; }
  .keyboard-guide { display: none !important; }
  .screen-wrap { height: min(72svh, 700px); max-height: none; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .theme-options { width: 100%; }
  .theme-btn { flex: 1; justify-content: center; }
  .notes-zone { padding: 14px; }
  .card-board { width: min(100% - 12px, 1180px); }
  .welcome-panel { top: 12px; }.save-guide { padding: 14px; }
}

/* Touch devices use the emulator's built-in GBA controls instead of keyboard buttons. */
@media (hover: none) and (pointer: coarse) {
  .keyboard-guide { display: none !important; }
  .screen-wrap { height: min(72svh, 700px); max-height: none; }
}

/* Compact touch layout: the game stays first, actions become corner buttons. */
@media (max-width: 920px) {
  .page-shell { width: min(100% - 20px, 860px); padding-bottom: 28px; }
  .topbar { min-height: 64px; padding: 10px 12px; }
  .brand-mark { width: 40px; }.brand h1 { font-size: clamp(1.45rem, 6vw, 2rem); }
  .theme-options { width: auto; margin-left: auto; }.theme-btn { min-width: 38px; padding: 0 9px; }.theme-btn .material-symbols-rounded { margin: 0; }.theme-btn { font-size: 0; }.theme-btn .material-symbols-rounded { font-size: 20px; }
  .play-zone { position: relative; padding: 10px; }
  .section-head { position: absolute; top: 20px; right: 20px; z-index: 8; display: block; margin: 0; border: 0; padding: 0; }
  .game-actions { display: flex; gap: 8px; }
  .game-menu { position: static; }
  .game-menu .file-button, .create-card-button { width: 48px; min-width: 48px; min-height: 48px; padding: 0; border-radius: 50%; }
  .game-menu .button-label, .create-card-button .button-label { display: none; }
  .game-menu .material-symbols-rounded, .create-card-button .material-symbols-rounded { font-size: 24px; }
  .create-card-button { display: inline-flex !important; }
  .inline-card-form { position: fixed; top: 82px; left: 10px; right: 10px; z-index: 95; display: grid !important; grid-template-columns: 1fr auto auto; padding: 10px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper-warm); box-shadow: var(--pixel-shadow); }
  .inline-card-form[hidden] { display: none !important; }
  .inline-card-form input { min-width: 0; }.inline-card-form .file-button, .inline-card-form .ghost-button { width: auto; min-width: auto; padding: 0 10px; border-radius: 9px; }
  .game-library { top: 78px; left: auto; right: 10px; width: min(390px, calc(100vw - 20px)); max-height: min(66svh, 510px); transform: none; padding: 10px; }
  .game-library-tools { grid-template-columns: 1fr 54px; }.game-upload { min-width: 54px; padding: 0; font-size: 0; }.game-upload::after { content: "+"; font-size: 1.7rem; line-height: 1; }
  .screen-wrap { margin-top: 0; border-radius: 12px; }
  .save-guide { margin-top: 16px; padding: 14px; }.save-guide-title { align-items: flex-start; }.save-guide-title > .material-symbols-rounded { width: 40px; height: 40px; flex: 0 0 auto; }.save-guide h2 { font-size: 1.12rem; }.save-guide p { font-size: .85rem; }
  .save-guide-cards { gap: 10px; }.save-card { min-height: 112px; }.save-card-front { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px; text-align: left; }.save-card-front img { width: 112px; margin: 0; }.save-card-front strong { font-size: 1.05rem; }.save-card-front span { margin: 0 0 0 auto; white-space: nowrap; font-size: .85rem; }.save-card-back { padding: 10px; }.save-card-back .material-symbols-rounded { font-size: 25px; }.save-card-back p { font-size: .88rem; }
  .card-board { margin-top: 18px; }.card-board-head { padding: 10px; }.board-toolbar { overflow-x: auto; padding-bottom: 4px; }.tool-button { flex: 0 0 auto; }
}

@media (max-width: 560px) {
  .topbar { flex-direction: row; align-items: center; }.brand { gap: 8px; }.brand-mark { width: 34px; }.brand h1 { font-size: 1.35rem; }
  .theme-options { padding: 3px; }.theme-btn { min-height: 34px; min-width: 34px; padding: 0 7px; }
  .section-head { top: 16px; right: 16px; }.game-menu .file-button, .create-card-button { width: 44px; min-width: 44px; min-height: 44px; }
  .screen-wrap { height: min(66svh, 560px); min-height: 300px; }.inline-card-form { top: 72px; grid-template-columns: 1fr auto; }.inline-card-form .ghost-button { grid-column: 2; }
  .save-card { min-height: 100px; }.save-card-front img { width: 92px; }.save-card-front strong { font-size: .98rem; }.save-card-front span { font-size: .76rem; }
}

/* Final mobile and welcome-position safeguards. */
.welcome-panel { top: 50%; transform: translate(-50%, -50%); }
@keyframes welcome-pop { 0% { opacity: 0; transform: translate(-50%, calc(-50% - 18px)) scale(.92); } 12%, 68% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, calc(-50% - 12px)) scale(.96); visibility: hidden; } }
@media (max-width: 560px) { .card-board, #cardBoard { display: none !important; } }

/* Desktop-only keyboard tutorial. */
.keyboard-tutorial[hidden] { display: none !important; }.keyboard-tutorial { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 20px; background: rgba(32,35,31,.28); backdrop-filter: blur(7px); }.keyboard-tutorial-card { position: relative; width: min(690px, 100%); max-height: calc(100svh - 40px); overflow: auto; border: 2px solid var(--ink); border-radius: 18px; padding: 26px; background: var(--paper-warm); box-shadow: 8px 8px 0 var(--ink); text-align: center; }.tutorial-close { position: absolute; top: 12px; right: 12px; display: grid; width: 38px; height: 38px; place-items: center; border: 2px solid var(--ink); border-radius: 50%; padding: 0; background: var(--coral); box-shadow: 2px 2px 0 var(--ink); }.tutorial-icon { display: grid; width: 54px; height: 54px; place-items: center; margin: 0 auto 6px; border: 2px solid var(--ink); border-radius: 15px; background: var(--mint); font-size: 30px; animation: controller-bounce 1.8s ease-in-out infinite; }.keyboard-tutorial h2 { font-size: 2rem; }.tutorial-intro { margin: 2px 0 18px; color: var(--muted); font-weight: 700; }.tutorial-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }.tutorial-control { display: flex; align-items: center; gap: 11px; min-height: 74px; border: 2px solid var(--ink); border-radius: 12px; padding: 9px; background: var(--paper); }.tutorial-control:nth-child(2n) { background: var(--lavender); }.tutorial-control:nth-child(3n) { background: var(--sky); }.tutorial-control p { margin: 0; }.tutorial-control strong, .tutorial-control p span { display: block; }.tutorial-control p span { margin-top: 2px; color: var(--muted); font-size: .82rem; font-weight: 700; }.tutorial-control kbd { display: grid; min-width: 36px; height: 36px; place-items: center; border: 2px solid var(--ink); border-radius: 8px; padding: 0 7px; background: var(--paper-warm); box-shadow: 2px 2px 0 var(--ink); color: var(--ink); font: 900 .95rem Nunito, sans-serif; animation: key-pop 2s ease-in-out infinite; }.tutorial-keys { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }.tutorial-keys kbd:nth-child(2) { animation-delay: .15s; }.tutorial-keys kbd:nth-child(3) { animation-delay: .3s; }.tutorial-keys kbd:nth-child(4) { animation-delay: .45s; }.start-playing { margin-top: 18px; min-height: 48px; border: 2px solid var(--ink); border-radius: 11px; padding: 0 20px; background: var(--sun); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); font: 900 1.05rem Nunito, sans-serif; }.start-playing span { font-size: 1.4em; }.keyboard-tutorial-open { overflow: hidden; }@keyframes key-pop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }@keyframes controller-bounce { 0%, 100% { transform: rotate(-5deg) translateY(0); } 50% { transform: rotate(5deg) translateY(-4px); } }
body.dark-theme .keyboard-tutorial-card, body.dark-theme .tutorial-control kbd { background: var(--panel); }body.dark-theme .tutorial-control { background: var(--paper-warm); }
@media (max-width: 920px), (hover: none) and (pointer: coarse) { .keyboard-tutorial { display: none !important; } }
@media (max-width: 600px) { .tutorial-controls { grid-template-columns: 1fr; } }

.game-prompt[hidden] { display: none; }.game-prompt { position: absolute; top: calc(100% + 10px); left: 0; z-index: 96; display: inline-flex; align-items: center; gap: 7px; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 11px; background: var(--mint); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); font: 900 .95rem Nunito, sans-serif; white-space: nowrap; animation: prompt-bob 1s ease-in-out infinite; }.game-prompt .material-symbols-rounded { font-size: 21px; animation: prompt-arrow .8s ease-in-out infinite; }@keyframes prompt-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }@keyframes prompt-arrow { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }
body.dark-theme .game-prompt { background: var(--mint); color: #20231f; }
@media (max-width: 920px) { .game-prompt { top: 58px; left: auto; right: 0; } }

/* The selector prompt is a temporary instruction layer, not an extra button. */
.game-prompt { border: 0; border-radius: 0; padding: 0; background: transparent; box-shadow: none; pointer-events: none; }.game-prompt::before { content: ""; position: fixed; inset: 0; z-index: -1; background: rgba(32,35,31,.14); backdrop-filter: blur(4px); }.game-prompt span:first-child { border: 2px solid var(--ink); border-radius: 10px; padding: 7px 10px; background: var(--paper-warm); box-shadow: 3px 3px 0 var(--ink); }.game-prompt .material-symbols-rounded { position: absolute; top: -42px; left: 50%; color: var(--coral); font-size: 46px; font-variation-settings: "wght" 700; filter: drop-shadow(2px 2px 0 var(--ink)); transform: translateX(-50%); animation: prompt-arrow-up .8s ease-in-out infinite; }@keyframes prompt-arrow-up { 0%, 100% { transform: translate(-50%, 4px); } 50% { transform: translate(-50%, -5px); } }body.dark-theme .game-prompt span:first-child { background: var(--panel); color: var(--ink); }

/* Keep the game library attached to its trigger while the page scrolls. */
.game-menu { position: relative; }.game-library { position: absolute; top: calc(100% + 10px); left: 0; right: auto; transform: none; }
@media (max-width: 920px) { .game-menu { position: relative; }.game-library { top: calc(100% + 8px); left: auto; right: 0; } }

@media (max-width: 560px) {
  .game-library { width: min(286px, calc(100vw - 28px)); max-height: 46svh; gap: 7px; padding: 8px; border-radius: 12px; box-shadow: 4px 4px 0 var(--ink); }
  .game-library-tools { grid-template-columns: minmax(0, 1fr) 42px; gap: 6px; }.game-search { min-height: 38px; padding-left: 32px; font-size: .86rem; }.search-icon { left: 10px; font-size: 1rem; }
  .game-upload { min-width: 42px; min-height: 38px; border-radius: 8px; }.game-upload input { display: none; }.game-upload span { display: none; }.game-upload::after { content: "upload"; font-family: "Material Symbols Rounded"; font-size: 22px; }
  .game-list { gap: 7px; }.game-card { min-height: 40px; padding: 7px 9px; border-radius: 8px; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Fine-tune the selector arrow for each layout. */
.game-prompt .material-symbols-rounded { top: -39px; }
@media (max-width: 560px) { .game-prompt .material-symbols-rounded { top: -37px; animation: prompt-arrow-northeast .8s ease-in-out infinite; } }@keyframes prompt-arrow-northeast { 0%, 100% { transform: translate(-50%, 4px) rotate(45deg); } 50% { transform: translate(-50%, -5px) rotate(45deg); } }

/* The image tutorial replaces the desktop arrow; it is shown only on touch screens. */
.game-prompt { display: none !important; }
@media (max-width: 920px), (hover: none) and (pointer: coarse) {
  .game-prompt:not([hidden]) { position: fixed; inset: 0; z-index: 105; display: grid !important; place-items: center; padding: 20px; background: rgba(32,35,31,.22); backdrop-filter: blur(6px); animation: none; }
  .game-prompt::before, .game-prompt .material-symbols-rounded { display: none; }
  .game-prompt span:first-child, .game-prompt img { grid-area: 1 / 1; }.game-prompt span:first-child { align-self: start; width: min(360px, calc(100vw - 40px)); margin-top: calc(50svh - 155px); padding: 9px 12px; background: var(--mint); color: #20231f; font-size: 1rem; text-align: center; }.game-prompt img { width: min(380px, calc(100vw - 40px)); margin-top: 48px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper-warm); box-shadow: 6px 6px 0 var(--ink); }
}

/* Second tutorial step: choose a game. */
.game-prompt:not([hidden]) { position: fixed; inset: 0; z-index: 111; display: grid !important; place-items: center; padding: 20px; background: rgba(32,35,31,.28); backdrop-filter: blur(7px); animation: none; pointer-events: auto; }.game-prompt::before { display: none; }.game-prompt-card { position: relative; width: min(510px, 100%); max-height: calc(100svh - 40px); overflow: auto; border: 2px solid var(--ink); border-radius: 18px; padding: 26px; background: var(--paper-warm); box-shadow: 8px 8px 0 var(--ink); text-align: center; }.game-prompt-card h2 { margin: 0; font-size: 1.8rem; }.game-prompt-card > p { margin: 3px 0 15px; color: var(--muted); font-weight: 700; }.game-prompt-card img { display: block; width: min(100%, 400px); margin: 0 auto; border: 2px solid var(--ink); border-radius: 12px; box-shadow: 4px 4px 0 var(--ink); }.game-prompt-card .tutorial-icon { margin-bottom: 6px; }.game-prompt-card .start-playing { margin-top: 16px; }.game-prompt-card .material-symbols-rounded:not(.tutorial-icon) { display: inline; }.game-prompt-open { overflow: hidden; }body.dark-theme .game-prompt-card { background: var(--panel); }
@media (max-width: 560px) { .game-prompt:not([hidden]) { padding: 12px; }.game-prompt-card { padding: 20px 14px; }.game-prompt-card h2 { font-size: 1.55rem; }.game-prompt-card img { max-width: 340px; } }

/* Brand treatment and reset of old arrow styles inside the game tutorial. */
.brand h1 { display: inline-block; border: 2px solid var(--ink); border-radius: 13px; padding: 5px 14px 8px; background: var(--sun); color: #20231f; font-family: Fredoka, "Baloo 2", sans-serif; font-size: clamp(1.65rem, 3.4vw, 2.75rem); font-weight: 700; letter-spacing: -.055em; box-shadow: 4px 4px 0 var(--ink); text-shadow: none; }.brand { gap: 0; }
.game-prompt-card .tutorial-icon { position: static; top: auto; left: auto; display: grid; width: 54px; height: 54px; margin: 0 auto 6px; border: 2px solid var(--ink); border-radius: 15px; padding: 0; background: var(--mint); color: var(--ink); box-shadow: none; transform: none; filter: none; animation: controller-bounce 1.8s ease-in-out infinite; }.game-prompt-card .tutorial-close span { position: static; display: block; border: 0; border-radius: 0; padding: 0; background: transparent; box-shadow: none; color: var(--ink); font-size: 22px; transform: none; filter: none; animation: none; }.game-prompt-card .tutorial-close { display: grid; }.game-prompt-card .material-symbols-rounded { text-shadow: none; }
body.dark-theme .brand h1 { background: var(--sun); color: #20231f; text-shadow: none; }

/* Local, letter-by-letter vocabulary helper. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
.word-helper { position: relative; margin-top: 22px; border: 2px solid var(--ink); border-radius: 16px; padding: 17px; background: var(--paper-warm); box-shadow: 6px 6px 0 var(--ink); }.word-helper-heading { display: flex; align-items: center; gap: 11px; }.word-helper-heading > .material-symbols-rounded { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border: 2px solid var(--ink); border-radius: 12px; background: var(--lavender); font-size: 24px; }.word-helper h2 { font-size: 1.3rem; }.word-helper-heading p { margin: 1px 0 0; color: var(--muted); font-size: .86rem; font-weight: 700; }.word-lookup-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }.word-lookup-form input { min-width: 0; min-height: 46px; border: 2px solid var(--ink); border-radius: 10px; padding: 0 12px; background: var(--paper); color: var(--ink); font: 800 1rem Nunito, sans-serif; }.word-lookup-form button { min-height: 46px; border: 2px solid var(--ink); border-radius: 10px; padding: 0 16px; background: var(--sun); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); font-weight: 900; }.word-lookup-result { min-height: 55px; margin-top: 14px; border: 2px solid var(--ink); border-radius: 11px; padding: 11px; background: var(--paper); }.translation-answer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }.translation-es { color: var(--muted); font-weight: 800; }.translation-answer > .material-symbols-rounded { font-size: 20px; }.translation-answer strong { font: 800 1.3rem Fredoka, sans-serif; }.speak-word { display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid var(--ink); border-radius: 50%; padding: 0; background: var(--mint); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }.translation-example, .word-lookup-result > p { margin: 8px 0 0; color: var(--muted); font-weight: 700; }.word-suggestions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }.word-suggestions button { border: 2px solid var(--ink); border-radius: 999px; padding: 5px 9px; background: var(--sky); color: var(--ink); font-weight: 800; }.thinking-dot { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--ink); border-radius: 50%; background: var(--sun); animation: thinking-bounce .7s ease-in-out infinite alternate; }@keyframes thinking-bounce { to { transform: translateY(-4px); } }body.dark-theme .word-helper, body.dark-theme .word-lookup-result, body.dark-theme .word-lookup-form input { background: var(--panel); }
.word-helper-close { position: absolute; top: 10px; right: 10px; display: grid; width: 32px; height: 32px; place-items: center; border: 2px solid var(--ink); border-radius: 50%; padding: 0; background: var(--coral); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }.word-helper-close .material-symbols-rounded { font-size: 20px; }
@media (max-width: 560px) { .word-helper { margin-top: 16px; padding: 14px; }.word-helper-heading > .material-symbols-rounded { width: 39px; height: 39px; }.word-helper h2 { font-size: 1.15rem; }.word-lookup-form { gap: 7px; }.word-lookup-form button { padding: 0 12px; } }

.translator-launcher-wrap { display: flex; justify-content: flex-end; margin-top: 12px; }.translator-launcher { display: inline-flex; min-height: 44px; align-items: center; gap: 8px; border: 2px solid var(--ink); border-radius: 12px; padding: 0 13px; background: var(--sky); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); font: 900 .95rem Nunito, sans-serif; animation: translator-wiggle 2.8s ease-in-out infinite; }.translator-launcher:hover { animation-play-state: paused; }.translator-launcher .material-symbols-rounded { font-size: 23px; }@keyframes translator-wiggle { 0%, 78%, 100% { transform: rotate(0); } 84% { transform: rotate(-4deg); } 91% { transform: rotate(4deg); } }.word-helper[hidden] { display: none !important; }
body.dark-theme .translator-launcher { background: var(--sky); color: #20231f; }
body.dark-theme.keyboard-tutorial-open .keyboard-tutorial { background: rgba(0, 0, 0, .76); }.keyboard-tutorial-open .welcome-backdrop { display: none; }
body.dark-theme.game-prompt-open .game-prompt { background: rgba(0, 0, 0, .76); }.game-prompt-open .welcome-backdrop { display: none; }
@media (max-width: 560px) { .translator-launcher { min-height: 42px; padding: 0 11px; }.translator-launcher span:last-child { font-size: .88rem; } }

/* Floating translator: it never takes space away from the game controls. */
.play-zone { position: relative; }.translator-launcher-wrap { position: absolute; right: 20px; bottom: 22px; z-index: 24; margin: 0; }.word-helper:not([hidden]) { position: absolute; right: 20px; bottom: 82px; z-index: 23; width: min(420px, calc(100% - 40px)); margin: 0; }.word-helper[hidden] { display: none !important; }
@media (max-width: 920px) { .translator-launcher-wrap { position: fixed; right: auto; bottom: 16px; left: 16px; z-index: 80; }.word-helper:not([hidden]) { position: fixed; right: auto; bottom: 76px; left: 12px; z-index: 79; width: min(420px, calc(100% - 24px)); max-height: min(56svh, 430px); overflow: auto; }.translator-launcher { border-radius: 50%; width: 52px; min-height: 52px; justify-content: center; padding: 0; }.translator-launcher span:last-child { display: none; }.translator-launcher .material-symbols-rounded { font-size: 27px; } }

/* Bigger, quicker child-friendly welcome. */
.welcome-panel { gap: 15px; width: min(520px, calc(100% - 32px)); border-radius: 16px; padding: 18px 22px; background: var(--sun); color: #20231f; box-shadow: 6px 6px 0 var(--ink); animation-duration: 1.6s; }.welcome-panel strong { font: 800 clamp(1.8rem, 5vw, 2.5rem)/1 Fredoka, "Baloo 2", sans-serif; }.welcome-panel div > span { margin-top: 5px; font-size: 1.05rem; font-weight: 800; }.welcome-star { font-size: 42px; }.welcome-backdrop { animation-duration: 1.6s; }

/* Shared Lingolisten yellow grid background. */
body:not(.dark-theme) {
  background-color: #ffda55;
  background-image:
    linear-gradient(rgba(32, 35, 31, .075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 35, 31, .075) 1px, transparent 1px),
    linear-gradient(120deg, transparent 0 77%, rgba(255, 249, 220, .5) 77% 79%, transparent 79% 100%);
  background-size: 38px 38px, 38px 38px, cover;
}

body:not(.dark-theme)::before { display: none; }

/* Long game names stay inside their cards and reveal themselves on hover. */
.game-card-title { display: block; width: 100%; overflow: hidden; padding: 0 3px; }
.game-card-title-text { display: inline-block; max-width: none; white-space: nowrap; }
.game-card.has-long-title:hover .game-card-title-text,
.game-card.has-long-title:focus-visible .game-card-title-text {
  animation: game-title-marquee 3.4s ease-in-out .35s infinite alternate;
}
@keyframes game-title-marquee {
  0%, 24% { transform: translateX(0); }
  76%, 100% { transform: translateX(var(--title-shift)); }
}
@media (prefers-reduced-motion: reduce) {
  .game-card.has-long-title:hover .game-card-title-text,
  .game-card.has-long-title:focus-visible .game-card-title-text { animation: none; }
}

/* About Renny: parent-friendly card using the same playful system. */
.brand-title-short { display: none; }
.about-me-button { display: flex; width: fit-content; align-items: center; gap: 7px; min-height: 46px; margin: 28px auto 0; border: 2px solid var(--ink); border-radius: 12px; padding: 0 15px; background: var(--lavender); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); font: 900 .95rem Nunito, sans-serif; cursor: pointer; }
.about-me-button .material-symbols-rounded { font-size: 20px; }
.about-me-button:hover { transform: translate(-1px, -1px); }.about-me-button:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.about-me-modal[hidden] { display: none !important; }
.about-me-modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; background: rgba(32, 35, 31, .34); backdrop-filter: blur(7px); }
.about-me-card { position: relative; width: min(650px, 100%); max-height: calc(100svh - 40px); overflow: auto; border: 2px solid var(--ink); border-radius: 18px; padding: 28px; background: var(--paper-warm); box-shadow: 8px 8px 0 var(--ink); }
.about-me-icon { display: grid; width: 56px; height: 56px; place-items: center; margin-bottom: 8px; border: 2px solid var(--ink); border-radius: 16px; background: var(--sky); color: var(--ink); font-size: 32px; }
.about-me-card h2 { margin-bottom: 12px; font-size: 2rem; }.about-me-card p { margin-top: 10px; color: var(--muted); font-weight: 700; line-height: 1.52; }.about-me-card p strong { color: var(--ink); }
.about-me-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }.about-me-actions a { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 48px; border: 2px solid var(--ink); border-radius: 11px; padding: 8px 12px; box-shadow: 4px 4px 0 var(--ink); color: var(--ink); font-weight: 900; text-align: center; text-decoration: none; }.about-preply { background: var(--sun); }.about-email { background: var(--mint); }.about-me-actions a:hover { transform: translate(-1px, -1px); }.about-me-actions a:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
body.dark-theme .about-me-card { background: var(--panel); }.about-me-open { overflow: hidden; }
@media (max-width: 920px) { .about-me-button { position: fixed; left: 50%; bottom: 16px; z-index: 80; min-height: 44px; margin: 0; padding: 0 13px; transform: translateX(-50%); }.about-me-button:hover { transform: translate(-50%, -1px); }.about-me-button:active { transform: translate(-50%, 4px); } }
@media (max-width: 560px) { .brand-title-short { display: inline; }.brand-title-full { display: none; }.about-me-button { bottom: 10px; min-height: 42px; padding: 0 11px; font-size: .86rem; }.about-me-card { max-height: calc(100svh - 24px); padding: 22px 16px; }.about-me-card h2 { font-size: 1.7rem; }.about-me-card p { font-size: .92rem; }.about-me-actions { grid-template-columns: 1fr; }.about-me-actions a { font-size: .9rem; } }
