* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #13151a;
  color: #e8eaf0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
  display: flex;
  height: 100%;
}

#viewport {
  position: relative;
  flex: 1;
  min-width: 0;
}

#glcanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#glcanvas:active {
  cursor: grabbing;
}

.gl-error {
  padding: 2rem;
  color: #ff8080;
}

#regrip-view {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(38, 43, 54, 0.85);
  backdrop-filter: blur(4px);
  font-size: 13px;
}

#hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #8a90a0;
  pointer-events: none;
}

#status-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #3a3320;
  color: #e8c35a;
  pointer-events: none;
}

#status-badge.solved {
  background: #1e3a26;
  color: #63d98a;
}

#panel {
  width: 320px;
  flex-shrink: 0;
  padding: 20px;
  overflow-y: auto;
  background: #1a1d24;
  border-left: 1px solid #2a2e38;
}

#panel h1 {
  margin: 0 0 16px;
  font-size: 20px;
}

#panel h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a90a0;
}

#panel section {
  margin-bottom: 20px;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.btn-grid.slices {
  grid-template-columns: repeat(4, 1fr);
}

button {
  font: inherit;
  color: inherit;
  background: #262b36;
  border: 1px solid #353b48;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

button:hover {
  background: #303748;
}

button:active {
  background: #3a4257;
}

button.move {
  font-size: 15px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

button.primary {
  background: #2c5faa;
  border-color: #3a70c0;
}

button.primary:hover {
  background: #3670c2;
}

select {
  font: inherit;
  color: inherit;
  width: 100%;
  background: #262b36;
  border: 1px solid #353b48;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  cursor: pointer;
}

#alg-moves {
  margin-bottom: 10px;
  padding: 0 2px;
}

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

.row button {
  flex: 1;
}

.label {
  margin: 0 0 6px;
  font-size: 12px;
  color: #8a90a0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  word-spacing: 4px;
}

#scramble-text {
  background: #12141a;
  border: 1px solid #2a2e38;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
  min-height: 3.2em;
}

.dim {
  color: #8a90a0;
}

#face-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.face-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #f0f2f8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  will-change: transform, opacity;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.check-row input {
  accent-color: #2c5faa;
  cursor: pointer;
}

.grip-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.grip-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.help {
  font-size: 12px;
  color: #8a90a0;
  line-height: 1.5;
}

#credit {
  font-size: 12px;
  color: #8a90a0;
  margin-top: 4px;
}

#credit a {
  color: #b8c2d8;
  text-decoration: none;
}

#credit a:hover {
  text-decoration: underline;
}

@media (max-width: 760px) {
  #app {
    flex-direction: column;
  }

  #viewport {
    height: 55vh;
    flex: none;
  }

  #panel {
    width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid #2a2e38;
  }
}
