/* ==========================================================================
   Prism — Optical Puzzle Game Styles
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0a0f1a;
  --bg-elev: #111827;
  --bg-card: #151c2e;
  --fg: #e8edf5;
  --fg-muted: #8b97a9;
  --fg-dim: #5a6778;
  --accent: #22d3ee;
  --accent-dim: #0891b2;
  --warm: #f472b6;
  --warm-dim: #db2777;
  --green: #4ade80;
  --green-dim: #16a34a;
  --amber: #fbbf24;
  --amber-dim: #d97706;
  --red: #f87171;
  --blue: #60a5fa;
  --violet: #c084fc;
  --cyan: #22d3ee;
  --white: #ffffff;
  --border: #2a3548;
  --border-bright: #3a485c;
  --shadow: rgba(0, 0, 0, 0.5);
  --glow-cyan: rgba(34, 211, 238, 0.35);
  --glow-pink: rgba(244, 114, 182, 0.3);
  --glow-green: rgba(74, 222, 128, 0.3);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: 150ms ease;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, monospace;
  --cell-size: clamp(44px, 7vw, 64px);
  --gap: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Background glows */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 { width: 400px; height: 400px; top: -100px; left: -100px; background: radial-gradient(circle, var(--glow-cyan) 0%, transparent 70%); opacity: 0.6; }
.glow-2 { width: 300px; height: 300px; bottom: -50px; right: -50px; background: radial-gradient(circle, var(--glow-pink) 0%, transparent 70%); opacity: 0.5; }
.glow-3 { width: 200px; height: 200px; top: 50%; left: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle, var(--glow-green) 0%, transparent 70%); opacity: 0.3; }

.app { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; padding: clamp(12px, 2vh, 20px); }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 4px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-weight: 600; font-size: clamp(1.1rem, 3vw, 1.4rem); letter-spacing: 0.05em; }
.brand-mark { width: 36px; height: 36px; color: var(--accent); filter: drop-shadow(0 0 8px var(--glow-cyan)); flex-shrink: 0; }
.brand-name { background: linear-gradient(135deg, var(--accent), var(--warm), var(--green)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.header-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  color: var(--fg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition), background var(--transition), transform 100ms ease;
}
.icon-btn:hover { border-color: var(--border-bright); background: var(--bg-elev); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.icon-btn[aria-pressed="true"] .sound-on { display: none; }
.icon-btn:not([aria-pressed="true"]) .sound-off { display: none; }

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
  flex-wrap: wrap;
}
.level-info { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.level-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--fg-dim); font-weight: 600; }
.level-name { font-size: clamp(1rem, 2.5vw, 1.2rem); font-weight: 600; color: var(--fg); }

.stats { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.stat { display: flex; align-items: baseline; gap: 6px; font-size: 0.85rem; }
.stat-label { color: var(--fg-muted); font-weight: 500; }
.stat-value { color: var(--fg); font-family: var(--font-mono); font-size: 1.1em; }
.stat-max { color: var(--fg-dim); font-family: var(--font-mono); font-weight: 400; }
.stat-best .stat-value { color: var(--amber); }

/* Game Area */
.game-area {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 16px;
  margin-top: 16px;
  flex: 1;
  min-height: 0;
  align-items: start;
}

@media (max-width: 1024px) {
  .game-area { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .palette { order: 2; }
  .board-wrap { order: 1; }
  .guide { order: 3; display: none; }
  .guide.open { display: block; }
}

@media (max-width: 640px) {
  .game-area { gap: 12px; margin-top: 12px; }
}

/* Palette */
.palette {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: fit-content;
  max-height: 100%;
  position: sticky;
  top: calc(clamp(12px, 2vh, 20px) + 80px);
}

.palette-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette-header h2 { margin: 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-muted); font-weight: 600; }
.palette-hint { font-size: 0.7rem; color: var(--fg-dim); }

.element-list { list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.element-item {
  --el-color: var(--accent);
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform 100ms ease;
  role: option;
}
.element-item:hover { border-color: var(--el-color); background: var(--bg-card); }
.element-item:active { transform: scale(0.98); }
.element-item.selected { border-color: var(--el-color); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--el-color) 12%, transparent)); box-shadow: 0 0 0 1px var(--el-color), inset 0 0 20px color-mix(in srgb, var(--el-color) 10%, transparent); }
.element-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.element-item.empty { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.element-preview { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--bg); position: relative; }
.element-preview svg { width: 32px; height: 32px; stroke: var(--el-color); fill: none; stroke-width: 2.5; filter: drop-shadow(0 0 6px var(--el-color)); }
.element-preview .preview-beam { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--el-color); filter: blur(2px); opacity: 0.8; animation: beam-pulse 1.5s ease-in-out infinite; }
@keyframes beam-pulse { 0%, 100% { opacity: 0.5; transform: scale(1); } 50% { opacity: 1; transform: scale(1.3); } }

.element-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.element-name { font-weight: 600; font-size: 0.9rem; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.element-desc { font-size: 0.7rem; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.element-count { font-family: var(--font-mono); font-size: 0.85rem; color: var(--fg-dim); background: var(--bg); padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); }
.element-item.selected .element-count { color: var(--el-color); border-color: var(--el-color); }

.palette-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform 100ms ease;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--blue)); color: var(--bg); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 4px 20px var(--glow-cyan); }
.btn-secondary { background: var(--bg-elev); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card); border-color: var(--border-bright); }

/* Board Wrap */
.board-wrap {
  --board-size: clamp(300px, calc(100vh - 320px), 580px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  align-items: center;
}
.board-header,
.board-frame,
.board-controls {
  width: min(100%, var(--board-size));
  align-self: center;
}
.board-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; box-shadow: 0 0 8px currentColor; }

/* Board Frame */
.board-frame { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; max-width: 100%; }
.board-corners { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.corner { position: absolute; width: 24px; height: 24px; border: 2px solid var(--border); background: linear-gradient(135deg, var(--bg-card), var(--bg-elev)); }
.corner.tl { top: -1px; left: -1px; border-radius: var(--radius) 0 0 0; border-right: none; border-bottom: none; }
.corner.tr { top: -1px; right: -1px; border-radius: 0 var(--radius) 0 0; border-left: none; border-bottom: none; }
.corner.bl { bottom: -1px; left: -1px; border-radius: 0 0 0 var(--radius); border-right: none; border-top: none; }
.corner.br { bottom: -1px; right: -1px; border-radius: 0 0 var(--radius) 0; border-left: none; border-top: none; }

.board { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(7, 1fr); gap: var(--gap); padding: var(--gap); width: 100%; height: 100%; position: relative; z-index: 1; }
.cell {
  position: relative;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.cell:hover { background: var(--bg-elev); border-color: var(--border-bright); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; z-index: 3; }
.cell.source { cursor: default; }
.cell.target { cursor: default; }

.cell.placed { border-color: color-mix(in srgb, var(--el-color, var(--accent)) 40%, var(--border)); }

/* Source indicators on grid edges */
.cell.source::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--source-color);
  pointer-events: none;
}
.cell.source.top::before { top: -3px; height: 6px; border-radius: 6px 6px 0 0; }
.cell.source.bottom::before { bottom: -3px; height: 6px; border-radius: 0 0 6px 6px; }
.cell.source.left::before { left: -3px; width: 6px; border-radius: 6px 0 0 6px; }
.cell.source.right::before { right: -3px; width: 6px; border-radius: 0 6px 6px 0; }

/* Target indicators */
.cell.target { overflow: visible; }
.cell.target::after {
  content: "";
  position: absolute;
  width: 60%;
  height: 60%;
  border: 2px solid var(--target-color);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--target-color), inset 0 0 8px var(--target-color);
  transition: box-shadow var(--transition), border-color var(--transition);
  background: transparent;
}
.cell.target.lit::after {
  background: var(--target-color);
  box-shadow: 0 0 20px var(--target-color), inset 0 0 12px var(--target-color);
  animation: target-pulse 2s ease-in-out infinite;
}
@keyframes target-pulse { 0%, 100% { box-shadow: 0 0 15px var(--target-color), inset 0 0 10px var(--target-color); } 50% { box-shadow: 0 0 30px var(--target-color), inset 0 0 15px var(--target-color); } }

/* Placed element rendering */
.placed-element { position: absolute; inset: 4px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.placed-element svg { width: 85%; height: 85%; stroke: var(--el-color); fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px var(--el-color)); }
.placed-element .el-beam { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--el-color); filter: blur(1.5px); opacity: 0.9; animation: el-beam-pulse 1.2s ease-in-out infinite; }
@keyframes el-beam-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* Cursor for keyboard nav */
.cell.cursor { box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--glow-cyan); z-index: 3; }

/* Beam Canvas */
.beam-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }

/* Win Overlay */
.win-overlay { position: absolute; inset: 0; background: rgba(10, 15, 26, 0.95); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; animation: overlay-in 200ms ease; }
.win-overlay[hidden] { display: none !important; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.win-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; max-width: 360px; width: 100%; text-align: center; animation: card-in 300ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes card-in { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: none; } }
.win-icon { width: 64px; height: 64px; margin: 0 auto 16px; color: var(--green); filter: drop-shadow(0 0 16px var(--glow-green)); animation: icon-pop 400ms cubic-bezier(0.16, 1, 0.3, 1) 100ms both; }
@keyframes icon-pop { from { opacity: 0; transform: scale(0.5) rotate(-20deg); } to { opacity: 1; transform: none; } }
.level-clear { margin: 0 0 8px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.2em; color: var(--green); font-weight: 700; }
.win-card h3 { margin: 0 0 20px; font-size: 1.2rem; font-weight: 600; color: var(--fg); }
.win-stats { display: flex; justify-content: center; gap: 24px; margin-bottom: 24px; padding: 16px; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.win-stat { display: flex; flex-direction: column; gap: 4px; }
.win-stat span { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-dim); }
.win-stat strong { font-family: var(--font-mono); font-size: 1.3rem; color: var(--fg); }
.win-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Board Controls */
.board-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 4px 4px 8px; }
.control-group { display: flex; gap: 8px; }
.keys-hint { margin: 0; font-size: 0.65rem; color: var(--fg-dim); text-align: right; flex: 1; min-width: 200px; }
.keys-hint kbd { background: var(--bg); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.7em; color: var(--fg-muted); }

/* Hints */
.hint-panel {
  width: min(100%, var(--board-size));
  align-self: center;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid rgba(192, 132, 252, 0.38);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.12), rgba(34, 211, 238, 0.05));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  animation: hint-panel-in 180ms ease both;
}
.hint-panel[hidden] { display: none !important; }
@keyframes hint-panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.hint-icon { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(192, 132, 252, 0.35); border-radius: 9px; color: var(--violet); background: rgba(192, 132, 252, 0.08); }
.hint-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hint-copy { min-width: 0; flex: 1; }
.hint-copy strong { display: block; margin-bottom: 3px; color: var(--violet); font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; }
.hint-copy p { margin: 0; color: var(--fg); font-size: 0.82rem; line-height: 1.55; }
.hint-close { width: 26px; height: 26px; flex: 0 0 auto; padding: 0; border: 1px solid var(--border); border-radius: 7px; color: var(--fg-muted); background: var(--bg-elev); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.hint-close:hover { color: var(--fg); border-color: var(--border-bright); }
.cell.hint { animation: hint-cell-pulse 900ms ease-in-out 3; }
@keyframes hint-cell-pulse {
  0%, 100% { border-color: var(--border); box-shadow: 0 0 0 rgba(192, 132, 252, 0); }
  50% { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.16), 0 0 22px rgba(192, 132, 252, 0.28); }
}

/* Guide Panel */
.guide { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 20px; height: fit-content; position: sticky; top: calc(clamp(12px, 2vh, 20px) + 80px); max-height: calc(100vh - 120px); overflow-y: auto; }
.guide-header h2 { margin: 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-muted); font-weight: 600; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: step; }
.steps li { position: relative; padding-left: 36px; font-size: 0.85rem; line-height: 1.6; color: var(--fg-muted); }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; color: var(--accent); font-family: var(--font-mono); }
.steps li strong { color: var(--fg); }

.element-legend { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.legend-row { display: flex; align-items: center; gap: 12px; }
.legend-row .el-preview { width: 40px; height: 40px; flex-shrink: 0; border-radius: 6px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.legend-row .el-preview svg { width: 24px; height: 24px; stroke: var(--el-color); fill: none; stroke-width: 2.5; }
.legend-row span { font-size: 0.8rem; color: var(--fg); display: flex; flex-direction: column; gap: 2px; }
.legend-row span small { font-size: 0.65rem; color: var(--fg-dim); font-weight: 400; }

.keys-card { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.keys-card p { margin: 0 0 10px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-dim); font-weight: 600; }
.keys-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.7rem; }
.keys-row kbd { background: var(--bg); border: 1px solid var(--border); padding: 3px 8px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.75em; color: var(--fg-muted); min-width: 56px; text-align: center; }
.keys-row span { color: var(--fg-dim); flex: 1; }

/* Footer */
.footer { display: flex; justify-content: space-between; align-items: center; padding: 16px 4px; margin-top: auto; font-size: 0.75rem; color: var(--fg-dim); flex-wrap: wrap; gap: 8px; }
.footer-note { color: var(--fg-dim); }

/* Help Dialog */
.help-dialog { border: none; background: var(--bg-card); border-radius: var(--radius-lg); padding: 0; max-width: 480px; width: 90vw; box-shadow: 0 24px 60px var(--shadow); animation: dialog-in 200ms ease; }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
.help-dialog::backdrop { background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px); animation: backdrop-in 200ms ease; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elev); color: var(--fg); font-size: 1.4rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--transition), border-color var(--transition); }
.dialog-close:hover { background: var(--bg-card); border-color: var(--border-bright); }
.dialog-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-dialog h2 { margin: 24px 24px 8px; font-size: 1.3rem; font-weight: 600; color: var(--fg); }
.help-dialog > p { margin: 0 24px 20px; color: var(--fg-muted); line-height: 1.6; }
.help-dialog h3 { margin: 20px 24px 12px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-dim); font-weight: 600; }
.help-elements, .help-colors { margin: 0 24px 20px; padding-left: 20px; color: var(--fg-muted); line-height: 1.8; font-size: 0.85rem; }
.help-elements li, .help-colors li { margin-bottom: 8px; }
.help-elements strong { color: var(--fg); }
.el-preview { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); margin-right: 10px; vertical-align: middle; flex-shrink: 0; }
.el-preview svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 2.5; }
.help-tip { margin: 0 24px 24px; padding: 14px 16px; background: linear-gradient(90deg, color-mix(in srgb, var(--amber) 15%, transparent), transparent); border-left: 3px solid var(--amber); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.85rem; color: var(--fg); }
.help-dialog .btn-primary { margin: 0 24px 24px; width: calc(100% - 48px); }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); opacity: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 20px; font-size: 0.85rem; color: var(--fg); box-shadow: 0 12px 40px var(--shadow); z-index: 100; transition: transform 200ms ease, opacity 200ms ease; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Visually hidden */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* High contrast mode */
@media (prefers-contrast: high) {
  :root { --border: #556; --border-bright: #778; --fg-muted: #aaa; }
  .cell { border-width: 2px; }
  .btn-secondary { border-width: 2px; }
}