* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #12121c;
  color: #e8e8f0;
  user-select: none;
}
#app { position: fixed; inset: 0; pointer-events: none; }
#topbar, #scrambleBar, #layerBar, #history, #status { pointer-events: auto; }
canvas { display: block; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: rgba(18, 18, 28, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2a2a3a;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand span { color: #7aa2ff; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 700; letter-spacing: 1px;
  color: #ffffff; min-width: 170px; text-align: center;
}
.timer.running { color: #7dff9b; }

.controls { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.controls label { font-size: 13px; color: #9a9ab0; display: flex; align-items: center; gap: 6px; }
select, button, input {
  background: #1d1d2b; color: #e8e8f0;
  border: 1px solid #33334a; border-radius: 8px;
  padding: 6px 10px; font-size: 14px; font-family: inherit;
}
button { cursor: pointer; transition: background 0.15s; }
button:hover { background: #2a2a40; }
button:active { transform: translateY(1px); }
#btnScramble { background: #2d4a8f; border-color: #3a5fc0; }
#btnScramble:hover { background: #3a5fc0; }

#scrambleBar {
  position: absolute; top: 52px; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: rgba(18, 18, 28, 0.7);
  z-index: 9; flex-wrap: wrap;
}
.scramble-text {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 15px; color: #ffd866; flex: 1; min-width: 220px; line-height: 1.5;
}
.scramble-input { display: flex; gap: 8px; }
.scramble-input input { width: 290px; }

#layerBar {
  position: absolute; top: 98px; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 6px 16px; z-index: 8;
  background: rgba(18, 18, 28, 0.5);
}
#layerBar label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #9a9ab0; }
#layerValue { color: #fff; font-weight: 700; min-width: 20px; text-align: center; }
input[type="range"] { accent-color: #7aa2ff; }
.hint { margin-left: auto; font-size: 12px; color: #6a6a85; }

#history {
  position: absolute; right: 12px; bottom: 12px;
  background: rgba(18, 18, 28, 0.78);
  border: 1px solid #2a2a3a; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; min-width: 180px; z-index: 8;
}
.history-title { color: #9a9ab0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
#historyList { list-style: none; color: #cfcfe0; }
#historyList li { padding: 2px 0; }

#status {
  position: absolute; top: 132px; left: 50%; transform: translateX(-50%);
  background: #1d6b34; color: #d8ffe2;
  padding: 10px 24px; border-radius: 10px;
  font-size: 16px; font-weight: 600; z-index: 20;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s; white-space: nowrap;
}
#status.hidden { opacity: 0; pointer-events: none; }
