* { box-sizing: border-box; }
html { min-width: 320px; background: #008080; }
body { margin: 0; min-height: 100vh; color: #111; font-family: "MS Sans Serif", Tahoma, Arial, sans-serif; font-size: 12px; }
button, input { font: inherit; }
button { color: inherit; }
.desktop { min-height: 100vh; padding: 18px 18px 60px; background: #008080; }
.paint-window { width: min(1260px, 100%); margin: 0 auto; padding: 3px; background: #c0c0c0; border: 3px outset #fff; box-shadow: 12px 12px 0 rgba(0,0,0,.28); }
.titlebar { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 4px 3px 7px; color: #fff; background: linear-gradient(90deg, #000080, #1084d0); }
.title-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.title-name b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.app-icon { display: grid; place-items: center; width: 24px; height: 24px; background: #fff; border: 1px solid #000; }
.window-controls { display: flex; gap: 3px; }
.window-controls span { width: 25px; height: 24px; display: grid; place-items: center; color: #111; font: 900 16px Arial, sans-serif; background: #c0c0c0; border: 2px outset #fff; }
.menu-bar { min-height: 31px; display: flex; align-items: center; padding: 0 6px; }
.menu-bar button { padding: 4px 10px; background: transparent; border: 0; }
.menu-bar button:focus, .menu-bar button:hover { color: #fff; background: #000080; }
.challenge-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 54px; margin: 0 4px 5px; padding: 7px 9px; color: #fff; background: repeating-linear-gradient(135deg, #8500a8 0 20px, #d30075 20px 40px, #e6b800 40px 60px, #007d93 60px 80px); border: 2px inset #eee; text-shadow: 1px 1px #000; }
.challenge-bar > div:first-child { display: grid; gap: 3px; }
.challenge-label { font-size: 9px; font-weight: 900; letter-spacing: .14em; }
#challenge-text { font-size: clamp(12px, 2vw, 16px); }
.challenge-actions { display: flex; align-items: center; gap: 7px; }
.timer { min-width: 60px; padding: 8px; color: #ff0; font: 900 15px "Courier New", monospace; text-align: center; background: #000; border: 2px inset #ddd; }
.workspace { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 5px; min-height: 590px; }
.toolbox { display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 4px; padding: 6px; background: #c0c0c0; border: 2px inset #eee; }
.tool { min-height: 62px; display: grid; place-items: center; align-content: center; gap: 3px; background: #c0c0c0; border: 2px outset #fff; cursor: pointer; }
.tool span { font: 900 25px "Courier New", monospace; }
.tool small { font-size: 8px; }
.tool.active { color: #fff; background: #000080; border: 2px inset #eee; }
.size-box { grid-column: 1 / -1; display: grid; gap: 5px; margin-top: 6px; padding: 8px; text-align: center; background: #fff; border: 2px inset #eee; }
.size-box label { font-size: 9px; font-weight: 900; }
.size-box input { width: 100%; accent-color: #000080; }
.size-box output { font: 11px "Courier New", monospace; }
.canvas-zone { min-width: 0; overflow: auto; padding: 14px; background: #808080; border: 2px inset #eee; }
.canvas-frame { position: relative; width: 960px; max-width: calc(100% - 9px); line-height: 0; background: #fff; box-shadow: 3px 3px 0 #333; }
#paint-canvas { width: 100%; height: auto; display: block; aspect-ratio: 16 / 9; background: #fff; cursor: crosshair; touch-action: none; image-rendering: auto; }
.resize-handle { position: absolute; width: 7px; height: 7px; background: #000080; border: 1px solid #fff; }
.handle-right { right: -9px; top: 50%; }.handle-bottom { bottom: -9px; left: 50%; }.handle-corner { right: -9px; bottom: -9px; }
.bottom-controls { display: grid; grid-template-columns: 54px minmax(260px, 1fr) auto; gap: 8px; align-items: center; padding: 8px 4px; }
.current-colors { position: relative; width: 49px; height: 44px; background: #c0c0c0; border: 2px inset #eee; }
.current-colors span { position: absolute; width: 27px; height: 27px; border: 2px solid #000; }
#color-back { right: 5px; bottom: 5px; background: #fff; }
#color-front { left: 5px; top: 5px; background: #000; }
.palette { display: grid; grid-template-columns: repeat(14, 24px); gap: 3px; align-content: center; }
.swatch { width: 24px; height: 24px; padding: 0; border: 3px outset #fff; cursor: pointer; }
.swatch.active { outline: 2px dotted #000; outline-offset: 1px; }
.action-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.win-button { min-height: 32px; padding: 5px 10px; background: #c0c0c0; border: 2px outset #fff; box-shadow: 1px 1px #000; cursor: pointer; }
.win-button:active { border-style: inset; transform: translate(1px, 1px); }
.win-button:focus-visible, .tool:focus-visible, .swatch:focus-visible { outline: 2px dotted #000; outline-offset: 2px; }
.win-button:disabled { color: #777; text-shadow: 1px 1px #fff; cursor: not-allowed; }
.done-button, .save-button { font-weight: 900; background: #ffef54; }
.statusbar { display: grid; grid-template-columns: 1fr 160px 160px; gap: 3px; }
.statusbar span { min-height: 25px; display: flex; align-items: center; padding: 3px 6px; border: 2px inset #eee; }
.taskbar { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; height: 45px; display: grid; grid-template-columns: auto minmax(180px, 330px) 1fr; gap: 5px; padding: 4px; background: #c0c0c0; border-top: 2px solid #fff; }
.start, .task-app, .clock { min-height: 35px; display: flex; align-items: center; gap: 6px; padding: 0 9px; border: 2px outset #fff; }
.task-app { background: #ddd; border-style: inset; }.clock { justify-self: end; }
.dialog-backdrop { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,.48); }
.dialog-backdrop.hidden { display: none; }
.result-window { width: min(460px, 100%); padding: 3px; background: #c0c0c0; border: 3px outset #fff; box-shadow: 12px 12px rgba(0,0,0,.35); }
.result-body { display: grid; grid-template-columns: 80px 1fr; gap: 14px; align-items: center; padding: 24px; }
.result-icon { color: #d20073; font-size: 65px; text-shadow: 4px 4px #ffdf00; }.result-body h2 { margin: 0 0 7px; color: #000080; }.result-body p { line-height: 1.5; }
@media (max-width: 820px) {
  .desktop { padding: 5px 5px 53px; }
  .challenge-bar { align-items: flex-start; flex-direction: column; }
  .challenge-actions { width: 100%; flex-wrap: wrap; }
  .workspace { grid-template-columns: 1fr; }
  .toolbox { grid-template-columns: repeat(8, minmax(48px, 1fr)); overflow-x: auto; }
  .size-box { grid-column: span 3; min-width: 130px; }
  .canvas-zone { min-height: 50vw; padding: 9px; }
  .bottom-controls { grid-template-columns: 50px 1fr; }.action-buttons { grid-column: 1 / -1; justify-content: flex-start; }
  .palette { grid-template-columns: repeat(7, 24px); }
  .statusbar { grid-template-columns: 1fr auto; }.statusbar span:last-child { display: none; }
}
@media (max-width: 520px) {
  .menu-bar button { padding-inline: 6px; }.menu-bar button:nth-child(4), .menu-bar button:nth-child(5) { display: none; }
  .toolbox { grid-template-columns: repeat(4, 1fr); }.size-box { grid-column: 1 / -1; }
  .palette { grid-template-columns: repeat(7, 22px); }.swatch { width: 22px; height: 22px; }
  .taskbar { grid-template-columns: auto 1fr; }.clock { display: none; }
  .result-body { grid-template-columns: 1fr; text-align: center; }.result-icon { line-height: 1; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
